如何使用自定义模块/默认类别添加类别

时间:2014-07-02 10:33:37

标签: magento

我想在自定义模块安装时在默认类别中添加新类别。 任何人都可以帮助我这样做

这是我的mysql设置脚本..

$this->startSetup();


$parentId = Mage::app()->getStore()->getRootCategoryId();

$parentCategory = Mage::getModel('catalog/category')->load($parentId);
Mage::register('isSecureArea', 1);
// Force the store to be admin
Mage::app()->setUpdateMode(false);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$category = Mage::getModel('catalog/category');
$category->setPath($parentCategory->getPath()) // set parent to be root category
    ->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)
    ->setName('Subscription Plans')
    ->setUrlKey('subscription-plans')
    ->setIsActive(1)
    ->setDisplayMode('PRODUCTS')
    ->setIsAnchor(0)
    ->setIncludeInMenu(0)
    ->save();
$this->installEntities();

$this->endSetup();

0 个答案:

没有答案