I was trying to override the above class (Magento\GroupedProduct\Model\Product\Type\Grouped)

Below is my app/code/Best/CustomGrouped/etc/adminhtml/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\GroupedProduct\Model\Product\Type\Grouped" type="Best\CustomGrouped\Model\Product\Type\Grouped"/>

And below is the model class app/code/Best/CustomGrouped/Model/Product/Type/Grouped.php

namespace Best\CustomGrouped\Model\Product\Type;

class Grouped extends \Magento\GroupedProduct\Model\Product\Type\Grouped
    public function getAssociatedProducts($product)
        // Do something

I debug through the code, but it still goes to the core class rather using my overridden one. I do not want to use a plugin. I just want to know what am I missing here when overriding the class Magento\GroupedProduct\Model\Product\Type\Grouped

Any suggestions would be appreciated.

P.S. : I already checked with clearing the cache, generation etc. in var folder. But it didn't worked. I'm using Magento EE 2.1

  • 1
    Is your module sequenced after Magento's GroupedProduct module? You can quickly check the order by looking at app/etc/config.xml to confirm your module is listed after the core one. If not Magento itself has a preference on this file in app/code/Magento/GroupedProduct/etc/adminhtml/di.xml – Kristof at Fooman Aug 25 '16 at 3:02
  • I checked the app/etc/config.xml. and it's not after the Magento's GroupedProduct module. I changed the my module's namespace to start with 'N', so it'll be load after the Magento's GroupedProduct module. Then it works. I think this is the issue. Thanks for pointing out. How can I load My module after the Magento's GroupedProduct without changing the namespace? – Sukeshini Aug 25 '16 at 3:14
  • @Kristof at Fooman : Many thanks for pointing the issue. It worked :) – Sukeshini Aug 25 '16 at 3:30

Modifying the file app/code/Best/CustomGrouped/etc/module.xml to load my custom module after the core module worked for me.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Best_customGrouped" setup_version="0.0.1" active="true">
            <module name="Magento_GroupedProduct"/>

The issue was sine the namespace of My custom module started with letter 'B' it was listed before the Magento's GroupedProduct module in app/etc/config.xml. So I force my module to load after the Magento's one by using above code.

A very big thank for @Kristof at Fooman for pointing me the issue.

| improve this answer | |
  • i have done same but not working "500" error display on screen. – Sarfaraj Sipai Oct 13 '17 at 10:39

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.