Created
March 12, 2017 16:52
-
-
Save rintoug/bf0ba6f740501418ac6ac668b7b16f07 to your computer and use it in GitHub Desktop.
Magento create category programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createCategory(){ | |
$parentId = 1;// Any of your parent category | |
$category = Mage::getModel('catalog/category'); | |
$category->setName('My First Category'); | |
$category->setUrlKey('My-First-Category'); | |
$category->setIsActive(1); // to make active | |
$category->setDisplayMode('PRODUCTS'); | |
$category->setIsAnchor(1); // This is for active anchor | |
$category->setStoreId(Mage::app()->getStore()->getId()); | |
$parentCategory = Mage::getModel('catalog/category')->load($parentId); | |
$category->setPath($parentCategory->getPath()); | |
$category->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment