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

Multiple override of a class? 
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Hello,

I am writing several modules and in some of them I need to override the same classes.
I guess a simple solution would be to create a single independent module for the overrides but the modules would depend on each other, and of course that’s not the purpose of the module architecture…

So, do anybody knows a “module compliant” solution please ? ^^

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
MA_19
Member
 
Total Posts:  41
Joined:  2009-01-21
 

The Event model is designed to handle situations like this by defining an observer for each module, you can have them all reacting to the same events in magento without creating dependencies.

Take a look at this page on the wiki:

http://www.magentocommerce.com/wiki/customizing_magento_using_event-observer_method

Matt

 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Thank you Matt, I’ll study this smile

Edith says me that maybe events are not the thing for me, it said “Use events if you are fine with existing logic provided by Magento and need to add over the core logic.”
But in two modules I override Mage_Catalog_Model_Product, and in both I specialize a method (load in one and save in another) and create new methods… Err… Well, I will study this ^^’

 
Magento Community Magento Community
Magento Community
Magento Community
 
lvanstaden
Jr. Member
 
Total Posts:  10
Joined:  2009-01-25
 
benippon-francois - 13 March 2009 12:43 AM

Thank you Matt, I’ll study this smile

Edith says me that maybe events are not the thing for me, it said “Use events if you are fine with existing logic provided by Magento and need to add over the core logic.”
But in two modules I override Mage_Catalog_Model_Product, and in both I specialize a method (load in one and save in another) and create new methods… Err… Well, I will study this ^^’

Hi, I ran into exactly the same problem, whilst extending the product grid.

Although Matt’s suggestion is the best solution (rather use the events), this solution is not possible everywhere, as the events are not available everywhere.

You may be interested in my post, and responses, and possible solution to this issue.

http://www.magentocommerce.com/boards/viewthread/20877/P15/#t114540

Unfortunately I cannot see any way out of this problem, without some module dependancies being created. I would appreciate your input and/or any other solution you may come up with regarding this issue.

-Lucas

 
Magento Community Magento Community
Magento Community
Magento Community
 
benippon-francois
Member
 
Total Posts:  51
Joined:  2009-01-15
 

Thank you Lucas,

The fact is now the simplest solution to me is to create a separated module which only goal is to override for others modules, with others modules dependent on this one.
This is not a perfect solution, but since all the modules I write are to work together for now it’s a safe solution. If I find a better way I write here.

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