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="https://apis.google.com/js/plusone.js">
{"parsetags": "explicit"},
{"lang": "<?php echo $this->__('en-GB') ?>"}
</script>
    <g:plusone size="medium" count="true" href="<?php echo trim(Mage::registry('current_product')->getProductUrl()) ?>"></g:plusone>
</div>
<script type="text/javascript">
gapi.plusone.go("google-plusone");
</script>

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
change
$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()
 add
 if (!isset($result['error'])) {

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

before
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()
                    );
into
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',
 change
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: http://cdn.webrupee.com/js  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>
</block>
 
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

app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

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

change
 $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.