Skip to content

Instantly share code, notes, and snippets.

View gist:727f50243cb722d9d4941f18c72474c1
🏃. 5x Magento Certified, 2x Magento Master. ✝ Follower. Co-host @magetalk,@commercefuture. Organizer @magentosofla. Evangelist @somethingdigitl
View magento-check.php
* A simple fix for a shell execution on preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
* The only edit that was done is that shell_exec('mysql -V') was changed to mysql_get_server_info() because not all
* systems have shell access. XAMPP, WAMP, or any Windows system might not have this type of access. mysql_get_server_info()
* is easier to use because it pulls the MySQL version from phpinfo() and is compatible with all Operating Systems.
* @link
* @author Magento Inc.
philwinkle / election-results.txt
Created Sep 1, 2015
2015 Moderator Election Results
View election-results.txt
OpenSTV version 1.7 (
Suggested donation for using OpenSTV for an election is $50. Please go to to donate via PayPal, Google Checkout, or
Amazon Payments.
Certified election reports are also available. Please go to for more information.
Loading ballots from file magento-stackexchange-com-2015-election-results.blt.
philwinkle / SassMeister-input-HTML.html
Created Aug 27, 2014
Generated by
View SassMeister-input-HTML.html
<a href="#" class="button">Obnoxious button</a>
philwinkle / gist:fd3d153b27f7b6da9992
Created Aug 26, 2014
PHP 5.4 Dereferencing with an array for a helper
View gist:fd3d153b27f7b6da9992
$__ = array(Mage::helper('yourcompany/helper'), '__');
echo $__('Translate me');
philwinkle /
Last active Feb 24, 2016
product->load as an antipattern?


$product = Mage::getModel('catalog/product')->getCollection()->getFirstItem();

View Observer.php
class Sample_Model_Observer
protected $colToAdd = 'colname';
* @param Varien_Event_Observer $observer
public function urapidflow_profile_action( $observer )
$action = $observer->getData( 'action' );
$profile = $observer->getData( 'profile' );

Debugging (Resource) Model Instantiation

Follow each step manually and any bugs during (resource) model instantiation will become obvious.

Since many people find model and resource model instantiation to be one of the more challenging things in Magento 1, these are all the steps Magento does to resolve the factory name to the real PHP class name.

To debug, simply follow each step manually until you find a non-match. This works really well in my experience.
Less guessing, more and faster results.

In the examples I use a factory name of "example/thing".

View cornify.js
var cornify_count = 0;
var cornify_add = function() {
cornify_count += 1;
var cornify_url = '';
var div = document.createElement('div'); = 'fixed';
var numType = 'px';
var heightRandom = Math.random()*.75;
var windowHeight = 768;