1

I have a module which contains a model rewrite in it's config.xml file.

Site also have other 3rd party modules, due to which I suspect module conflict occurs and thus result page seems to be broken.

When I remove rewrite in my config.xml file, page reappears correctly.

Below shows rewrite code section in my config.xml file.

<rewrite>
     <catalog_product_attribute_edit_tab_main>MyNameSpace_MyModule_Block_Product_Attribute_Main</catalog_product_attribute_edit_tab_main>
</rewrite>

I disabled it like below :

<rewrite>
     <!--<catalog_product_attribute_edit_tab_main>MyNameSpace_MyModule_Block_Product_Attribute_Main</catalog_product_attribute_edit_tab_main>-->
</rewrite>

I think the reason is conflict between modules.

Questions

  • How can I understand that it's rewrite-conflict or it something else?

  • If it is a conflict (2 or more extensions are overwriting the same functionality/Model ), then how to identify the which Module/Class are in conflict with this one?

OBSERVATION

IT looks like create form didn't build correctly. enter image description here

  • Please also add the error that you are getting. You are writing about an error and to understand anything of the problem you have, you could at least add the error. – 7ochem Nov 2 '16 at 12:58
  • Is there any difference in block rewrite syntax, between 1.9. and 1.8 versions of Magento? – Gevorg M Nov 22 '16 at 17:18
1

To identify the other module rewriting the class, I recommend doing a search in your project files for the class identifier node, <catalog_product_attribute_edit_tab>. If that brings up multiple results, you will know that you have a rewrite conflict.

To solve rewrite conflicts, there are two options: make your rewrite class extend the other rewrite class, and make your module depend on the other module in your /etc/modules/module.xml file. Then, include your rewrite: that should fix the issue.

The other option is to copy the logic from both classes into a single class, and take advantage of Magento's code pools and autoloading to move it into a folder in the local code pool; however, this is not recommended.

Rewriting classes allows for a great deal of flexibility, but also opens the door to issues like this one. I suggest that you use events wherever possible, and avoid rewrites if you can. For a block like this, you can listen to the core_block_abstract_to_html_before event, or any of the other events in the block method. You can then manipulate the block's data, or even inject methods into it to call on it (https://swiftotter.com/blog/using-closure-bindto-as-an-alternative-to-rewriting-classes).

  • Thanks for your response. First, I've searched for node in community and local folder (where should be modules, I guess can miss searching in "core" folder ) result is nothing, that's why I'm not sure it's rewrite conflict. Please update if you know other way for conflict identification. The second thing: I had something like conflict with events, too. Please check magento.stackexchange.com/questions/143139/… I'll be thankful if you will able to help with that one, too. – Gevorg M Nov 2 '16 at 13:44
0

How can I understand that it's rewrite-conflict or it something else ?

It looks like there is no conflict at all. Also your question appears quiet misleading too.

You are saying, you did a model rewrite in one of your custom module. But the code that you have shown indicates that, it is a block rewrite. It is evident in your custom block name MyNameSpace_MyModule_Block_Product_Attribute_Main

You are also saying, when you add that rewrite code in your module, page looks broken. When you remove that rewrite, then page reappears. This means, problem is with your module. Most probably it will be a problem in your block class. ie MyNameSpace_MyModule_Block_Product_Attribute_Main.

So in order to help you out, we want to see your module's files especially that particular block class.

If it is a conflict, then how to identify the which Module/Class are in conflict with this one?

Well, there are lot of ways to do this. Common and easy solution is already recommended by @tjon in his answer.

You can use n98-magerun to find module conflict. This is a powerful console tool which will help you a lot in your future development.

Also you can refer this thread which covers almost all possible ways to find out rewrites in a Magento instance.

Hope that will help you out.

  • Thanks for your clarifications and response. I'm sorry but I'll prefer don't write code details, first because it's not under my ownership and second I don't think it could be helpful. – Gevorg M Nov 2 '16 at 15:49
  • Okay no issues. – Rajeev K Tomy Nov 2 '16 at 15:50
  • I was going write this in one message with my previous comment just mistakely press Enter. All I can tell is the following: Our class extends from Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Main and all it does override function _prepareForm(), function begins with parent::_prepareForm(); after this our custom code. For the testing purposes I've added "return $this;" row after the calling parent's method. This mean our code will not make any effect, but anyway we still gets that issue – Gevorg M Nov 2 '16 at 16:00
  • All I can say is, it is difficult to point out the mistake without viewing your codes. I answer your two questions as much as detailed. This is what we can do with the given content of your question. – Rajeev K Tomy Nov 2 '16 at 16:04

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.