Tuesday, October 11, 2011

Magento: Find subcategories for a root category

We can use the below code to find all child categories for a particular category
in Magento
 
<?php
//get category model
    $category_model = Mage::getModel('catalog/category'); 
 //$categoryid for which we have to find the child categories
    $_category = $category_model->load($categoryid); 
 //array that contains all child categories id
        $all_child_categories = $category_model->getResource()->getAllChildren($_category);
?>

Magento:Add/Edit HTML of success/failure message

Edit success/failure messages html in magento
Go to file
\app\code\core\Mage\Core\Block\Messages.php
find
public function getGroupedHtml()
    {
......................
Edit HTML here
......................
     }

Magento admin images donot show or upload

This is a common error in magento.
Product images in admin donot show or upload.
Fix:
In file
js/mage/adminhtml/product.js

replace
this.images.toJSON();
with:
Object.toJSON(this.images);