Skip to content

Instantly share code, notes, and snippets.

View molotovbliss's full-sized avatar
⚗️
Code, Eat, Sleep++;

Jared molotovbliss

⚗️
Code, Eat, Sleep++;
  • DFW, Texas
View GitHub Profile
@molotovbliss
molotovbliss / cronlist.php
Last active December 17, 2015 18:57 — forked from werdan/Magento cron lister
Lists all Magento cron jobs with tables output
<?php
// shell/listAllCron.php
require_once 'abstract.php';
class Mage_Shell_CronLister extends Mage_Shell_Abstract
{
public function run()
{
$cronJobs = Mage::app()->getConfig()->getNode('crontab/jobs');
@molotovbliss
molotovbliss / gist:11afd49aefad10103133
Created December 25, 2015 10:07 — forked from alistairstead/gist:1053331
Find bad things in Magento customisations
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getModel("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getResourceModel("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "Mage::getSingleton("
find . -name "*.phtml" -print | xargs grep --color=auto -iRnH "SELECT.*FROM.*;[\"\']"
find . -name "*.php" -print | xargs grep --color=auto -iRnH "htmlEscape("
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "htmlEscape("
find ./app/code/local -name "*/Block/*.phtml" -print | xargs grep --color=auto -iRnH "SELECT.*FROM.*;[\"\']"
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "\$_[GET|REQUEST|SERVER|POST]"
find ./app/code/local -name "*.php" -print | xargs grep --color=auto -iRnH "public _construct"
find . -name "*.php" -print | xargs grep --color=auto -iRnH "public _construct"
@molotovbliss
molotovbliss / save-large-data-quick.php
Last active September 12, 2018 15:10
Magento: One model save to rule them all for performance!
<?php
// Insert or read all data in one big batch, smallest possible number of queries.
// Sauce: http://inchoo.net/dev-talk/thou-shalt-not-do-inserts-in-a-foreach-unless-you-know-the-trick/
/*** Speed tests say (time in seconds):
100 iterations 1000 iterations 10000 iterations
Insert multiple 0.017 0.079 0.379
Foreach in a transaction 0.074 0.501 4.701
@molotovbliss
molotovbliss / skureport.sql
Created January 20, 2016 19:58
Report by SKUs SQL for Magento
SELECT name, sku, sum(qty_ordered), sum(row_total)
FROM sales_flat_order_item
WHERE price > 0
AND created_at > "2013-01-01 00:00:00"
GROUP BY sku
ORDER BY sku
LIMIT 1000
# note created_at is in UTC
@molotovbliss
molotovbliss / profiler remove
Created January 24, 2016 18:43
Profiler removal one liner & Locate via grep to txt file
Find all profiler entries in codebase:
`grep -l "Varien_Profiler" * -R > profiler.txt`
Find all profiler entries in codebase & remove.
`find . -type f -exec grep -qF 'Varien_Profiler' {} \; -exec sed -i '/Varien_Profiler/d' {} \;`
Sauce: https://magento.stackexchange.com/questions/121/what-parts-of-the-model-layer-can-be-bypassed-in-the-interest-of-performance-opt
@molotovbliss
molotovbliss / Varien-Debug-backtrace.php
Last active July 5, 2018 23:32
Magento Varien_Debug::backtrace() (no truncating output)
EXAMPLE:
echo Varien_Debug::backtrace(true, true); exit;
DECLERATION:
static method backtrace
Prints or return a backtrace
access: public
static string|bool backtrace ([bool $return = false], [bool $html = true], [bool $withArgs = true])
bool $return: return or print
@molotovbliss
molotovbliss / magento-soap-test-catalog-img.php
Created February 2, 2016 03:28
Test Magento SOAP Catalog Product Attribute Media Create
<?php
ob_implicit_flush(true);
umask(0);
set_time_limit(0);
ini_set('display_errors', 1);
$wsdlurl = 'http://example.com/api/soap?wsdl';
$user = 'user';
$key = 'password';
$filename = './media/somefile.jpg';
@molotovbliss
molotovbliss / disable-cache-onblock.xml
Last active February 2, 2016 05:34
Disable caching of block via layout XML
<reference name="footer">
<action method="unsCacheLifetime"></action>
</reference>
@molotovbliss
molotovbliss / dropm2e.sql
Created February 8, 2016 10:07
Drop all M2EPro Magento tables
# Generated with:
# SET SESSION group_concat_max_len = 999999999;
# SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
# AS statement FROM information_schema.tables
# WHERE table_schema = 'databasename' AND table_name LIKE 'm2epro%';
DROP TABLE m2epro_account,
m2epro_amazon_account,
m2epro_amazon_category,
m2epro_amazon_category_specific,
@molotovbliss
molotovbliss / remove-table-prefixes.sql
Last active May 31, 2021 11:22
Remove table prefixes MySQL
# Set @database, @old_prefix and @new_prefix (if you want a different prefix instead of removing)
# Execute the Generated SQL Query this generates to rename all tables found with prefix.
SET SESSION group_concat_max_len = 999999999;
SET @database = "databasename";
SET @old_prefix = "mgn_";
SET @new_prefix = "";
SELECT GROUP_CONCAT("RENAME TABLE ", TABLE_NAME, " TO ", replace(TABLE_NAME, @old_prefix, @new_prefix),'; ' separator '')
FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database AND TABLE_NAME LIKE CONCAT(@old_prefix, '%');