Skip to content

Instantly share code, notes, and snippets.

View rodde177's full-sized avatar

rodde177

  • sthlm
View GitHub Profile
@rodde177
rodde177 / mysql-docker.sh
Created March 1, 2018 13:54 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@rodde177
rodde177 / Events fired during order submit process
Created May 8, 2017 02:13 — forked from wkw/Events fired during order submit process
Main events fired during one-page checkout in Magento
### Events during order submit process
`core_copy_fieldset_customer_account_to_quote`
`core_copy_fieldset_sales_convert_quote_to_order`
`sales_convert_quote_to_order`
`core_copy_fieldset_sales_convert_quote_address_to_order`
`sales_convert_quote_address_to_order`
`core_copy_fieldset_sales_convert_quote_address_to_order_address`
`sales_convert_quote_address_to_order_address`
@rodde177
rodde177 / Magento 1.x Orphaned Records Cleanup.md
Created April 24, 2017 13:57 — forked from dfelton/Magento 1.x Orphaned Records Cleanup.md
Deletes orphaned records from a Magento 1.x database.

Purpose

The purpose of this SQL script is to clean up a Magento 1.x database by deleting orphaned records from database tables which cause foreign key contraint failures. This happens when at some point in time records where deleted from the database while FOREIGN_KEY_CHECKS = 0 and the person performing the delete operations failed to delete all related records pertaining to related tables of the primary table.

This script can be helpful when encountering foreign key constraint failures using the Data Migration Tool to migrate your

@rodde177
rodde177 / Magento 2 - tar exclusion parameters.MD
Created April 24, 2017 13:54 — forked from dfelton/Magento 2 - tar exclusion parameters.MD
Magento 2 - Directories to exclude when tarballing a site

Exclusion List

List of exclusion paramters for tar command. Focus put on image cache directories, tmp files, log files, and generated source files.

  • --exclude="./pub/media/*/*/cache"
  • --exclude="./pub/media/js"
  • --exclude="./pub/media/tmp"
  • --exclude="./pub/media/wysiwyg/.thumbs"
@rodde177
rodde177 / Observer.php
Created March 17, 2017 01:12 — forked from IvanChepurnyi/Observer.php
Optimized catalog price rules
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
n98-magerun.phar config:dump | xmlstarlet sel -t -m '/config/global/events/*/observers/*' -v ./class -o ' ' -v ./method -o ' ' -v ./type -n
@rodde177
rodde177 / magento quering
Created February 6, 2017 12:03 — forked from srinathweb/magento quering
magento quering
http://fishpig.co.uk/magento/tutorials/direct-sql-queries/
Yes you can run direct sql queries within Magento, the best way to do this is to use the read write resource. You can insatiate it with:
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
To run a select you can do something like this:
// 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)
<?php
namespace Vendor\Module\Test\Unit;
use Magento\Framework\App\ObjectManagerFactory as AppObjectManagerFactory;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\App\Filesystem\DirectoryList;