Archive for April, 2011

Sorting categories in Magento according to the position in admin

<?php    $cats = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();    ?>    <ul>    <?php foreach($cats as $category): ?>        <li>            <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a>        </li>    <?php endforeach; ?>    </ul>

in here 3 is parent category ID

for more info visit mage-people

Searching product in different Category In Magento

Suppose You want to search a product in specific Category This code will help you. for this you just need to go  catalogSearch and paste this code in then you will show the result

* Magento
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to so we can send you a copy immediately.
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to for more information.
* @category   design_default
* @package    Mage
* @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (
* @license  Academic Free License (AFL 3.0)
* @version Edmonds Commerce Quick Search with Top Level Categories
$category = Mage::getModel('catalog/category');
$current_category_path = array();
$children_string = $category->getChildren();
$children = explode(',',$children_string);
foreach($children as $c){
$selected = (in_array($c, $current_category_path))?'SELECTED':'';
$extra_options.= '<option value="' . $c . '" ' . $selected . '>' . $category->load($c)->getName() . '</option>' . "\n";
<form id="search_mini_form" action="<?php echo $this->helper('catalogSearch')->getResultUrl() ?>" method="get">
<legend><?php echo $this->__('Search Site') ?></legend>
<input id="search" type="text" name="<?php echo $this->helper('catalogSearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogSearch')->getEscapedQueryText() ?>" />
<select name="cat" id="cat">
<option value="">All Departments</option>
<?= $extra_options ?>
<input type="submit" value="Go" style="border: 1px solid #808080;" alt="<?php echo $this->__('Search') ?>" />
<div id="search_autocomplete"></div>
<script type="text/javascript">
var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('search site...') ?>');
searchForm.initAutocomplete('<?php echo $this->helper('catalogSearch')->getSuggestUrl() ?>', 'search_autocomplete');

this above code is only for Displaying Current category and if someone want to search in specific category

then you need to change the code like

foreach($children as $c){
if(in_array($c, $exclude_array)){continue;}
$selected = (in_array($c, $current_category_path))?'SELECTED':'';
$extra_options.= '<option value="' . $c . '" ' . $selected . '>' . $category->load($c)->getName() . '</option>' . "\n";

on the otherhand if someone want to get all category and subcategory then

foreach($this->getSubCategories($c) as $sc){
foreach($this->getSubCategories($sc) as $ssc){

for more info visit mage-people

Adding attribute to the new order notification email in magento.

Today for purpose of one my freelancing project I have added attribute to new order Email . So i am going to share this.

Just you have to work on two file only 1. app->design->fronend->themname->default->template->email->order->items.phtml

in here you have add column heading

then you have to go 2. app->design->fronend->themname->default->template->email->order->items->order->default.phtml

here to add attribute you should have write code like

<?php $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('Attribute_code')); ?>
 <?php echo $product->getData('Attribute_code'); ?>


hope it will help you.

for more magento tutorial visit:

Reindexing Problem-Stock Status Index process is working now.Try again later

As my Title of post this common problem in magento.. This is caused by sever execution time or file access permission problem. Today I have solved this problem by a simple task

here I have rename the locks folder———-var/locks

then tried again reindexing problem is solved.

for more magento tutorial visit: