Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ruleId = <rule_Id>;
- $productSku = <sku>;
- $shoppingCartPriceRule = Mage::getModel('salesrule/rule')->load($ruleId);
- $skuCondition = Mage::getModel('salesrule/rule_condition_product')
- ->setType('salesrule/rule_condition_product')
- ->setAttribute('sku')
- ->setOperator('==')
- ->setValue($productSku);
- try {
- $shoppingCartPriceRule->getConditions()->addCondition($skuCondition);
- $shoppingCartPriceRule->save();
- $shoppingCartPriceRule->applyAll();
- } catch (Exception $e) {
- echo $e->getMessage();
- die();//remove die when in production and set the error message in session and return
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement