1

I want to create a custom product type similar to grouped product and I got help from here so I created a new module

enter image description here

I already read this question however could not solve my problem.: here is what I did in config.xml:

    <catalog>
        <product>
            <type>
                <excellence translate="label" module="excellence_test">
                    <label>Custom Product</label>
                   <model>excellence_test/basket_product</model>
                    <price_model>catalog/product_type_grouped_price</price_model>
                    <composite>1</composite>
                    <allow_product_types>
                        <simple/>
                        <grouped/>
                    </allow_product_types>
                    <index_priority>50</index_priority>
                    <price_indexer>catalog/product_indexer_price_grouped</price_indexer>
                </excellence>
            </type>
        </product>
    </catalog>

here is my Model:

class Excellence_Test_Model_Basket_Product extends Mage_Catalog_Model_Product_Type_Abstract
{
    public function isComposite($product = null)
    {
        return true;
    }
   public function setTypeId($typeId)
    {

        return Mage_Catalog_Model_Product_Type::TYPE_GROUPED;
    }
}

regarding to the link I should determine to add associated products tab, how ever it does not read the xml file at all!, I don't even have any erros:

I have layout update in my config.xml:

 <adminhtml>
    <layout>
        <updates>
            <excellence_test>
                <file>excellence/catalog.xml</file>
            </excellence_test>
        </updates>
    </layout>
 </adminhtml>

This still is not showing me the associated product tab. here is the path file to my layout file:

app\design\adminhtml\default\default\layout\excellence\catalog.xml

inside I wrote this:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
<adminhtml_catalog_product_excellence>
    <reference name="product_tabs">
        <action method="addTab">
            <name>super</name>
            <block>adminhtml/catalog_product_edit_tab_super_group</block>
        </action>
    </reference>
</adminhtml_catalog_product_excellence>
</layout>

even if I write it does not throw any errors so I guess my file even is not being read.

here is config.xml per Raphael request:

<?xml version="1.0"?>
<config>
    <modules>
        <Excellence_Test>
            <version>1.0.0</version>
        </Excellence_Test>
    </modules>
    <global>
        <catalog>
            <product>
                <type>
                    <excellence translate="label" module="excellence_test">
                        <label>Custom Product</label>
                       <model>excellence_test/basket_product</model>
                        <price_model>catalog/product_type_grouped_price</price_model>
                        <composite>1</composite>
                        <allow_product_types>
                            <simple/>
                            <grouped/>
                        </allow_product_types>
                        <index_priority>50</index_priority>
                        <price_indexer>catalog/product_indexer_price_grouped</price_indexer>
                    </excellence>
                </type>
            </product>
        </catalog>

        <resources>
            <excellence_test_setup>
                <setup>
                    <module>Excellence_Test</module>
                    <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
                </setup>
            </excellence_test_setup>
        </resources>
        <blocks>
            <excellence_test>
                <class>Excellence_Test_Block</class>
            </excellence_test>
        </blocks>
        <helpers>
            <excellence_test>
                <class>Excellence_Test_Helper</class>
            </excellence_test>
        </helpers>
        <models>
            <excellence_test>
                <class>Excellence_Test_Model</class>
                <resourceModel>excellence_test_resource</resourceModel>
            </excellence_test>
            <excellence_test_resource>
                <class>Excellence_Test_Model_Resource</class>
            </excellence_test_resource>
        </models>

    </global>

     <adminhtml>
        <layout>
            <updates>
                <excellence_test>
                    <file>excellence/catalog.xml</file>
                </excellence_test>
            </updates>
        </layout>
     </adminhtml>

</config>

please help me.code is available

  • Could you post your full config.xml file please – Raphael at Digital Pianism Jun 5 '16 at 9:11
  • 1
    done, I included the full config.xml – Nickool Jun 5 '16 at 19:37
2

I fixed it, The problem was, I should also define the phtml file, I have done the following in catalog.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
<adminhtml_catalog_product_excellence>
    <reference name="product_tabs">
        <action method="addTab">
            <name>super</name>
            <block>adminhtml/catalog_product_edit_tab_super_group</block>
        </action>
    </reference>
</adminhtml_catalog_product_excellence>
    <PRODUCT_TYPE_excellence>
        <reference name="product.composite.fieldset">
            <block type="adminhtml/catalog_product_composite_fieldset_grouped" name="product.composite.fieldset.grouped" before="product.composite.fieldset.options" template="catalog/product/composite/fieldset/grouped.phtml"/>
            <remove name="product.composite.fieldset.qty"/>
        </reference>
    </PRODUCT_TYPE_excellence>
</layout>

Then I saw that function getAssociatedProducts cannot be called so I extended different class for my model as the following:

class Excellence_Test_Model_Basket_Product extends Mage_Catalog_Model_Product_Type_Grouped 
{

}

so instead of extending the Abstract, I extend the grouped, and now I can customize this type of product based on my requirements.I also pushed the code to github so it is available for whoever wanted to do the same.

1

Well, I think you've been mislead by the adminhtml XML layout.

Your layout handle adminhtml_catalog_product_excellence means that the code will only be called when accessing /admin/catalog/product/excellence route. However, in your case you want to add that tab when you're accessing a product edit page.

I first wanted to suggest you to use this code instead:

<adminhtml_catalog_product_edit>
    <reference name="product_tabs">
        <action method="addTab">
            <name>super</name>
            <block>adminhtml/catalog_product_edit_tab_super_group</block>
        </action>
    </reference>
</adminhtml_catalog_product_edit>

But I'm afraid it will add the tab to every edit page even if your new product type is not used.

I suggest you try this instead:

<PRODUCT_TYPE_excellence>
    <reference name="product_tabs">
        <action method="addTab">
            <name>super</name>
            <block>adminhtml/catalog_product_edit_tab_super_group</block>
        </action>
    </reference>
</PRODUCT_TYPE_excellence>
  • Thank you for the answer, I tried your code and still I see no results, as I mentioned something is wrong in my layout since I think excellence/catalog.xml is not even read, I can write whatever and no errors will show up. – Nickool Jun 7 '16 at 17:41
  • 1
    you gave me the idea of product_type_excellence and I went through core and saw what I can do about it so +1, thank you! – Nickool Jun 7 '16 at 20:43
  • @Nickool glad you fixed it – Raphael at Digital Pianism Jun 7 '16 at 20:53

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.