1

the extension in question has the following structure:

  • app
    • code
      • local
        • MST
          • Menupro
            • Block
              • Base.php

Base.php has:

class MST_Menupro_Block_Base extends Mage_Core_Block_Template {

my custom module

  • app
    • code
      • local
        • Myname
          • BlockOverride
            • Block
              • Base.php

my Base.php has:

class Myname_BlockOverride_Block_Base extends Mage_Core_Block_Template {

In my module activation file Myname_BlockOverride.xml I have:

<?xml version="1.0"?>
    <config>
        <modules>
           <Myname_BlockOverride>
               <codePool>local</codePool>
                    <active>true</active>
                    <depends>
                        <MST_Menupro/>
                    </depends>
           </Myname_BlockOverride>
       </modules>
    </config>

module is verified as enabled and working because I am overriding some mage core classes also.

in:

  • app
    • code
      • local
        • Myname
          • BlockOverride
            • etc
              • config.xml

i have:

<?xml version="1.0"?>
    <config>
        <modules>
            <Myname_BlockOverride>
                <version>0.1.0</version>
            </Myname_BlockOverride>
        </modules>

        <global>
            <blocks>
                <myname_blockoverride>
                    <class>Myname_BlockOverride_Block</class>
                </myname_blockoverride>
                <menupro>
                    <rewrite>
                        <base>Myname_BlockOverride_Block_Base</base>
                    </rewrite>
                </menupro>
            </blocks>
        </global>
    </config>

This question has been asked multiple times, like here https://stackoverflow.com/questions/24145976/how-to-rewrite-extend-a-magento-class-in-an-existing-third-party-extension and http://code.tutsplus.com/tutorials/understand-overriding-in-magento-blocks--cms-23325 and Rewrite a local Extension Module doesn't work

which i've dutifully followed through but seem to up against a brick wall. my overriding class file is never loaded (error_log at top of file does not fire).

any help greatly appreciated.

edit: i checked through the 3rd party extension for their block definition in config.xml and see

<blocks>
    <menupro>
        <class>MST_Menupro_Block</class>
    </menupro>
</blocks>

not sure if i'm missing a clue there somehow

1

Two mistakes I can find.

  1. You placed your module files in wrong place
  2. You rewrote the custom module's block class in wrong way.

Place files in correct location

Activation File : app/etc/modules/Myname_BlockOverride.xml

<?xml version="1.0"?>
<config>
    <modules>
       <Myname_BlockOverride>
           <codePool>local</codePool>
                <active>true</active>
                <depends>
                    <MST_Menupro/>
                </depends>
       </Myname_BlockOverride>
   </modules>
</config>

config file : app/code/local/Myname/BlockOverride/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Myname_BlockOverride>
            <version>0.1.0</version>
        </Myname_BlockOverride>
    </modules>

    <global>
        <blocks>
            <myname_blockoverride>
                <class>Myname_BlockOverride_Block</class>
            </myname_blockoverride>
            <menupro>
                <rewrite>
                    <base>Myname_BlockOverride_Block_Base</base>
                </rewrite>
            </menupro>
        </blocks>
    </global>
</config>

Rewrite Class : app/code/local/Myname/BlockOverride/Block/Base.php

<?php
class Myname_BlockOverride_Block_Base extends MST_Menupro_Block_Base
{

}

and that's it. Last and but not least, you need to clear your caches. Ready, Set, Goooooooo....

  • Hi Rajeev, thank you for the reply, but unfortunately I made a typo when writing my question. Both my activation and config file have been in the correct path from the beginning (question updated accordingly). All caches are currently disabled (but yes I flushed them all just to make sure). – baku Aug 6 '15 at 14:31
  • your activation file name is wrong. check "activation file" part in my answer – Rajeev K Tomy Aug 6 '15 at 14:39
  • damn, should proofread my question better :( but I assure you my activation file is correct. the module is registered to magento and activated, I am using it to perform other successful overrides. Question updated accordingly. Thank you again for taking the time to reply! – baku Aug 6 '15 at 14:55
0

Your extension BlockOverride block.php should be

class Myname_BlockOverride_Block_Base extends MST_Menupro_Block_Base {

  • thanks for the suggestion, but i'm afraid that doesn't work in this case. Or it's not the entire problem. The error_log (at the top of the custom Base.php file) is never called, so that file is not parsed. – baku Aug 6 '15 at 6:05
  • edit: Sorry i just realized you specified block.php (assuming Block.php, maybe that doesn't matter). I created Block.php and added the class definition, that file also is never executed. – baku Aug 6 '15 at 6:11
0

Although this is not a direct answer to this question which i never solved satisfactorily, I did work around this by moving the 3rd party extension to community pool and override it via file inheritance.

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.