Skip to content

Instantly share code, notes, and snippets.

View yvoronoy's full-sized avatar

Yarik Voronoy yvoronoy

View GitHub Profile
@yvoronoy
yvoronoy / sql-snippets
Last active September 8, 2017 22:07
Magento Check unprocessed changelog counts
SELECT version_id - (SELECT version_id FROM enterprise_mview_metadata WHERE changelog_name = 'enterprise_url_rewrite_redirect_cl') FROM enterprise_url_rewrite_redirect_cl ORDER BY version_id DESC LIMIT 1;
SELECT version_id - (SELECT version_id FROM enterprise_mview_metadata WHERE changelog_name = 'cataloginventory_stock_status_cl') FROM cataloginventory_stock_status_cl ORDER BY version_id DESC LIMIT 1;
SELECT version_id - (SELECT version_id FROM enterprise_mview_metadata WHERE changelog_name = 'enterprise_url_rewrite_category_cl') FROM enterprise_url_rewrite_category_cl ORDER BY version_id DESC LIMIT 1;
SELECT version_id - (SELECT version_id FROM enterprise_mview_metadata WHERE changelog_name = 'enterprise_url_rewrite_product_cl') FROM enterprise_url_rewrite_product_cl ORDER BY version_id DESC LIMIT 1;
SELECT version_id - (SELECT version_id FROM enterprise_mview_metadata WHERE changelog_name = 'catalog_category_product_index_cl') FROM catalog_category_product_index_cl ORDER BY version_id DESC LIMIT 1;
SELECT
@yvoronoy
yvoronoy / .bash_aliases
Created March 31, 2016 23:42
My Magento Bash Aliases
#Magento Aliases
alias m1.clear.cache='echo "rm -rf var/*cache*"; rm -rf var/*cache*'
alias m1.show.version='cat app/Mage.php | grep -A 10 "function getVersionInfo"'
alias m1.mysql.debug.enable='\
sed -i "" "s/_debug[ ]*= false/_debug = true/g" lib/Varien/Db/Adapter/Pdo/Mysql.php; \
sed -i "" "s/_logAllQueries[ ]*= false;/_logAllQueries = true;/g" lib/Varien/Db/Adapter/Pdo/Mysql.php; \
sed -i "" "s/_logCallStack[ ]*= false;/_logCallStack = true;/g" lib/Varien/Db/Adapter/Pdo/Mysql.php';
alias m1.mysql.debug.disable='\
sed -i "" "s/_debug[ ]*= true/_debug = false/g" lib/Varien/Db/Adapter/Pdo/Mysql.php; \
sed -i "" "s/_logAllQueries[ ]*= true;/_logAllQueries = false;/g" lib/Varien/Db/Adapter/Pdo/Mysql.php; \
@yvoronoy
yvoronoy / my.cnf
Last active December 22, 2022 17:57
MySQL Magento Config
[mysqld]
## After edit config you have to remove log files and restart mysql server
## because after changing innodb-log-file-size you should recreate ib_logfiles
## Stop MySQL server
## rm /data/dir/ib_logfile*
## Run MySQL server
##Table open cache under MacOS and MySQL 5.6 should be 250.
##Otherwise you will get error MySQL server has gone away
##table-open-cache = 250
function m2sniff()
{
phpcs --standard=EcgM2,PSR1,PSR2 $1;
vendor/bin/phpmd $1 text cleancode, codesize, controversial, design, naming, unusedcode
}
@yvoronoy
yvoronoy / m1fakedata.php
Created June 10, 2016 09:59
Generate Magento1 Test Data
#!/usr/bin/php
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@yvoronoy
yvoronoy / COMPOSER_AUTH env
Created June 12, 2016 10:04
How to set COMPOSER_AUTH env
#Travis CI
export COMPOSER_AUTH='{"http-basic":{"repo.magento.com": {"username": "public-key", "password": "secret-key"}}}'
@yvoronoy
yvoronoy / Magento2-Rest-Link-Configurable-Products
Created September 13, 2016 06:39
Magento2 Rest Link Configurable Products
#!/bin/bash
function runCommand()
{
echo $CMD;
eval $CMD;
}
N98=$(which n98-magerun2.phar);
command -v $N98 >/dev/null 2>&1 || {
echo "I require $N98 tool but it is not installed" >&2;
@yvoronoy
yvoronoy / CODE_AND_DB_DUMP.MD
Last active April 26, 2023 08:35 — forked from tshabatyn/CODE_AND_DB_DUMP.MD
How to Generate Magento2 Code and DB dumps

Code dump

You can use tiny script m2dump it is doing the same thing as described below.

Estimate size of directories and exclude no needed.

du -sh ./* | sort -h
@yvoronoy
yvoronoy / m2dump
Last active September 10, 2019 14:33
Magento 2 Code and DB dumps
#!/usr/bin/env bash
function runCommand
{
echo "${CMD}"
eval ${CMD};
}
function getDb
{
echo $(grep [\']db[\'] -A 20 app/etc/env.php | grep $1 | head -n1 | sed "s/.*[=][>][ ]*[']//" | sed "s/['][,]//");
return 0;