overriding class first to second working but overr

2019-07-25 18:11发布

问题:

I am overriding AW_Blog_Block_Cat and it is working good.

<global>
    <blocks>
       <blog>
            <rewrite>
                <cat>King_Ring_Block_Updates_Cat</cat>
            </rewrite>
        </blog>
    </blocks>
</global>

Now I want to override the above class King_Ring_Block_Updates_Cat in other module and it's not overriding. Still showing the above class(King_Ring_Block_Updates_Cat), not showing the below one(Cat_Rat_Block_Updates_Bat). Can anyone please tell me why is that?

config is:

<global>
    <blocks>
       <ring>
            <rewrite>
                <updates_cat>Cat_Rat_Block_Updates_Bat</updates_cat>
            </rewrite>
        </ring>
    </blocks>
</global>

Class definition

Cat_Rat_Block_Updates_Bat extends King_Ring_Block_Updates_Cat

回答1:

Check your XML for second rewrite.

  • You are starting the module name as <ring> and ending it with </blog> instead of ring itself.
  • Another issue, you are starting the tag <updates_cat>, and ending it with </cat>.

Do you want developers here to parse your XML and check your typos? Check your code thoroughly before posting things here.

Change the required things as I said, clear cache, and it should work.



回答2:

I found it in the end. Nothing was wrong with the configuration or paths. It was In my Layout.xml, as I was kept on calling the wrong block type to override. I was kept on calling the same parent block type which had already been overridden by second block, that is why it never rendered.

Now in order to override the second block I specify that block type and obviously it works!!

<block type="rat/updates_bat" name="N" template="whatever temp"/>. 


标签: magento