Skip to content

Instantly share code, notes, and snippets.

@avstudnitz
avstudnitz / ProductCollectionCommand.php
Last active June 14, 2018 09:02
Magento 2 snippet to compare performance of product collections with and without call of ->getCustomAttributes()
<?php
namespace IntegerNet\CustomAttributeTest\Console\Command;
use Magento\Catalog\Model\Product;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
class ProductCollectionCommand extends \Symfony\Component\Console\Command\Command
"firegento/magesetup"
"firegento/pdf"
"avstudnitz/scopehint"
"avstudnitz/admin-notification-advanced"
"integer-net/removecustomeraccountlinks"
"magento-hackathon/hackathon_magemonitoring"
"magento-hackathon/indexer-stats"
"aoepeople/aoe_scheduler"
@avstudnitz
avstudnitz / gist:ed98bb721d26695d5067
Last active February 10, 2020 09:08
Magento: Create SQL queries to recreate all foreign keys which exist in database magento_source but not in database magento_dest
SELECT
CONCAT('ALTER TABLE ', u1.table_name, ' ADD CONSTRAINT ', u1.CONSTRAINT_NAME, ' FOREIGN KEY (', u1.column_name, ') REFERENCES ', u1.referenced_table_name, ' (', u1.referenced_column_name, ') ON DELETE CASCADE ON UPDATE CASCADE;') as 'sql_query'
FROM information_schema.key_column_usage u1
LEFT JOIN information_schema.key_column_usage u2
ON
u1.table_name = u2.table_name
AND u1.column_name = u2.column_name
AND u2.table_schema = 'magento_dest'
AND u2.referenced_table_name IS NOT NULL
WHERE
<?php
class MyCompany_MyModule_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
/**
* Save billing address information to quote
* This method is called by One Page Checkout JS (AJAX) while saving the billing information.
*
* @param array $data
* @param int $customerAddressId
* @return Mage_Checkout_Model_Type_Onepage