Skip to content

Instantly share code, notes, and snippets.

View twosg's full-sized avatar

Sven Geiß twosg

View GitHub Profile
@hostep
hostep / composer-v2-support-older-magento2-versions.md
Last active January 27, 2024 10:37
Add composer v2 support to older Magento2 versions

Add composer v2 support to older Magento2 versions

Magento 2.3.7 and 2.4.2 ship with composer v2 support out of the box but as far as I can see the only thing that needs to happen is to use some more modern versions of certain composer plugins which are used by certain dependencies of Magento.

This means we should be able to add composer v2 support to older Magento2 versions as well if we get a bit creative.

See below for diffs of the composer.json files you can apply to your projects, be sure to keep a mental note of these things, they will need to maintained by yourself in case newer versions of these modules are released. And if one day you update to Magento 2.3.7 or 2.4.2 or higher, you can remove these changes again.

⚠️ Disclaimer: use these tricks at your own risk!

@ProcessEight
ProcessEight / Testing in Magento 2.md
Last active February 7, 2024 14:42
M2: Notes on setting up PHPUnit and writing/troubleshooting tests in Magento 2
@Vinai
Vinai / M2 acl.xml
Last active October 17, 2023 05:38
My current Magento 2 PHPStorm File Templates (Feb 2016)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
</resource>
</resources>
</acl>
</config>
@SchumacherFM
SchumacherFM / pt-duplicate-key-checker.sql
Last active February 5, 2023 15:10
pt-duplicate-key-checker for Magento 1.8 MySQL database. Less indexes the faster the update/insert statement
# ########################################################################
# api2_acl_attribute
# ########################################################################
# IDX_API2_ACL_ATTRIBUTE_USER_TYPE is a left-prefix of UNQ_API2_ACL_ATTRIBUTE_USER_TYPE_RESOURCE_ID_OPERATION
# Key definitions:
# KEY `IDX_API2_ACL_ATTRIBUTE_USER_TYPE` (`user_type`)
# UNIQUE KEY `UNQ_API2_ACL_ATTRIBUTE_USER_TYPE_RESOURCE_ID_OPERATION` (`user_type`,`resource_id`,`operation`),
# Column types:
# `user_type` varchar(20) not null comment 'type of user'
@peterjaap
peterjaap / removeTestDataResetEntitySeries.sql
Last active May 30, 2019 02:48
Remove orders, invoices, shipments, creditmemos, customers and quotes from Magento
# Empty relevant tables
DELETE FROM sales_flat_creditmemo;
DELETE FROM sales_flat_invoice;
DELETE FROM sales_flat_order;
DELETE FROM sales_flat_quote;
DELETE FROM sales_flat_shipment;
DELETE FROM customer_entity;
# Reset increment_ids
# Beware of store_ids when using multiple stores
@peterjaap
peterjaap / Magento generated events
Created October 14, 2013 09:44
Magento generated events; a number of models use automatically generated events through prefixes. This is a (non-exhaustive) list of a number of those events, combined with _save_before, _save_after, _save_commit_after, _delete_before, _delete_after, _delete_commit_after, _load_before & _load_after.
tag_save_after
admin_roles_save_after
admin_user_save_after
review_save_after
catalogsearch_query_save_after
sales_order_save_after
sales_quote_address_save_after
sales_quote_payment_save_after
sales_quote_item_save_after
sales_quote_save_after
@jkaflik
jkaflik / magento_fix_stock_items.sql
Created May 27, 2013 09:54
Fix for "Stock item for Product is not valid" error in Magento 1.x. It reproduces cataloginventory_stock_item using product entities.
INSERT INTO `cataloginventory_stock_item` (
`item_id` ,
`product_id` ,
`stock_id` ,
`qty` ,
`min_qty` ,
`use_config_min_qty` ,
`is_qty_decimal` ,
`backorders` ,
`use_config_backorders` ,
@kalenjordan
kalenjordan / Batched Iterator for Magento collections
Last active May 9, 2022 12:25
Batched iterator for Magento collections
// This is how you would use it. Pass in your collection
// along with an individual callback as well as a batch callback
Mage::getSingleton('stcore/resource_iterator_batched')->walk(
$collection,
array($this, 'batchIndividual'),
array($this, 'batchAfter'),
self::BATCH_SIZE
);
public function batchIndividual($model)
@yireo
yireo / create_website_scope.php
Last active October 1, 2020 11:02
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
@arosenhagen
arosenhagen / magento-code-snippets.md
Last active April 8, 2024 09:21
[magento] - code snippets

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name