How to add a category to Magento via Setup script?

前端 未结 5 1161
长发绾君心
长发绾君心 2021-01-13 05:42

I actually can add a category via setup script, the thing is for some reason some of the fields doesn\'t get set properly. Here\'s is my code

$this->start         


        
5条回答
  •  抹茶落季
    2021-01-13 06:23

    I have created multiple categories via installer script.

    startSetup();
    
    Mage::register('isSecureArea', 1);
    
    $category = Mage::getModel('catalog/category');
    $category->setPath('1/2/4') // set parent to be root category
    ->setName('CAT NAME') //Category Name
    ->setIsActive(1) // Category Status
    ->setIncludeInMenu(1) // Show in Menu
    ->setIsAnchor(1) // used for Layered navigation
    ->setDisplayMode('PAGE') //  Product Only
    ->setPageLayout('one_column') // Page layout
    ->save();
    
    $installer->endSetup();
    

提交回复
热议问题