2
votes

I have created one Catalog Price Rule Programmatically it works fine.

so my issue is, I need to do login with admin and need click button of "Apply Rules" other wise discount is not apply in magento store, so i need "Apply Rules" programmatically and i have no idea about it how to do.

enter image description here

Any help or suggestion will be appreciated.

1

1 Answers

0
votes

You can Apply Rules using the below code with Newly created Catalogrule ID

$rule = Mage::getModel('catalogrule/rule')->load($ruleId);
Mage::getResourceModel('catalogrule/rule')->updateRuleProductData($rule);
Mage::getResourceModel('catalogrule/rule')->applyAllRulesForDateRange();
Mage::getModel('catalogrule/rule')->_invalidateCache();
$indexProcess = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_price');
if ($indexProcess) {
    $indexProcess->reindexAll();
}