browse the blogs

[ 11 Oct 2015 ]

I’m working on an in-depth ERP project, and ran into a strange problem where I had a reference to a quote object that refused to delete its items. I could run something like this

foreach($quote->getItemsCollection() as $item)
    if("item meets my criteria")

but the items remained in the collection. After a few false starts down the collection caching and _hasModelChanged path I finally found the solution. From a high level? Don’t build your own ORM.

Quote Item Deleting

When you call the deleteItem method on a quote, you’re not actually deleting anything. This method will, at the end of its call-stack, …

[ 26 Sep 2015 ]

If you’ve spent anytime doing Magento 1 module development, you’re probably familiar with the _validateControllerClassName method. This method is where Magento 1 generates and validates paths to possible controller class matches during routing.

This method is gone in Magento 2 – partially due to the PSR-0 autoloader being the standard, even for controller classes, and partially due to refactoring.

Here’s a few similar spots in Magento 2 that can help you track down a non-matching route configuration – you may want to read through my article on Magento 2’s routing and M-V-VM system if you’re a little unclear on what we’re talking about.

First, there’s Magento/Framework/App/Router/Base, where Magento searches for a module match. If your module doesn’t show up in …

[ 16 Sep 2015 ]

In Magento 1, it was possible to register a global variable with the static registry method.

Mage::register('some_var', 'some value');

Many extensions, include core Magento extensions, ended up using this from controller action methods to pass variables into the views.

While its future is uncertain (not marked explicatly supported via an @api, but not marked @deprecated) Magento 2 does have a similar registry object that should help easy the transition for extensions. The class is Magento\Framework\Registry, and you can inject it in any constructor.

public function __construct(//... 
    \Magento\Framework\Registry $registry,
    $this->registry     = $registry;

and then set variables with

$this->registry->register('test_var', 'this is a test!');

and …

[ 10 Sep 2015 ]

The Magento 2 developer documentation is coming along at a good clip. Unlike round one, the company behind Magento has a dedicated team of profesional technology writeres who are cranking out documents based on interviews with the core team, and feedback from the merchant beta.

I’ve seem some complaints that the developer documentation is hard to search – which seems a little silly in the age of Google. If you’re searching for something Magento 2 specific, try using Google’s advanced serach feature to limit yourself to the developer documentation site.

For example, Googling for the following string plugins

will limit your results to the domain.

[ 9 Sep 2015 ]

Every so often in my small Magento 2 experiments, I’ll hit a point where an error like this starts popping up.

Fatal error: Cannot redeclare class Pulsetorm\Helloworld\Observers\Block in /path/to/magento/app/code/Pulsestorm/Helloworld/Observers/Block.php on line 4

I’ll scratch my head for a while, wonder what’s going on, and eventually realize it’s this


i.e. I’ve mistyped a namespace name, and when the initial autoloads loads the class file, it won’t have defined the class it’s looking for, and then a second autoloader (Composer’s usually) loads it again, and tries to redefine the same incorrect class.

i.e., Magento wanted the class


but I defined


thanks to the wrong namespace.

Writing this down here so when it happens again Google will jog my memory. I’m sure you kids with …

[ 27 Aug 2015 ]

Debugging Varnish VCL configuration files | Midwestern Mac, LLC:

Over the past few years varnish has become the “go to” way for Magento systems to paper over serious backend performance problems – which means varnish debugging is quickly becoming a must have skill for Magento developers working at all levels of scalability.

This entire article’s worth a read, but the ability to log from VCL files dirctly to the system log is what drew my attention

In your VCL (at the top), add in import std; to import the std library. Then, anywhere in the vcl, you can log messages to the system log using something like:

std.syslog(0, req.http.Cookie);

[ 10 Aug 2015 ]

Magento 2: How to Check if a Module’s Installed:

Hint: Inject Magento’s Magento/Framework/Module/Manager object.

[ 6 Aug 2015 ]

Magento Patches Finder:

Nice and simple web application that will let you say

Hey, I’m using THIS version of Magento CE

and the application will say back

Then here’s the security patches you want

It’s a pity that the politics of a company in transition don’t let Varien/Magento Inc./Ebay Enterprises/etc. release something like this themselves, but I’m glad I’m working inside a platform/community where things like this exist.

[ 27 Mar 2015 ]


This tool is used to build a minimal Magento environment that allows to run PHPUnit tests for a Magento module on Travis CI.

[ 27 Mar 2015 ]


Clever bit of programming from clockworkgeek (Daniel Deady) that lets you turn any Magento project with a composer.json file into a Magento Connect package.