Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active December 2, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklooss/accbc8f4637e1938e0e8b80f6dc14055 to your computer and use it in GitHub Desktop.
Save mklooss/accbc8f4637e1938e0e8b80f6dc14055 to your computer and use it in GitHub Desktop.
Magento Apply all Rules
<?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