Skip to content

Instantly share code, notes, and snippets.

🏃. 5x Magento Certified, 2x Magento Master. ✝ Follower. Co-host @magetalk,@commercefuture. Organizer @magentosofla. Evangelist @somethingdigitl
<?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 http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
* @author Magento Inc.
*/
@philwinkle
philwinkle / election-results.txt
Created September 1, 2015 20:29
2015 Moderator Election Results
OpenSTV version 1.7 (http://www.OpenSTV.org/)
Suggested donation for using OpenSTV for an election is $50. Please go to
http://www.OpenSTV.org/donate to donate via PayPal, Google Checkout, or
Amazon Payments.
Certified election reports are also available. Please go to
http://www.openstv.org/certified-reports for more information.
Loading ballots from file magento-stackexchange-com-2015-election-results.blt.
@philwinkle
philwinkle / SassMeister-input-HTML.html
Created August 27, 2014 14:47
Generated by SassMeister.com.
<a href="#" class="button">Obnoxious button</a>
@philwinkle
philwinkle / gist:fd3d153b27f7b6da9992
Created August 26, 2014 17:39
PHP 5.4 Dereferencing with an array for a helper
<?php
$__ = array(Mage::helper('yourcompany/helper'), '__');
//usage
echo $__('Translate me');
@philwinkle
philwinkle / reproduce.md
Last active February 24, 2016 08:42
product->load as an antipattern?
<?php

require('app/Mage.php');
Mage::app();


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

var_dump($product-&gt;getData('media_gallery'));
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".

var cornify_count = 0;
var cornify_add = function() {
cornify_count += 1;
var cornify_url = 'http://www.cornify.com/';
var div = document.createElement('div');
div.style.position = 'fixed';
var numType = 'px';
var heightRandom = Math.random()*.75;
var windowHeight = 768;