Fixing Magento's catalog rules (188.8.131.52)
While working on a new version of a Magento website using v184.108.40.206, I came accross a bug which affects the way catalog rules are evaluated, and makes the resulting price index wrong. At first, I thought the problem lied with the conditions engine, but since there wasn’t any significant code change between 220.127.116.11 and 18.104.22.168 in Mage_Rule, I started to search elsewhere.
A few changes were made to Mage_CatalogRule in Magento’s latest stable iteration.
Here what the release notes from 22.214.171.124 have to say about promotional price rules:
- Catalog price rules are applied properly to customer groups.
- The scope of a product attribute is now honored by a catalog price rule.
Sounds good, except the latter breaks everything.
The scope of attributes is honored only for website-scoped attributes. As of 126.96.36.199, you can’t use (or I’m completely misguided) any globally-scoped attribute in a condition of a catalog rule without breaking it.
The fix is quite simple and should be applied to Mage_CatalogRule_Model_Rule_Condition_Product, so I made a simple module to override this class. It’s available here on Bitbucket.
Here’s the fix, explained in details.
I don’t really know if it’s the right fix to apply, but it doesn’t seem to be intrusive, and it works well after that, so for now, I’ll use that way!
I have the feeling there might be some other issues with the changes introduced in Mage_CatalogRule, but it seems to be mostly because my project is not running from a fresh install of Magento.
Enjoy your next Magento debugging session!
Yet-to-be successful software developer, crazy Android lover and open-source enthusiast