Take the 2-minute tour ×

I have created a shopping cart price rule programmatically. The rule seems to have been created and works fine. But sometimes on opening the frontend section or page which contains this code for creating the rule, I get the error --- Invalid method Mage_SalesRule_Model_Rule::applyAll(Array ( ) )

I have used the following code for creation of the shopping cart price rule. Can someone please help me remove this error from my magento site.

Here is the code ---

$date = new DateTime();
        $couponcode = substr(md5($date->getTimestamp()),-10);
        $shoppingCartPriceRule = Mage::getModel('salesrule/rule');

        $name = "Discount Rule - 20% Off"; // name of Shopping Cart Price Rule
        $websiteId = 1;
        $customerGroupId = 1;
        $actionType = 'by_percent'; // discount by percentage(other options are: by_fixed, cart_fixed, buy_x_get_y)
        $discount = 20; // percentage discount


        $cardCondition = Mage::getModel('salesrule/rule_condition_product')
        try {  
        } catch (Exception $e) {
share|improve this question
add comment


Your Answer



Browse other questions tagged or ask your own question.