Monthly Archives: August 2012

Magento Accordion Menu for Layered Navigation

One of the Most powerful feature in Magento is layer Navgation for filtering the Result .Based on the Attribute filter get work but some time attributes are more so layer navigation become lengthy and we need to scroll down more which is bad impression on site so we can add accordan menu for that which will allow   accordon for each atribute

1) First download the updated version of JS form here.if it is there in your site no need

Put your jQuery file in the “js” folder located in the root (or Magento) directory. You can create a new folder called “jquery”. The Scriptaculous code is also located in “js” folder.

For noConflict part,

add if required


2)Second add the Js in page.xml

<action method="addJs"><script>jquery/jquery-version.min.js</script></action>

3)Third Modify view.phtml located at app/design/frontend/yourthem/template/catalog/layer

<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<?php echo $_filter->getHtml() ?>
<?php endif; ?>
<?php endforeach; ?>

All we need is call the ID, “narrow-by-list” from jQuery, and add an anchor element in “dt” like so:

<dt><a href="/"><?php echo $_filter->getName() ?></a></dt>
<script type="text/javascript">
/* <![CDATA[ */
jQuery("dl#narrow-by-list> dd:not(:first)").hide();
jQuery("dl#narrow-by-list> dt a").click(function(){
jQuery("dl#narrow-by-list> dd:visible").slideUp("fast");
return false;
/* ]]> */

as “narrow-by-list” css is there so no need to add as per your theme need to chnaged if required

and that’s refresh the cache it will work

Magento Out of Stocks and Back Order

By Default Magento does not allow to add “Out of stock” product n Cart .So we will be using the concept of Backorders which is there in magento by default but it is Disbale in admin.This concept will allow to add the “Out of stock” product in Cart

For enable Backorders

To enable backorders, go to:Admin Panel -> System -> Configuration -> Catalog Tab -> Inventory -> Product Stock Options -> Backorders = Allow Qty Below 0 and Notify CustomerEdit Product to Qty = 0 and Stock Availability = In Stock

When you add the particular product to cart, the product is added to cart and you will see the following message:* This product is not available in the requested quantity. 1 of the items will be backordered.You can order the product even if it is out of stock. The product will be delivered to you when it is in stock.


Magento AOE Scheduler

Magento AOE Scheduler will help to Manage your scheduler/cron tasks including a timeline view also help  to check the cron running on the site
Great Extension nearly work in all magento version.Hope this will help while running cron

Magento Add Qty Items on Grid or List View

To show the quantity of items left in stock  just add the following code in list.phtmlwe have added int as by default magento will show in this manner 10.00

<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>

Hope this will help you

Magento Remove index.php from url

Magento by default added the index,php in url .So,As per the SEO page will not get indexed properly SO here we have try to Remove index.php in url from both End Access Magento URL without index.php
For example: to Just follow steps
1) Login to admin section by using the URL
2) then go to “System >> Configuration >>Web >> Search Engines Optimization” Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure” Use secure URL Frontend: YES
4)Then create the .htaccess file under your the magento installed folder.

If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]


and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /shop/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /shop/index.php [L]

Thst's it just refresh the cache .Hope this will help!

Magento Adding New Field in the product Custom Options

Magento had limited field in custom Options so if we required the New or To add the New field in the magento product Custom options just follow the steps

Note : Here DEAL is the new field you have to replace by your field name 

1) Open the file  adminhtml/default/default/catalog/product/edit/options/option.phtml

Just after this

  'jsQuoteEscape(Mage::helper('catalog')->__('Is Required')) ?>'+

Add the new field

 'jsQuoteEscape(Mage::helper('catalog')->__('Is Deal')) ?>'+

2) In the same file just after this

  'getRequireSelectHtml() ?>'+

Add the new field

  'getDealSelectHtml() ?>'+

3) In the same file check for the

  if (data.is_require) {
            $A($('getFieldId() ?>_''_is_require').options).each(function(option){
                if (option.value==data.is_require) option.selected = true;

And below that add

if (data.is_deal) {
            $A($('getFieldId() ?>_''_is_deal').options).each(function(option){
                if (option.value==data.is_deal) option.selected = true;

4) Open the file  app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php
and add in local folder app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php

search function getOptionValues()

 $value['is_require'] = $option->getIsRequire();

Add the follwoing code

 $value['is_deal'] = $option->getIsDeal();

and in the same file check this Fucntion  getRequireSelectHtml()

add new function

public function getDealSelectHtml()
        $select = $this->getLayout()->createBlock('adminhtml/html_select')
                'id' => $this->getFieldId().'_{{id}}_is_deal',
                'class' => 'select'

        return $select->getHtml();

6) and add the new filed in the db in the table catalog_product_option or you can upgrade the script for adding the new field for the product custom options

 That’s it just clear the cache and and refresh your Browser

Magento Remove "+" from product custom options

AS By default Magento add “+” sign in custom options .In order to Remove we need to edit file which is located in


just copy the file and add in local which will become


now serach $sign = ‘+’;

just replace $sign = ‘ ‘;

Note:just remove the (+) symbol.That’s it refresh the page

Magento Add Custom Grid in Admin

Add custom column to admin grid for your module. we will see how to add a banner image column to our grid.
For example our module name will be Magento_Banner.

Adding Banner Image to Grid

Open your Grid.php file and add the code in the _prepareColumns() function of your module

$this->addColumn('image', array(
          'header'    => Mage::helper('banner')->__('Banner Image'),
          'align'     =>'left',
          'index'     => 'bannerimage',
          'renderer'  => 'banner/adminhtml_banner_renderer_image'

Here we have specified an renderer block type as ‘banner/adminhtml_banner_renderer_bannerimage’.
we need to create this Block. The code inside this block is as follows:

class Magento_Banner_Block_Adminhtml_Banner_Renderer_BannerImage extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
    public function render(Varien_Object $row)
        $html = '        $html .= 'id="' . $this->getColumn()->getId() . '" ';
        $html .= 'src="' . $row->getData($this->getColumn()->getIndex()) . '"';
        $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss() . '"/>';
        return $html;

This is all that is needed, if you open your grid you show see an image there. You have to adjust path/src of the image to make it show correctly. Here the $this->getColumn() function is the important function, you can access the array you pass in the Grid.php file in the getColumn() function. For example, if we write in Grid.php file

 $this->addColumn('image', array(
          'header'    => Mage::helper('banner')->__('Banner Image'),
          'align'     =>'left',
          'index'     => 'image',
          'renderer'  => 'banner/adminhtml_banner_renderer_bannerimage',
          'attr1'     => 'value1'

then in our renderer we can use


You can also access the data of the current row using the $row variable passed in the render function, for example the below code will show the path of image as well.

class Magento_Banner_Block_Adminhtml_Banner_Renderer_BannerImage extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{ 
public function render(Varien_Object $row)
        $html = '        $html .= 'id="' . $this->getColumn()->getId() . '" ';
        $html .= 'src="' . $row->getData($this->getColumn()->getIndex()) . '"';
        $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss() . '"/>';
        $html .= '


        return $html;

Install ionCube loader on your WAMP or XAMPP server.

Some time while running magento on WAMP or  XAMPP give error about the  ionCube easy solution for this just follow this step

In order to run eSoftScript Pro on your server you must have installed ionCube on your
server.  Herea are 2 quick ways to install the loader:

1. Install on WAMP server:
– Download the Free IonCube Loaders for your PC, by choosing your OS platform from HERE
– Extract that zip pack to your wamp folder directly. So, that it becomes like this,
– Edit php.ini file: C:\wamp\bin\apache\Apache2.2.11\bin\php.ini and add this line at the bottom
of the last line: zend_extension_ts = “C:\wamp\ioncube\ioncube_loader_win_5.2.dll”
– Restart WAMP.

2. Install on XAMPP server:
– Download the Free IonCube Loaders for your PC, by choosing your OS platform from HERE
– Extract that zip pack to your xampp folder directly. So, that it becomes like this,
– Install ionCube loader to XAMPP at: C:\xampp\htdocs\\ioncube
– Open php.ini with your text editor. The file is located at C:\xampp\apache\bin\ or
C:\xampp\php\. Add the following line before any other zend_extension statements.
zend_extension_ts = “C:\xampp\htdocs\\ioncube\ioncube_loader_win_5.2.dll”
– Restart XAMPP.

Just Restart the server hope this will help you