Dane Lowe

Articles tagged 'Magento'

14 November 2015

Magento's Flat Catalog Remembers Store ID

If you're using store emulation, and loading product collections while emulating a store, you need to be aware of one massive gotcha.

Magento keeps the store id for a flat collection in a singleton

Consider the following code:

public function reindexAll()
    foreach (Mage::app()->getStores() as $_store) {

protected function _reindex($storeId, $products = null)
    $initialEnvironment = Mage::getSingleton('core/app_emulation')
23 September 2015

How Time Fields work in Magento

Magento stores time values in the system config database table as comma-separated values for hours, minutes, and seconds, but it displays the configuration options as three dropdown boxes.

I've often wondered what class controlled this behaviour, thinking there would be some canonical way of creating config values composed of multiple HTMl fields.

As it turns out, this behaviour is not specific to time fields. core/config_data models just naively serialize arrays to comma-separated values...

5 February 2015

Simple and Robust Nginx config for Magento

I have a few requirements for my Magento Nginx configuration

  1. I need to understand what it is doing, at first glance.
  2. I need to be able to create subdomains in a DRY fashion.
  3. It needs to be secure.
  4. It needs to work, and be performant.

This is not using any load-balancer. It is a single server fronted by Nginx.

This isn't too much to ask, but the idiomatic Nginx config for Magento just wasn't cutting it for me.

I've always been bugged by the fact that Magento dumps application code...

22 January 2015

Bulk updating EAV attributes in Magento

Don't fear the EAV

EAV in Magento is a pain. It's slow and difficult to manage. But it's not going away.

Sometimes (well, all of the time) I wish there was a PostgreSQL adapter for Magento and it did away with EAV for one of the many features (HSTORE, JSON field queries) Postgres has that makes EAV in Magento's case unecessary. I think that is a project for another day.

Right now. There are many situations where data just needs to be stored in an EAV attribute. Sorting, for example, is designed...

19 April 2013

How to get an EAV product collection when Flat Catalog is Enabled

There are certain times when your attribute filters just won't work when you're using a flat catalog product collection, namely when you're filtering by multivalued attributes, or attributes not in the index.

This simple fix will allow you to programmatically choose whether the collection should act as an EAV collection or as the default collection specified by admin.

The description assumes you already have an extension set up (of course you already have one set up if you need this)