Hello everyone. Welcome to our Magento blog! After discovering how Magento works with categories, I continued to research on Catalog Rules and found them very interesting. Thus I cannot wait any longer to share the useful information with you.

As you may know, Magento has two types of price rules: catalog and shopping cart price rules. While shopping cart price rules are applied in the shopping cart, catalog rules are applied on products before they are added to the cart. They are used when you have a new sales policy for a set of products.

  • Rule model and conditions

Firstly, conditions are the core of a catalog rule model. They help the system determine products that were discounted. Catalog rules use product conditions which are similar to:

This condition will filter products of category 13 to apply this rule. When you save and apply the rule, the product prices will be re-indexed by the function applyAll() of the rule model (catalogrule/rule):

* Apply all price rules, invalidate related cache and refresh price index
* @return Mage_CatalogRule_Model_Rule
public function applyAll()
$indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
if ($indexProcess) {

When calculating prices for products, catalog rules catch the event catalog_product_get_final_price to change the product’s prices:


The product’s price was calculated by the function processFrontFinalPrice based on catalog rules data. The price is shown in the frontend as below:

  • Rules database

Magento stores catalog price rules in the main table catalogrule:

You can see that the field conditions_serialized is very important in this table. The task of this field is to store the condition for the rule.

After you apply the rule, Magento will index your price rule and save it to the table catalogrule_product and catalogrule_product_price.

The data in the table catalogrule_product is used to get rules for a product to calculate its price. The structure of this table is as the followings:

Also, data in the table catalogrule_product_price is used to get the final price for the product, depending on many rules. It is re-indexed every day by a cron.

For each product, Magento stores three rows for three days (current day, previous day and the next day). Thus, it helps the system work exactly with many time zones or even when the cron job is missed.

Well! This part ends here. Is there any question or idea? Just drop it in the comment below. I’ll be back and discuss with you.

Over and out!


Why Magestore? We believe in building a meaningful & long-term relationship with you.

1 Comment

Write A Comment