I want to create a category from front end , i have a code
<?php
$category = Mage::getModel('catalog/category');
$category->setName('mobiles')
setIsActive(1) //activate your category
setIsAnchor(0)
setCustomDesignApply(1)
setDisplayMode( 'PRODUCTS' )
setAttributeSetId($category->getDefaultAttributeSetId());
$parentCategory = Mage::getModel('catalog/category')->load("2");
$category->setPath($parentCategory->getPath());
$category->save();
unset($category);
?>
this code is working fine in single store, but in multi-store the category is not in active mode. please guys help me to solve this problem.
For multi-store, you have to set the store_id
$category->setStoreId(0);
// 0 = default/all store view.
If you want to save data for a specific store view, replace 0 by your store_id
Mage::app()->getStore()->getId()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.