How to set “Is Anchor” to all categories in magento by custom php script?

Home / Magento / How to set “Is Anchor” to all categories in magento by custom php script?

Create .php page with below code to set “Is Anchor” to all categories in magento by custom php script.

error_reporting(E_ALL);
ini_set('display_errors', '1');
// Load Up Magento Core
define('MAGENTO', realpath('/'));
require_once(MAGENTO . 'app/Mage.php');
$app = Mage::app();
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('is_anchor', 0)
->addAttributeToFilter('entity_id', array("gt" => 1))
->setOrder('entity_id');
foreach($categories as $category) {
echo $category->getId() . "t" . $category->getName() . "n";
$category->setIsAnchor(1);
$category->save();
}

Looking for theme / plugin support?

Looking for theme / plugin customization?