Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. $ruleId = <rule_Id>;
  2. $productSku = <sku>;
  3. $shoppingCartPriceRule = Mage::getModel('salesrule/rule')->load($ruleId);
  4. $skuCondition = Mage::getModel('salesrule/rule_condition_product')
  5. ->setType('salesrule/rule_condition_product')
  6. ->setAttribute('sku')
  7. ->setOperator('==')
  8. ->setValue($productSku);
  9. try {
  10. $shoppingCartPriceRule->getConditions()->addCondition($skuCondition);
  11. $shoppingCartPriceRule->save();
  12. $shoppingCartPriceRule->applyAll();
  13. } catch (Exception $e) {
  14. echo $e->getMessage();
  15. die();//remove die when in production and set the error message in session and return
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement