How to list subcategories of a particular (specific) category

Posted on September 9th, 2014 | Posted by admin

To get a subcategory list of a specific category you need to make the following php call:

  $category = Mage::getModel('catalog/category')->getCategories(7);
  foreach($category as $_category){
  $currentCat = Mage::getModel('catalog/category')->load($_category->getId());
  <li><a href="<?php echo $currentCat->getUrl()?>"><?php echo $currentCat->getName();?></a></li>
<?php } ?>

Where 7 is my category id ($category = Mage::getModel(‘catalog/category’)->getCategories(7);)

The category id you get it from the Manage categories and after you click on a category you can see the ID next to the category name.


Posted on April 5th, 2013 | Posted by admin

when we in the list.phtml file sometime we need to display the list of child categories of current category with there URL for navigations. this can easily implemnt with magento framework objects. below code example can use on list.phtml easily to retrive child categories of current category.this shows as a list, you can apply css to format the list. happy coading… :)

Magento:Alphabetical category sorting

Posted on March 29th, 2013 | Posted by admin

If you are dealing with magento category i am very sure that you’ll face this problem .Magento category fetching is not an issue its a child play but sorting thse categories is little tricky , so here the is SQL part by which you can sort the categories in alphabetical order

SET @i=0;
SET @j=0;
SELECT e.entity_id AS 'entity_id',

Create a Custom Attribute for a Category in Magento

Posted on March 17th, 2013 | Posted by admin

To Create a Custom Attribute for a Category in Magento we need to do:

Depending on which version of magento you’re running will depend on which tables in your database you’ll need to update.

  • 1. eav_attribute
  • 2. eav_entity_attribute
  • 3. catalog_eav_attribute (only required for Magento version 1.4 onwards)

So start by adding a row to the eav_attribute table in your database

INSERT INTO EAV_ATTRIBUTE (attribute_id, entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note,

Magento: Automate Related Products with Current Category

Posted on March 7th, 2013 | Posted by admin

Automate Related Products with Current Category in magento

Personally, I’d prefer to show other products from the same category rather than have no related products. This seems to be the case with most of my clients too. I wrote this piece of code to check for manually set related products, and if there are none go and get a random collection of products from the current category.

“What if the user has gone directly to the product which belongs to more than one category?” – easy! If there is no current category set then get an array of categories the product belongs to and choose the first one.

Put this PHP at the top of related.php. This will check for the number of related products and fetch some if need be.

Page 1 of 3123»