2

In an extension I have a rewrite for Mage_Sales_Block_Order_Info.

<config>
  <global>
    <blocks>
      <sales>
        <rewrite>
          <order_info>Company_Module_Block_Sales_Order_Info</order_info>
        </rewrite>
      </sales>
    </blocks>
  </global>
</config>

This works as expected, however in the interest of extensibility for module users, I've tried this instead to no avail

<config>
  <global>
    <blocks>
      <company_module>
        <class>Company_Module_Block</class>
      </company_module>
      <sales>
        <rewrite>
          <order_info>company_module/order_info</order_info>
        </rewrite>
      </sales>
    </blocks>
  </global>
</config>

In this case Magento is throwing an Exception

exception 'Mage_Core_Exception' with message 'Invalid block type: company_module/order_info'

My question is twofold

  1. Am I simply declaring this rewrite incorrectly when trying to use the class alias notation?
  2. Is using the class alias notation for a rewrite actually pointless here? My thought is users of the module might use the same override notation I have, then extend my module's Company_Module_Block_Sales_Order_Info class instead of Mage_Block_Sales_Order_Info since Magento is looking for the sales/order_info alias in the first place.
4

Yes it's incorrect and pointless. A rewrite assigns your class to a class alias. While in theory this could be transitive, it would not provide any additional value. If another module wants to rewrite your class it actually has to rewrite the original class (alias) and depend on your module to take precedence.

  • Perfect that's what I thought! Just want to double check to ensure I'm getting my head around the rewrite and class alias concepts. – quickshiftin Dec 19 '15 at 18:42

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.