browse the blogs

[ 26 Dec 2014 ]

Magento Sellers Guide to Sales Tax:

A relatively straight forward article about how to collect sales tax for an ecommerce business. It’s remarkable how much hand waving there is about this from agencies representing themselves as ecommerce experts.

[ 23 Dec 2014 ]

If Magento 2 is your first introduction to PHP namespaces, here’s one small thought technology that might help. Consider the following

namespace Foo\Baz;
class Bar {

The above does not define a class named Bar. It defines a class named “Foo\Baz\Bar”. That’s how PHP sees the class internally, and once you start thinking about classes the same way PHP does, they start making more sense, (or, at least, they did for me)

[ 21 Dec 2014 ]

If you’re trying to use the browser setup workflow in the Magento 2 beta released in December of 2014, make sure your web server is using the index.php in the root of the project and not the pub/index.php file.

It’s unclear which index.php is “the right” file to point to — the pub folder seems to be an attempt to adopt a more modern, Symfony like approach that keeps your code and your web serve-able file separate, but the root level index.php seems like an affordance for developers used to Magento’s traditional structure.

[ 21 Dec 2014 ]

If you’re using Vagrant to manage your Magento 2 installations, you’ll want to be careful with file permissions. By default, it appears that Vagrant’s synced folder setup won’t allow the apache/web user to create folders with permissions elevated higher than the default sync share.

Dropping in some custom mount options should fix this up, and while 0666 and 0777 aren’t ideal, that seems to be world we live in nowadays.

[ 21 Dec 2014 ]

Magento 2 Profiler:

There’s still a lot of work to be done before Magento 2 is ready for general release, and a lot of that work will involve performance tuning. The old UI for enabling/disabling the built in profiler is gone, but this Stack Exchange answer from Marko Martinović tells you how to enable it. (a MAGE_PROFILER server environment variable with values of html, csv, etc)

[ 20 Dec 2014 ]

Two Vagrant boxes for the newly released Magento 2 beta.

The first is maintained by Rolando Granadino (beeplogic to Twitter folks), and is a fully featured opinionated box, with puppet provisioning, web grind for xDebug profiling, and git submodules for project dependencies.

The second is a lightweight affair from Alan Kent, Magento 2’s current lead architect.

If you’re never used Vagrant before, it’s a program for managing and creating virtual machines from the command line. If you’ve never used virtual machines before, they’re a way to “run” another computer operating system from your main computer operating system. Two virtual computers on one physical machine. Using virtual linux machines is a popular way to manage different software stacks. …

[ 17 Jul 2014 ]

Configuration Gaslighting Checklist:

A quick Stack Overflow answer from yours truly that covers what to do when you think Magneto’s gaslighting you on configuration values you’re sure you’ve changed.

[ 16 Jul 2014 ]

I needed to grab a few category names when all I had were the category IDs

$categories = Mage::getModel('catalog/category')->getCollection()
->addFieldToFilter('category_id', array('in'=>$product['category_ids']));

Can you spot the error? PHP complained with the following error

Fatal error: Call to a member function getBackend() on a non-object in /Users/alanstorm/Sites2014/ on line 816

Can you spot the error now? Unless you happen to be working on a project where you’re deep inside Magento’s EAV implementation, the above error message is worse than useless when it comes to tracking down the actual error.

The problem was I used category_id — and a Magento category object has no such field. I should have used entity_id. Easy brain fart — made easier in that Magento doesn’t stick to the …

[ 13 Jul 2014 ]

In a stock Magento system, there’s several tables where a row will have an ID field of 0.

mysql> select * from core_store\G:
*************************** 1. row ***************************
  store_id: 0
      code: admin
website_id: 0
  group_id: 0
      name: Admin
sort_order: 0
 is_active: 1
*************************** 2. row ***************************
  store_id: 1
      code: default
website_id: 1
  group_id: 1
      name: Default Store View
sort_order: 0
 is_active: 1

In turn, there are times where the Magento application will assume these 0 ID rows exist. For example, a store ID of 0 is always interpreted as the admin store object.

In day to day operations this is no big deal — however MySQL …

[ 7 Jul 2014 ]

If you’re new to Magento, you may not realize that every remote API method has a native PHP equivalent. The why, how, and how to identify these models is covered elsewhere, but one thing I forget at my peril is how useful the API methods are when I need to serialize something as JSON or via PHP’s serialize function.


$data = serialize(Mage::getModel('catalog/product')->load($product_id));

What’s great about the API load methods is they automatically return a simple PHP array full of scaler values. Compare that to something like this


While they may seem equivalent, the catalog/product object is going to have a lot of other object references — which …