Wednesday, 16 November 2011

Jquery history plugin in magento

Main aspect of this is , at the time of using ajax powered search some one has search some thing and they have refreshed the page then they need to make the search another one time but using this plugin you can achieve the same result after the user have refreshed their page. Although it will work in the startergy for browser back and front button

Add history plugin js in your layout.xml as below [You can download the jquery plugin here :]

<reference name="head">
      <action method="addJs"><script>javascript/jquery.history.js</script></action>

And then add the hash (#store | #product) to your href for example you have store and product search in your application the it will goes like below.

href="#store" onclick="jQuery.history.load('store');" [to search stores]

href="#product" onclick="jQuery.history.load('product');" [to search products]

You need to add the below script in your basic template if your using for 1column page then you need to add the below snippet inside the head tag.

<script type="text/javascript">
        var flag = false;
                    flag =true;
                    SwapBwnStoreProducts(url == "" ? "" : url);
                    SwapBwnStoreProducts(url == "" ? "product" : url);

use the below function for your ajax call you can write this function in a separate file and then you need to include the same in the layout xml of your module.

function SwapBwnStoreProducts(swap){  
     ajax call goes here

Sunday, 13 November 2011

Magento Block Over ride

Here i am going to over ride catalog layer view  [Mage_Catalog_Block_Layer_View]
Config.xml file need to same as that of below.
<?xml version="1.0"?>

Then you need to create a class file [Class Modulename_Catalog_Block_Layer_View]  with the function you need to over ride .
No need to change the function name because the system and the config will automatically override the previous one.

Using the above same way you can rewrite models also.