Catalog Price Rules “Apply Rules” programmatically

偶尔善良 提交于 2019-12-11 02:55:57

问题


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.

Any help or suggestion will be appreciated.


回答1:


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();
}


来源:https://stackoverflow.com/questions/42573145/catalog-price-rules-apply-rules-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!