0

I need to install two modules that extend the same magento classes / phtml files. Is it possible to install them both without generating conflicts, or do I need to merge them in a single module?

First module :

   class Aijko_CustomOptionDescription_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option 
extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
    {
        public function __construct()
        {
            parent::__construct();
            $this->setTemplate('aijko_customoptiondescription/catalog/product/edit/options/option.phtml');
        }

Second one :

<?php
class Mine_Custoptiontypev5_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option
        extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option
    {
        /**
         * Class constructor
         */
        public function __construct()
        {
            parent::__construct();
            $this->setTemplate('custoptiontypev5/catalog/product/edit/options/option.phtml');
        }

2 Answers 2

2

Unfortunately magento does not work with 2 extensions that extend the same class.
Only the last one is taken into consideration.
In general... You need to make one extension extend the other.
Take one, let's say Mine_Custoptiontypev5 and make it extend Aijko_CustomOptionDescription.
For this you have to modify Mine_Custoptiontypev5.xml and add this inside the <Mine_Custoptiontypev5> tag.

<depends>
    <Aijko_CustomOptionDescription />
</depends>

This will ensure that Mine_Custoptiontypev5 is loaded after Aijko_CustomOptionDescription.
Then you have to modify Mine_Custoptiontypev5_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option and make it extend Aijko_CustomOptionDescription_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option

If the blocks don't rewrite the same methods you should be safe. But this is not the case for you.
I see that both of them rewrite the __construct method and set a different template.
If you follow the example above only custoptiontypev5/catalog/product/edit/options/option.phtml will be used. So you need to modify that template also to include the elements that both extension brind to the table.

0
1

In general you could just let one extend the other

Aijko_CustomOptionDescription_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option extends Mine_Custoptiontypev5_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option

Mine_Custoptiontypev5_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option

In your special case, as both modules call $this->setTemplate(), this solution wouldn't work. Depending on what happens in the template file it could be possible to just use 1 template file and put the code of the other in there (not just copy and paste, you really need to find out what the code in the template file does). Still, it might be possible that the template files call $this->methodXyz(), so you also need to make the method available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.