1

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?

4

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/

  • Is there a magento page/wiki that states what each category's attribute/setting 'setXXXX' is? So in admin the Use Parent Category Settings is setCustomUseParentSettings(true) As i need to also set the displayMode to staticblockonly and then state which block to use for CMS block. Rather than ask another question is this list somewhere? – odd_duck Aug 29 '14 at 14:36
  • You can use every database field and available attributes as a setXXXX command. You just have to camelcase the fieldname (remove the underscore and set the first letter after the _ as uppercase). So display_mode becomes setDisplayMode() and image bcomes setImage(). – Vladimir Kerkhoff Aug 29 '14 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.