we have around 1300 shopping cart price rules. we now added a new product that we want't to exclude from all of our shopping cart price rules. what is the best way to do that? I though of updating the conditions of the shopping cart price rules programmatically, but I have no idea how to handle the serialized conditions.


  • You want to "Apply the rule only to cart items matching the following conditions"? There is only available for product: "Attribute set" or "Category". How do you select your product? By category or specific attribute set?
    – mkutyba
    Commented Mar 28, 2015 at 0:14
  • hi, yes this product is in a category that can be used to exclude it from shopping cart price rules. i know how to do it in the admin backend, but as we have so many rules i need a programmatically solution to update all of them with a script.
    – maigner
    Commented Mar 28, 2015 at 9:03

1 Answer 1


I don't know if there is some more OO solution, but my code just works.

$model = Mage::getModel('salesrule/rule')

foreach ($model as $item) {
    if (!in_array($item->getId(), [11,12,13])) continue; //which rules you want to modify, or comment this line to modify all

    $actions = unserialize($item->getActionsSerialized());

    $actions['conditions'][] = [
        'type' => 'salesrule/rule_condition_product',
        'attribute' => 'category_ids',
        'operator' => '==',
        'value' => 3, // insert here your category id
        'is_value_processed' => false


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.