Search code examples
phpmagentomoduleurl-rewriting

Rewrite Magento Core Block


I have made a Module to rewrite Mage_Core_Catalog_Block_Product_View_Type_Configurable, where I want to change the getJSConfig method.

class DennisKirkebak_ConfigurableStock_Block_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable

This is my Configurable.php class, which I have put in DennisKirkebak/Catalog/Block/Product/View/Type/ :

My config.xml file looks like this:

<?xml version="1.0"?>
<config>
<modules>
    <denniskirkebak_catalog>
        <version>1.0.1</version>
    </denniskirkebak_catalog>
</modules>
<global>
    <blocks>
        <catalog>
            <rewrite>
                <product_view_type_configurable>
                    DennisKirkebak_Catalog_Block_Product_View_Type_Configurable
                </product_view_type_configurable>
            </rewrite>
        </catalog>
    </blocks>
</global>
</config>

I have made my Module active in the app/code/etc/modules/ where I have a file called DennisKirkebak_All.xml and I can see my module in the backend of Magento.


Solution

  • Try doing a var_dump() on this in some random template you know will get outputted:

    Mage::getConfig()->getNode('global/blocks/catalog/rewrite/product_view_type_configurable');
    

    I'm not completely sure about that last part, if you're supposed to keep is as underscored or possibly separate it with slashes - but you get the point. It will show you any active overrides at runtime, and let you know if there's some existing module that is already overriding the same block.