Reputation: 11
Is it possible if I could override Enterprise Banner Package? The class that I want to override is in \app\code\core\Enterprise\Banner\Block\Widget\Banner.php
Here's part of my config.xml:
<blocks>
<Mycomp_Banners>
<class>Mycomp_Banners_Block</class>
</Mycomp_Banners>
<widget>
<rewrite>
<banners>Mycomp_Banners_Block_Widget_Banners</banners>
</rewrite>
</widget>
</blocks>
My file is in: \app\code\local\Mycomp\Banners\Block\Widget\Banners.php
class Mycomp_Banners_Block_Widget_Banners extends Enterprise_Banner_Block_Widget_Banner {
// ...
}
I tried this, but it didn't work for me.
Upvotes: 0
Views: 112
Reputation: 39119
In order to rewrite a block (but could also apply to Helpers and Models, controllers having different behaviour), you have to mimic the way they are defined in their own module's config.xml
So in the config.xml
of Enterprise_Banner
, the blocks are defined this way :
<?xml version="1.0"?>
<config>
<modules>
<Enterprise_Banner>
<version>1.11.0.0</version>
</Enterprise_Banner>
</modules>
<global>
<!-- nodes we don't care about -->
<blocks>
<enterprise_banner>
<class>Enterprise_Banner_Block</class>
</enterprise_banner>
</blocks>
<!-- more nodes we don't care about -->
</global>
<!-- still more nodes we don't care about -->
</config>
So your should mimic this definition of the block but where Magento is actually defining where the class is, you actually have to define what you want to rewrite and where it is going to be.
So your config.xml
should looks like that :
<?xml version="1.0"?>
<config>
<modules>
<Mycomp_Banners>
<version>0.0.0.1</version>
</Mycomp_Banners>
</modules>
<global>
<blocks>
<enterprise_banner>
<rewrite>
<widget_banner>Mycomp_Banners_Block_Widget_Banners</widget_banner>
<rewrite>
</enterprise_banner>
</blocks>
</global>
</config>
Upvotes: 1