Magento 1.9 – Add Category Settings and Thumbnail Programmatically

categorymagento-1.9thumbnail

I'm currently using the below to add a category programatically/in the front end

 <?php
 $category = Mage::getModel('catalog/category');
 $category->setName('new_category');
 $category->setIsActive(1);   
 $category->setIsAnchor(0);
 $parentCategory = Mage::getModel('catalog/category')->load("X");
 $category->setPath($parentCategory->getPath());
 $category->save();
 ?>

There are 2 settings which i need to be able to add – the setting of use parent category settings = yes and the category thumbnail

How can this be done with the above?

Best Answer

You can add the following lines for that:

$category->setCustomUseParentSettings(true);
$category->setThumbnail([image]);

The [image] is the name of the image that is located in media/catalog/category/

Related Topic