I am trying to create a magento catalogue price rule with condition combined using 'any' instead of 'all'
The following code creates a rule with two conditons - but they are combined using all. Does anyone know how to achieve this? I'm using magento 1.7.0.2 (Community Edition)
$skuCondition = Mage::getModel('catalogrule/rule_condition_product')
->setType('catalogrule/rule_condition_product')
->setAggregator('any')
->setAttribute('category_ids')
->setOperator('==')
->setValue('18');
$skuCondition2 = Mage::getModel('catalogrule/rule_condition_product')
->setType('catalogrule/rule_condition_product')
->setAttribute('category_ids')
->setOperator('==')
->setValue('40');
$catalogPriceRule->getConditions()->addCondition($skuCondition);
$catalogPriceRule->getConditions()->addCondition($skuCondition2);
$catalogPriceRule->save();
By changing my approach and using one rule with a different condition I managed to achieve the same thing as below. Notice the use of '()' instead of '==' to signify 'is any of'. I found this solution by creating a rule and looking at the data in the database table 'catalogrule' if you pick apart the column 'condition_serialized' i found
Where the "()" is the operator
So my final code was:
Hope that helps someone!