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 / Kittens.js
Created June 1, 2015 09:24
Everyone gets a kitten bookmarklet
javascript:(function(){var kittens=function(){for(var b=document.images,a=0;a<b.length;a++){var c=b[a].width,d=b[a].height;if(c&&d)b[a].src='http://placekitten.com/'+c+'/'+d}return false};kittens();})()
@molotovbliss
molotovbliss / gist:2e4dcfb5657d70310719
Created July 8, 2015 15:53
Monitor memcache with a PHP oneliner
watch 'php -r '"'"'$m=new Memcache;$m->connect("127.0.0.1", 11211);print_r($m->getstats());'"'"
<?php
$database_host = "localhost";
$database_user = "username";
$database_password = "password";
$magento_database = "databasename";
$table_prefix = "prefixhere_";
$dryrun = true; // change to false when you want to commit changes
$db = mysql_connect($database_host, $database_user, $database_password);
@molotovbliss
molotovbliss / dropalltables.sql
Created July 21, 2015 14:33
Drop all tables via SQL /w disable of foreign key checks
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@molotovbliss
molotovbliss / indexers.php
Last active December 31, 2015 08:08
Disable indexers/Enable Indexers
protected function _getIndexers()
{
return Mage::getSingleton('index/indexer')->getProcessesCollection();
}
protected function _stopReindex()
{
$this->_getIndexers()->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));
$this->_getIndexers()->walk('save');
}
@molotovbliss
molotovbliss / options-to-products.php
Created September 20, 2015 21:22
Options (colors) to Products
<?php
require_once('app/Mage.php');
ob_implicit_flush(true);
umask(0);
set_time_limit(0);
ini_set('display_errors', 1);
Mage::app();
Mage::setIsDeveloperMode(true);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@molotovbliss
molotovbliss / JSONArrayFileUtil.php
Last active April 2, 2021 15:16
Simple PHP Class to save an array to disk and read it back into a PHP Array using JSON.
<?php
/**
* Save an PHP Array to disk with a delimiter to support
* multiple array values. Associative Array supported.
*
* @author Jared Blalock ([email protected])
* @link http://molotovbliss.com
*/
Class Json_Array {
@molotovbliss
molotovbliss / updateprice.php
Created November 20, 2015 15:53
Update Product Price Programmatically
<?php
// drop into Magento root directory updateprice.php and execute
require_once('app/Mage.php');
ob_implicit_flush(true);
umask(0);
set_time_limit(0);
ini_set('display_errors', 1);
ini_set('memory_limit', '2048M');
@molotovbliss
molotovbliss / gist:4f71f6242a16fa894a92
Last active December 7, 2015 09:03
Debugging Layout XML issues
Source: https://magento.stackexchange.com/questions/95/debugging-layout-xml-loading
You can log the compiled layout XML directives which are used to generate blocks. Create an observer on controller_action_layout_generate_blocks_before, and in the observer method log the update XML from the transported layout object:
public function logCompiledLayout($o)
{
$req = Mage::app()->getRequest();
$info = sprintf(
"\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
$req->getRouteName(),
@molotovbliss
molotovbliss / fastproductupdate.php
Created December 2, 2015 01:02
Use Iterator to mass update products for performance optimization
// Get Collection
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('publihser')
->addFieldToFilter(array(array('attribute'=>'publisher','eq'=>$publisher)));
function productUpdateCallback($args){
$product = Mage::getModel('catalog/product');
$product->setData($args['row']);
$productId = $product->getId();