Home » Magento14 June 2011

Magento: Create Catalog Price Rule Programmatically

Here, you will see how to create Catalog Price Rule in Magento through code.

Catalog Rules are applied on products before they are added to the cart.

To create a Catalog Price Rule from Admin Panel, we go to Promotions -> Catalog Price Rules and select Add New Rule.

Basically, there are three main parts for Catalog Price Rule, i.e. Rule Information, Conditions, and Actions.

Here is the code to create Catalog Price Rule. In this code example, I have created Catalog Price Rule with the following information:-

– The rule is applied to particular product with the particular SKU (in our case: ‘chair’)
– The rule is applied as Fixed Amount Discount To certain amount (in our case: 20) of currency amount

A new Catalog Price Rule with the name “My Catalog Price Rule” has been created. You can view the rule from Promotions -> Catalog Price Rules in admin.

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Pravin Agham

    Hi, with your script I successfully created the Catalog price rule in magento but later I found that it doesn’t apply to product.   I have to manually click on “Save and Apply” button and then it get reflect…
    Can you have any idea why this is so..?


  • Bryan

    you make me happy.  very. very. happy.

  • Chw

    Where do I have to place this code to make it work. Would that work with version
    thanks a lot.

  • Bala

    I’m getting the following error

    error Serialization of ‘SimpleXMLElement’ is not allowed

    when I call $catalogPriceRule->getConditions()->addCondition($skuCondition);

    Can you please let me know the issue here ?

  • Ramesh Kr

    In which file this code to be placed.