Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How do I override classes in Mage/core ? 
 
Sintax
Member
 
Total Posts:  58
Joined:  2008-02-18
Hungary
 

Hi,

I want to override a function in app/code/core/Mage/catalog/Block/Product/View.php how would I do it the Magento way?

I need to override the function getAdditionalData(). Would I place that in the app/code/local/Mage/catalog/Block/Product/View.php? Can someone clarify this? Would I extend the new class from Mage_Catalog_Block_Product_View ?

Please help.

Thanks,

::Sintax

 
Magento Community Magento Community
Magento Community
Magento Community
 
finch8243
Sr. Member
 
Total Posts:  79
Joined:  2007-08-31
 

Would love to know this as well—seems like we’d need to rewrite some of the Mag classes and I don’t want to do that!

Cheers,

D

 
Magento Community Magento Community
Magento Community
Magento Community
 
CreedFeed
Member
 
Total Posts:  74
Joined:  2007-08-31
Milwaukee, WI
 

Has anyone figured this out? I would like to change the function getCountryHtmlSelect in the file app/code/core/Mage/Directory/Block/Data.php

If you just copy the current core file into the local app/code directory and make the appropriate changes to that function it won’t work. I’m getting a blank white screen. I assume this is because the system is attempting to declare two classes of the same name?? (not sure exactly why). If I rename the class to My_Mage_Directory_Block_Data and extend the Mage_Directory_Block_Data, I don’t get how to tell the system to use that class over the default Mage_Directory_Block_Data class?

Can someone please help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
yshahin
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2008-05-14
 

try adding this to your moduleName/etc/config.xml

<global>
  <
blocks>
    <
directory>
      <
rewrite>
        <
data>CompanyName_ModuleName_Block_FileName</data>
      </
rewrite>
    </
directory>
  </
blocks>
</global>

Not sure if it will work but its a start

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top