Sunday, May 5, 2013

Magento Module - Remove specific field from Catalog Filter

One of the common modification that most of client required was remove some fields from Magento catalog filter. Standard way for impalement above requirement Create new module and rewrite Catalog Layer View block. Hope following module will help you

app\code\local\kbtdeveloper\PriceFilterRemove\etc\config.xml


<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <layer_view>kbtdeveloper_PriceFilterRemove_Block_View</layer_view>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>


\app\code\local\kbtdeveloper\PriceFilterRemove\Block\View.php



<?php

class kbtdeveloper_PriceFilterRemove_Block_View extends Mage_Catalog_Block_Layer_View {

    public function getFilters() {
        $filters = array();
        if ($categoryFilter = $this->_getCategoryFilter()) {
            $filters[] = $categoryFilter;
        }

        $filterableAttributes = $this->_getFilterableAttributes();
        foreach ($filterableAttributes as $attribute) {
        /**
        *Remove Price on Refine by block , store wise
        */
            if (Mage::app()->getStore()->getCode() == 'default') {
                if ($attribute->getAttributeCode() == 'price') {
                    continue;
                }
            }
            $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
        }

        return $filters;
    }

}

Magento - Display Specific Massage when free shipping available

One of the easiest way for display specific message , when free shipping available is create static block and display it.

Create new static block
CMS -> Static Block -> Add new.

then edit relevant template file "\app\design\frontend\PACKAGE-NAME\THEAME-NAME\template\checkout\onepage\shipping_method\available.phtml"

on top of that file update as follow


    <?php
// Remove any other shipping methods if free shipping is available
    $isFreeShippingAllow = false;
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
    $_shippingRateGroups = array('freeshipping' => $_shippingRateGroups['freeshipping']);
    $isFreeShippingAllow = true;
}
?>

Finally Call predefined static block when free shipping available



<?php
    if($isFreeShippingAllow){
      echo $this->getLayout()->createBlock('cms/block')->setBlockId('Solar_Free_Shipping_Msg')->toHtml();
   }
    ?>


;) one of the simple trick  :)