Change shipping address dropdown to div in Magento

If you want to change shipping address dropdown to div structure.
After a long research i found that this select box is comming form core php file and it's hard to make any change in core file. So we have to change in shipping.phtml file as following. Step 1 : Open shipping.phtml you can find it :- /app/design/frontend/package/yourtheme/template/checkout/onepage/shipping.phtml Please find this code around line no 30.
  • <?php echo $this->getAddressesHtmlSelect('shipping') ?>
  • Set Payment Method "PayPal" on Particular State Only in Magento

    If you want to disable a specfic payment method for specfic State then follow these steps. 1.Make a new file in app/etc/module/Arunendra_Disablepayment.xml copy and Paste below code in that file
    
    <?xml version="1.0"?>
    
    
         
            true
            local
         
    
    
    
    2.Now make module folder inside app/code/local/Arunendra/Disablepayment 3.Make new folder and file inside app/code/local/Arunendra/Disablepayment/etc/config.xml and copy and paste below code in that file.

    How to disable specfic payment method for specfic products in Magento

    How to disable specfic payment method for specfic products If you want to disable a specfic payment method for specfic products then follow these steps. 1.Make a new file in app/etc/module/Arunendra_Disablepayment.xml copy and Paste below code in that file
    <?xml version="1.0"?>
    
    
    
         
            true
            local
    
        
    
    
    
    2.Now make module folder inside app/code/local/Arunendra/Disablepayment 3.Make new folder and file inside app/code/local/Arunendra/Disablepayment/etc/config.xml and copy and paste below code in that file.

    Add Product Images In Magento Transactional Emails

    In order to add the order Image to the transaction email templates (order), you need to play with the following two files:
    1.) Edit the file: app/design/frontend/base/default/template/email/order/items.phtml Locate this line (Around Line 32) :
    <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"> <?php echo $this->__('Sku') &#63></th>
    

    Disable admin notification popup in Magento

    Every time you log in to the Magento Admin Panel, you see an admin notification popop message telling you there's a new Magento version. As a developer, it's best to stay informed about new releases by reading blogs, tweets and lots of other news channels - besides this, upgrades should never be taken lightly. It's possible to remove this notification popup message.


    To remove this notification popup message.
    • Login to your Magento Admin Panel
    • Go to System >> Configuration >> Advanced
    • Disable the Mage_AdminNotification module


    How to create custom page layout in magento

    To create a new custom column layout, you need to place a new file in the Magento theme. With the Magento default theme, you could use the folder app/design/frontend/default/default/template/page, but of course - when building your own site - it is recommended to have your own theme-directory.

    In the tutorial, the file 1column.phtml is copied to the file 1columnfp.phtml (where "fp" stands for the front page). To make this new page reckognizable you wll need to add a new XML-definition. In the tutorial the following code is added to the file app/code/core/Mage/Page/etc/config.xml. copy this module in local exp app/code/local/Mage/Page/etc/config.xml
    
        
        
        page_one_column_fp
    
    
    However, with a Magento upgrade this change could be gone. The same XML could also be added to your app/etc/local.xml file instead:

    Customizing Magento email templates

    Emails (or often referred to as transactional emails) are - just like the entire Magento theme - based on files in the filesystem: If you open up the folder app/locale/en_US/template/email you will numerous files. Don't edit them directly, because any Magento upgrade will override your changes. Instead, the purpose of these files is to override them. You can override these email templates either using the Magento Admin Panel, or by copying them to your Magento theme. The first approach allows for easy editing using the Magento Admin Panel, but this interface lacks nice editing features like syntax highlighting or code completion. Ofcourse, you can copy the textarea contents ofcourse to your local editor modify things there and copy the code back into the textarea once you're done.

    Change order status in WooCommerce for specific payment method

    Copy this code in your theme's function.php file
    <?php
    /* Reset status of new orders from "pending" to "completed" */
    add_action( 'woocommerce_thankyou', 'changeOrderStatus' );
    function changeOrderStatus($order_id) {
        global $woocommerce;
         if (!$order_id )
            return;
     $billing_paymethod = get_post_meta($order_id,'_payment_method',true);
      $order = new WC_Order( $order_id );
      /* put here your specific payment method */
     if($billing_paymethod == 'paypal')
     {
       /* put here your specific  order status */
           $order->update_status( 'completed' );
        }
        else
        {
         /* put here your specfic default order status for all payment method */
      $order->update_status( 'processing' );   
        }
    }
    ?>
    

    Get Upsell products list using Product Id in Magento

    Using Product ID you can get list of Upsell product. Copy following code and place it in you custom file.
    <?php
       // Get product object.
       $object = Mage::getModel('catalog/product');
       
       /* Get product detail using product id   : $_product->getId() */
       $product = $object->load($_product->getId()); 
      
       // Fetch list of upsell product using query.
       $upsell_product = $product->getUpSellProductCollection()->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter(); 
    
       //check if record is empty or not
       $count = count($upsell_product); 
       if(empty($count)) : 
           //if empty
           echo "Record not found";
    
       else:
    
         //if result is not empty then get  upsell product detail using foreach loop
          foreach($upsell_product as $_upsell):
             
             //get detail of single upsell prdocut using upsell product id
             $upsp = $object->load($_upsell->getId());
    
             echo "Product Name : ". $upsp->getName();
             echo "Poduct url : ". $upsp->getProductUrl();
             echo "Product regular price : ". $upsp->getPrice();
             
           endforeach;
       
       endif;
    
    ?>
    

    Display all categories and sub categories on left sidebar in Magento

    You can display list of all categories and subcategories in left sidebar including product view page using the following code in Magento. You can display subcategories upto second level using this code. You can create a new file for this code and you can add it in your theme’s catalog XML file like this:

    
    

    How to make accordion tabs in magento For layered navigation

    In this blog I’m going to explain you how to create accordion tabs in magento for layered navigation as displayed below for attributes. Just navigate to your layered navigation file as shown:
    app/design/frontend/default/{your folder}/template/catalog/layer/view.phtml
    


    Then open that that file & paste the following jquery script at the end of the page:
    
    
    #narrow-by-list is the id used in that file(
    )
    . If you used different id’s, replace this with your id and save the file. Refresh the cache and reload the browser to see the results. Use no-conflict method in magento. It is a good practice to avoid javascript conflicts in the page.

    How to create Edit, Delete Cookies in magento

    Understanding Magento Cookies and how to manipulate.
    <?php    
    /**      
    * set cookie      
    * name and value are mandatory; other parameters are optional and can be set as null      
    * $period = cookie expire date in seconds      
    */    
    Mage::getModel('core/cookie')--->set($name, $value, $period, $path, $domain, $secure, $httponly);
    /**
    * get cookie with a specific name
    * $name = name of the cookie
    */
    Mage::getModel('core/cookie')->get($name);
    /**
    * get all cookies as an array
    */
    Mage::getModel('core/cookie')->get();
    /**
    * delete/remove cookie
    * $name is mandatory; other parameters are optional and can be set to null
    */
    Mage::getModel('core/cookie')->delete($name, $path, $domain, $secure, $httponly);
    ?>
    

    How to optimize Magento site

    If you enable Gzip compression by changing .htaccess, you can speed up Magento significantly. Assuming that you have Gzip enabled on your server. Uncomment the part of the code in your htaccess file that matches the code below. You uncomment by removing the #.
    
    
    ############################################
    ## enable apache served files compression
    ## http://developer.yahoo.com/performance/rules.html#gzip
    
         # Insert filter on all content
         SetOutputFilter DEFLATE
         # Insert filter on selected content types only
         AddOutputFilterByType DEFLATE text/html text/plain text/xml
    text/css text/javascript
    
         # Netscape 4.x has some problems...
         BrowserMatch ^Mozilla/4 gzip-only-text/html
    
         # Netscape 4.06-4.08 have some more problems
         BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
         # MSIE masquerades as Netscape, but it is fine
         BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    
         # Don't compress images
         SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzipdont-vary
    
         # Make sure proxies don't deliver the wrong content
         Header append Vary User-Agent env=!dont-vary
    
    
    

    Copy HTTP Request by Expires Headers
    When a customer visits your website for the first time, the site will load lots of HTTP requests. How to minimize these requests? We will use Expires Headers function to save unnecessary HTTP requests for the next visits. Simply add this code to your .htaccess file:
    
    
    ############################################
    ## Add default Expires header
    ##http://developer.yahoo.com/performance/rules.html#expires
    
         ExpiresActive On
         ExpiresDefault "access plus 1 year"
    
    
    
    Reduce the file size of images to be uploaded

    As far as you know, Magento is used for e-commerce website; therefore, all images on the site particular product images are essential. We need eye-catching images, of course, those are sometimes too big to fully load and time-costing. As a result, it is crucial for a store owner to find out a sensible solution to reduce the file size of images to be uploaded but still restrain the quality of the images. It will be critically helpful to reduce site’s capacity when you run it. We suggest a few feasible tips and directions for this issue. Trust us, it is completely simple and all you need is uploading your images to a system and it will return you re sized ones while the quality is kept. Now you can post similar-quality-shrunk images instead of old stone-sized ones. Below are our tips:
    https://tinypng.com/ (PNG images accepted only) http://www.smushit.com/ysmush.it/ (all images accepted)

    Turn off unnecessary modules
    There are thousands of Modules available in Magento to be used or shelved. For the medium-sized e-commerce website, it is not always necessary to use all these extensions and modules. You need to list all Modules that your system won’t use and turn them off. It helps to improve the site loading time when unused extensions are disabled. Simply go to Admin > System >Configuration> Tab Advanced>Advanced>Disable Modules Output, it shows all available Modules and their status. Select unnecessary modules and disable them.

    Utilize Magento Compilation
    Magento compilation will collect all functions in one place, which will decrease steadily site loading time up to 25-50% depending on each system. It is a brilliant feature that helps improve the speed of your site. Go to Admin > System > Tools >Compilation, click Run Compilation Process. When the process is done, you can Disable it.

    Enable Fat Catalog in Admin panel
    This function accelerates products queries and returns time-saving results. Go to Admin >Sytem>Configuration > Catalog: In Frontend section, change 2 values of “Use Flat Catalog Category” and “Use Flat Catalog Product” to Yes:

    And remember to Clear cache before it takes effect.
    Enable Merge CSS and JS
    Magento utilizes a lot of JS and CSS files. Loading each of those files is time-costing, therefore, to minimize the loading time, you can enable Merge function to compress CSS and JS files in one file and it will load at speed of light. Go to Admin >System >Configuration >Developer: Select “JavaScript Settings” and change the value of “Merge JavaScript Files” to Yes. In “CSS Settings”, select Yes for “Merge CSS Files”.

    Clean Database Log
    A Magento website generates a huge amount of logs, so we need to clear these logs regularly to save space of your database and improve the loading time. Go to Admin > System > Configuration >System: In Log cleaning, select Yes for “Enable Log Cleaning” and enter the time frame for logs saving, eg. 14 days.

    When you have applied those above listed solutions, be notified that you need to refresh and enable cache in the Magento back end so that they take effect.
    I hope those methods do help you improve the current site loading time. Besides, you can look for some other utilities to enhance your site optimization, for instance:
    http://www.magentocommerce.com/magento-connect/gtspeed.html http://www.magentocommerce.com/magento-connect/turpentine-varnish-cache.html http://www.magentocommerce.com/magento-connect/full-page-cache-pro.html
    Applying one of these open utilities will partly or mostly accelerate the loading speed of your site, however, be careful as they can conflict with other ready-installed files and make errors in performing your website. Therefore, saving a backup version of your website is always a “lifebuoy” for you before you implement any of those optimizations.

    How to check If is home Page in Magento

    Check If Home Page Magento If you need to determine if the the current page is the homepage in Magento, the below code works.
    <?php
     if(Mage::getSingleton('cms/page')->getIdentifier() == 'home'  && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') {
    echo 'i am home page';
    }
    ?>