Last active
December 2, 2019 13:25
-
-
Save mklooss/accbc8f4637e1938e0e8b80f6dc14055 to your computer and use it in GitHub Desktop.
Magento Apply all Rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (php_sapi_name() != 'cli') | |
{ | |
die('no!'); | |
exit; | |
} | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
$dir = dirname(__FILE__); | |
chdir($dir); | |
require $dir.'/app/Mage.php'; | |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price'); | |
$process->reindexAll(); | |
echo "reindexed\n"; | |
try { | |
Mage::getModel('catalogrule/rule')->applyAll(); | |
Mage::app()->removeCache('catalog_rules_dirty'); | |
echo Mage::helper('catalogrule')->__('The rules have been applied.'); | |
} catch (Exception $e) { | |
echo Mage::helper('catalogrule')->__('Unable to apply rules.'); | |
print_r($e); | |
} | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment