Revision: 39058
Updated Code
at January 12, 2011 22:59 by TheJasonParker
Updated Code
<?php define('MAGENTO', realpath(dirname(__FILE__))); require_once MAGENTO . '/app/Mage.php'; umask(0); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $file = fopen(MAGENTO . "/var/import/categoriesToEnable.csv", 'r'); while (($line = fgetcsv($file)) !== FALSE) { $cats = explode(",",$line[1]); foreach ($cats as $cat) { $newcats[$cat] = true; } } // Activate the categories it is in foreach ($newcats as $cat=>$value) { if ($value && !empty($cat)) { try { $_category = Mage::getModel('catalog/category')->load($cat); if ($_category->getIsActive() === "0" || !$_category->getIsActive()) { $_category->setIsActive(1); $_category->save(); echo "<br />Enabled ".$_category->getName(); unset($_category); } } catch(Exception $e) { echo " Caught Cat Insert exception: ", $e->getMessage(); } } } ?>
Revision: 39057
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 12, 2011 22:58 by TheJasonParker
Initial Code
<? define('MAGENTO', realpath(dirname(__FILE__))); require_once MAGENTO . '/app/Mage.php'; umask(0); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $file = fopen(MAGENTO . "/var/import/categoriesToEnable.csv", 'r'); while (($line = fgetcsv($file)) !== FALSE) { $cats = explode(",",$line[1]); foreach ($cats as $cat) { $newcats[$cat] = true; } } // Activate the categories it is in foreach ($newcats as $cat=>$value) { if ($value && !empty($cat)) { try { $_category = Mage::getModel('catalog/category')->load($cat); if ($_category->getIsActive() === "0" || !$_category->getIsActive()) { $_category->setIsActive(1); $_category->save(); echo "<br />Enabled ".$_category->getName(); unset($_category); } } catch(Exception $e) { echo " Caught Cat Insert exception: ", $e->getMessage(); } } } ?>
Initial URL
http://www.sonassi.com/knowledge-base/magento-knowledge-base/quick-script-to-mass-enable-categories-in-magento/
Initial Description
Create a CSV with a maximum of 1 column, with just the Magento category ID.
Initial Title
Mass enable categories
Initial Tags
magento
Initial Language
PHP