0

I am using Magento 1.13 Enterprise. I have two custom modules which rewrite the core class app/code/core/Mage/Catalog/Block/Product/List.php :

app
---code
------local
---------Mynamespace
------------BigFinder
------------Robots

In app/code/local/Mynamespace/BigFinder/etc/config.xml I have :

<config>
    <global>
        <blocks>
            <catalog>
                <rewrite> 
                    <category_view>Mynamespace_BigFinder_Block_Catalog_Category_View</category_view>
                </rewrite>
            </catalog>
        </blocks>
    </global> </config>

And in app/code/local/Mynamespace/Robots/etc/config.xml I have :

<config>
    <global>
        <blocks>
            <catalog>
                <rewrite> 
                    <category_view>Mynamespace_Robots_Block_Catalog_Category_View</category_view>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

I would like to keep my two modules and rewrite the app/code/core/Mage/Catalog/Block/Product/List.php class by Mynamespace_BigFinder_Block_Catalog_Category_View, and not by Mynamespace_Robots_Block_Catalog_Category_View.

How can priorize my rewrites ?

Thanks a lot

0

There is no way to priorize a rewrite. The two config.xml files are merged in an order dependent by the filesystem: so you could have one rewrite in an environment and a different one in another, while keeping the code still.

You should avoid using rewrites as much as possible. If you have to, use just one. You can still override multiple times having the rewrite extends all the other files in a row.

For example: Mynamespace_BigFinder_Block_Catalog_Category_View could extend Mynamespace_Robots_Block_Catalog_Category_View, and Mynamespace_Robots_Block_Catalog_Category_View could extend Mage_Catalog_Block_Catalog_Category_View In this example you still need just one in config: the one for Mynamespace_BigFinder_Block_Catalog_Category_View.

If you do so for a controller (in controllers folder), you could have to require_once the parent before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.