For update all categories with attribute is_anchor to 1

<?php

require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

ini_set('display_errors', 1);
ini_set('max_execution_time', 600);

$categories = Mage::getModel('catalog/category')->getCollection();

foreach ($categories as $cat){

   $_cat = Mage::getModel('catalog/category')->load($cat->getId());

   if ($_cat->getData('is_anchor') == 0){
      $_cat->setData('is_anchor',1);
      $_cat->save();
   }

   echo $_cat->getName().' '.$_cat->getData('is_anchor').'<br/>';
}

One thought on “Magento update all categories with attribute is_anchor to 1”

  1. I do agree with all of the concepts you have offered on your post.
    They’re very convincing and can definitely work. Nonetheless,
    the posts are very short for beginners. Could you please prolong them a bit from subsequent time?
    Thank you for the post.

Leave a Reply

Your email address will not be published. Required fields are marked *