Follow by Email

Sunday, April 29, 2012

Add Google plus one Button in product details page

Past the following code in your magento product details page and you will see your Google plus one Button in your product page.
<div id="google-plusone" style="float: left;position: relative;top: 23px;left: -9px;">
<script type="text/javascript" src="">
{"parsetags": "explicit"},
{"lang": "<?php echo $this->__('en-GB') ?>"}
    <g:plusone size="medium" count="true" href="<?php echo trim(Mage::registry('current_product')->getProductUrl()) ?>"></g:plusone>
<script type="text/javascript">

Wednesday, April 25, 2012

Magento onestep checkout remove shipping method step

In this blog, we will see how to remove the shipping method step from magento onepage checkout
The source code of this module has been tested in magento 1.6 version but should work fine 1.4+.
Removing the shipping method step is pretty simple, here are the steps to do it. I am going to set the ‘freeshipping’ shipping method as the default shipping method so that the checkout process goes smoothly. Also for this code to work make sure the freeshipping method is enabled from admin. Attached is the source code for this module
open app\code\core\Mage\Checkout\Block\Onepage.php
$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
$stepCodes = array('billing', 'shipping', 'payment', 'review');  

also open app\code\core\Mage\Checkout\controllers\OnepageController.php
find function saveBillingAction()
 if (!isset($result['error'])) {

                $method = 'freeshipping_freeshipping';
                $result = $this->getOnepage()->saveShippingMethod($method);
                Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()-> setShippingMethod($method)->save();

if (!isset($result['error'])) {
                    if ($this->getOnepage()->getQuote()->isVirtual()) {
also change
elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
                    $result['goto_section'] = 'shipping_method';
                    $result['update_section'] = array(
                        'name' => 'shipping-method',
                        'html' => $this->_getShippingMethodsHtml()
elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
                        $result['goto_section'] = 'payment';
                        $result['update_section'] = array(
                        'name' => 'payment-method',
                        'html' => $this->_getPaymentMethodsHtml()

find function saveShippingAction()
look on
 if (!isset($result['error'])) {
                $result['goto_section'] = 'shipping_method';
                $result['update_section'] = array(
                    'name' => 'shipping-method',
if (!isset($result['error'])) {
                    $result['goto_section'] = 'payment';
                    $result['update_section'] = array(
                        'name' => 'payment-method',

And also go to the app\code\core\Mage\Checkout\Model\Type\Onepage.php
add    if(empty($shippingMethod))
          $shippingMethod = 'freeshipping_freeshipping';
after starting of   public function saveShippingMethod($shippingMethod)    {

SQL Query to insert State/Region for India

I have made a sql file which can insert all the state of India into magento  please click here to download it.

Tuesday, April 24, 2012

Insert rupee symbol instead of Rs in magento

We have previously posted the solution for INR symbol. But that was playing with code, finally we were able to solve that problem in easy way. Here it goes:

Step 1: Goto: lib/Zend/Locale/Data/root.xml
Make changes in root.xml
find <currency type=”INR”> replace next line with this <symbol>Rs. </symbol>

Step 2: Goto:  or click
save the page as rupee.js and save it inside /js folder of the root.

Step 3: Goto: \app\design\frontend\default\your-theme\layout edit page.xml
After this <block type=”page/html_head” name=”head” as=”head”>
add <action method=”addJs”><script>rupee.js</script></action>

Step 4 : Clear cache by deleting all the files and folder inside /var/cache folder. Clear cache from back-end as well.

Sunday, April 22, 2012

Show recent view product in product view page in magento

What I have done to enable recently viewed on the product page was:
in catalog.xml inside the content block of catalog_product_view:

<block type="reports/product_viewed" name="reports.product.viewed" 
 as="recently_viewed" template="reports/product_viewed.phtml">
  <action method="setColumnCount"><columns>4</columns></action>
  <action method="setItemLimit"><type>recently_viewed</type><limit>4</limit></action>
in the template file: catalog/product/view.phtml:
<?php echo $this->getChildHtml('recently_viewed') ?>

Wednesday, April 18, 2012

Show all product in a page without pagination

If you want to display all product in a page  just open the file


Inside this file, the function that we are interested in is getLimit() beginning around line 723.

 $limit = 'all';

how do i change the price filter attributes price range with text

I am a coder but facing a unique problem. By default i get the magento price filter, with the price range but i want price filter like as given below:

under $50
$50 - $99(5)
$100 - $199(3)
$200 - $299(10)
$300 - $499(2)
$500 - $699(17)
$700 - $899(1)
$900 or above(12)

You can configure step of price ranges via admin panel. Log in into admin panel and go to System->Configuration->Catalog->Catalog->Layered Navigation. There select "Manual" in dropdown Price Navigation Step Calculation and enter prefered value into next input field.

Sunday, April 15, 2012

How to change pagination design in product listing page in magento

I have worked in the template\catalog\product\list\toolbar.phtml where you can change the total toolbar design. But there have a function
 <?php echo $this->getPagerHtml() ?>
it's for the pagination. if you want to change pagination html then go to the template\page\html\pager.phtml
and you can change it from here.

Saturday, April 14, 2012

jQuery conflict with prototype in Magento

Hi all,
I have got a good solution to prevent conflict jquery with prototype in magento
I have added the following code in page.xml after 
<action method="addJs"><script>mage/cookies.js</script></action>
this line and it's working fine.
<block type="core/text" name="google.cdn.jquery">
action method="setText">
text><![CDATA[<script type="text/javascript" src=""></script>
<script type="text/javascript">jQuery.noConflict();</script>]]>

Changing number of products / columns per row in Grid View

Hi All,
I am using Magento 1.6.2 and i wanted to bring 3 product in each row in product listing page grid view.
So i do the following.
Go to this file template/catalog/product/list.phtml

$_helper $this->helper(\'catalog/output\');
$this->setData(\'column_count\',3);            <------ add this line
And it\’s really working.

Thursday, April 12, 2012

Magento - remove from validation text

Some of us may not want the validation advice that is given, and prefer to just use CSS styling.
Here is how to remove it:
in /js/prototype/validation.js

test : function(nameelmuseTitle{
var Validation.get(name);
prop '__advice'+name.camelize();
if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
//if(!elm[prop]) {
                var advice = Validation.getAdvice(name, elm);
                if (advice == null) {
                    advice = this.createAdvice(name, elm, useTitle);
                this.showAdvice(elm, advice, name);
elm[prop] 1;
else {
//var advice = Validation.getAdvice(name, elm);
            //this.hideAdvice(elm, advice);
elm[prop] '';

Tuesday, April 10, 2012

Banner slider extension issue

After installing your banner slider extension  if you find that it show some error in your admin. Then you can solve it with the following process.
Please go to the file "app/design/frontend/base/default/layout/bannerslider.xml" and remove the comment of the code.
And go to ..\app\code\community\Magestore\Bannerslider\Block\Adminhtml\Bannerslider\Edit\Tab\Form.php
in line 32 you can see the code: $model->setStoreId(Mage::app()->getStore(true)->getId());
please remove or change it to comment.
I hope it will solve your problem.

Monday, April 9, 2012

How to show new products for a specific categories

I’m guessing the modification needs to be done in new.phml (app/design/frontend/default/default/template
/catalog/product/). Basically I’m thinking of duplicating new.phtml and calling it new_category1.phtml,
new_category2.phtml, etc and get “new” products from category id 1, category id 2 respectively.


46// category id$category Mage::getModel('catalog/category')->load($cat_id); $todayDate  Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);      
$products $category->getProductCollection()->addCategoryFilter($category)->addAttributeToFilter('news_from_date', array('date' => true'to' => $todayDate))->addAttributeToFilter('news_to_date', array('or'=> array(
=> array('date' => true'from' => $todayDate),
=> array('is' => new Zend_Db_Expr('null')))
'left')->            addAttributeToSelect('*');

if ((
$_products $this->getProductCollection()) && $_products->getSize()): ?><div class="hp-report">
div class="head-alt">
h2 class="title"><?php echo $this->__('New Products Category 46'?></h2>
table cellspacing="0" class="generic-product-grid" id="new-products-list-table">
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
if ($i>=4): continue; endif; ?>
a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170) ?>" width="170" height="170" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
p><class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
<?php echo $this->getReviewsSummaryHtml($_product'short'?>
echo $this->getPriceHtml($_producttrue'-new'?>
if($_product->isSaleable()): ?>
<a href="<?php echo $this->getAddToCartUrl($_product) ?>"><img src="<?php echo $this->getSkinUrl('images/btn_add_to_cart.gif') ?>" alt="<?php echo $this->__('Add to Cart') ?>" title="<?php echo $this->__('Add to Cart') ?>" /></a>
<?php else: ?>
<div class="out-of-stock"><?php echo $this->__('Out of stock'?></div>
<?php endif; ?>
<div class="clear"></div>
ul class="add-to">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist'?></a></li>
<?php endif; ?>
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare'?></a></li>
<?php endif; ?>
<?php $i++; endforeach; ?>
for($i;$i%4!=0;$i++): ?>
<?php endfor ?>
script type="text/javascript">decorateTable('new-products-list-table');</script></div><?php endif; ?>

How to get CMS Page ID in Magento

Here is the code to get CMS Page ID in Magento
function getCurrentCmsPage() {
$pageId = Mage::getBlockSingleton('cms/page')->getPage()->getIdentifier();
return $pageId;

Friday, April 6, 2012

How to Change the Footer Links in Magento

Magento’s XML layout and template framework and the flexibility that it brings is awesome, but unfortunately it does come with its own learning curve. This can take some time getting used to if you’re unfamiliar with Zend Framework and can turn the most trivial of tasks like modifying the links in the footer of a page somewhat more involved.
So let’s have a look at template/page/html/footer.phtml
You will be able to see that this gives us the footer div and loads most of the content through:

<?php echo $this->getChildHtml() ?>
You can then create your list of links as appropriate in the 
Magento backend, the default footer block contains:
<a href="{{store direct_url="about-magento-demo-store"}}">
 About Us</a></li>
    <li class="last">
<a href="{{store direct_url="customer-service"}}"> 
        Customer Service</a></li>
There are a couple of reasons why it’s great to edit the footer links in this way. One is that the store owner can easily change the footer at a later date without needing a professional to hand. Another, is the flexibility to add different content if you so wish, it doesn’t have to be a simple list of links.
Another block with a “footer” reference can be found in page.xml:

<block type="page/html_footer" name="footer" as="footer" 
    <block type="page/template_links" name="footer_links" 
 as="footer_links" template="page/template/links.phtml"/>
In the page/template/links.phtml file we can see 
a function call to $this->getLinks();