Question

I want to override the Catalog module. So I created my first custom module,

I initiated it in app/etc/modules/MyCompany_Catalog.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_Catalog>
            <active>true</active>
            <codePool>local</codePool>
        </MyCompany_Catalog>
    </modules>
</config>

Then In app/code/local/MyCompany/Catalog I created Block,Controllers,etc folder.

In etc/config.xml as I want to override Configurable.php:

<?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_Catalog>
            <version>0.1.0</version>
        </MyCompany_Catalog>
    </modules>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product_view_type_configurable>MyCompany_Catalog_Block_Product_View_Type_Configurable</product_view_type_configurable>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

In Controllers/IndexController.php :

<?php

class MyCompany_Catalog_IndexController extends Mage_Core_Controller_Front_Action
{

}
?>

And Finally In Block\Product\View\Type\Configurable.php :

<?php
class Shore_Catalog_Block_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
{
    protected function _prepareOldPrice($price, $isPercent = false)
    {
        $price = 0;  // Ramya
        if ($isPercent && !empty($price)) {
            //$price = $this->getProduct()->getPrice() * $price / 100;  
        }

        return $this->_registerJsPrice($this->_convertPrice($price, true));
    }
}
?>

But I didn't find the change applied. I found it to work when I changed it in base as a try. But as it not a good practice to edit I created a custom module. But it is not working here. Kindly correct me If I was wrong in my above steps.

Was it helpful?

Solution

You can try with config,xml file as below, Replace tag with catalog,

In your module you need catalog module override so you have to used catalog tag before rewrite tag. you have to define your core module name before rewrite tag. if you want override customer module file that time you need define customer tag.

 <?xml version="1.0"?>

<config>
    <modules>
        <MyCompany_Catalog>
            <version>0.1.0</version>
        </MyCompany_Catalog>
    </modules>   
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product_view_type_configurable>MyCompany_Catalog_Block_Product_View_Type_Configurable</product_view_type_configurable>
                </rewrite>
            </catalog>
        </blocks>
    </global>

</config>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top