Archive for October, 2011

Resolving Magento module dependencies without using the “depends” element

October 13th, 2011

You might someday (or perhaps you already have) come across a case where you want one module to be loaded after another module, but don’t necessarily want it to depend on the other module. Reasons might be that one config value should override another (such as a model/block/controller rewrite), or one layout should be applied after another (such as to remove a block added by the former). There might not actually be a dependence, or perhaps adding a dependence would create a circular dependency. There are two possible solutions for this:

  1. Merge the two (or more) module .xml files manually into one .xml file with the proper XML element order.
  2. Name the .xml files (or symlinks modman) such that they sort alphabetically in the proper order.

The element order within a single file will be stable (SimpleXML), and Magento loads the files alphabetically except that those beginning with Mage_ come first. Problem solved.



Now “My_Module” is loaded after “Their_Module” so I can override their config and/or layout without modifying their files and without My_Module depending on Their_Module!


Benchmarking Zend_Cache backends for Magento

October 3rd, 2011

The Zend_Cache module from the Zend Framework is a nice piece of work. It has a slew of programmer-friendly frontends and a respectable set of backends with a well-designed interface. I love the a-la-carte approach, but I am only really interested in the Zend_Cache_Core frontend and the backends that support tagging since that is what is required by Magento. This begs the question, which backend should you use? While I have my own opinion on that matter (ahem, Redis. -post coming soon-ish), I wanted a reliable way to test Zend_Cache backend performances so I wrote a benchmark! This benchmark was both forked from and inspired by the benchmark found in Vinai Kopp’s Symlink Cache. It uses Magento’s core/cache model rather than Zend_Cache_Core directly so a Magento (or Magento-lite) installation and bash are the only requirements.

The purpose of this post is not to provide a bunch of cache backend benchmarks, but rather to simply introduce my benchmark code in the hopes that others conduct their own tests and hopefully publish their findings. A link to this post is appreciated. Also, if there are any criticisms of the benchmark I’d love to see a pull request. :)

Read more…

Magento , ,