I'm trying to use a plugin from the answer on this question

Add additional select attributes to grouped product's child collection

I would go back and ask the person who answered but I don't have a high enough reputation score yet to add comments.

I don't use composer, so have gone the old route of app/code.

My plugin looks like this

namespace mynamespace\Plugingrouped\Plugin;
use \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection;
use \Magento\GroupedProduct\Model\Product\Type\Grouped as TypeGrouped;
class Grouped
public function afterGetAssociatedProductCollection(TypeGrouped $subject, Collection $result)
return $result;

I've added the plugin code as Grouped.php into a folder app/code/mynamespace/Plugingrouped/Plugin

My di.xml file in my module looks like this

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\GroupedProduct\Model\Product\Type">
    <plugin name="Grouped" type="Mynamespace\Plugingrouped\Plugin\Grouped" />

And then I tried calling a custom attribute in


<strong class="product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
                Weight : <?php echo $_item->getmy_attribute_height() ?>

To add custom attributes into the grouped product grid.

However, they don't render, I don't get an error, but I can't figure out how to make sure the plugin is working.

  • Use Namespace instead of namespace in your plugin file. Jul 4, 2018 at 11:11
  • Thanks for the reply. Assuming you meant Namespace mynamespace\Plugingrouped\Plugin; Unfortunately that didn't work either. It renders everything around the custom attribute but nothing from the attribute itself
    – wjp_bill
    Jul 4, 2018 at 11:31
  • @SukumarGorai Though it is technically possible to use sentence case for some PHP operators, it is best practice to lowercase them, therefore the OP was correct to use the lowercase version of the operator namespace. Jul 4, 2018 at 12:31
  • @ProcessEight - Thanks for the update. I've put it back to lowercase but no luck on it working.
    – wjp_bill
    Jul 4, 2018 at 14:20

2 Answers 2


After many many days of banging my head on a wall, I've finally solved it.

I had two modules set up originally:

  1. Mynamespace\Grouped\
  2. Mynamespace\Plugingrouped

Nothing I did would make the plugin show up until I combined the two into module.

I now have the Model override and plugin in one module and it's working.

In case anyone else is having the same nightmare:

My di.xml looks like this

<?xml version="1.0"?>
<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="Mynamespace\Grouped\Model\Rewrite\Product\Type\Grouped" />
        <type name="Mynamespace\Grouped\Model\Rewrite\Product\Type\Grouped">
        <plugin name="Mynamespace_grouped_groupedproduct_model" type="Mynamespace\Grouped\Plugin\Grouped" />

Folder Structure looks like:

    ->etc (di.xml & module.xml)
    ->Model->Rewrite->Product->Type->Grouped.php (copy of core)
    ->Plugin->Grouped.php (containing plugin code)

On the frontend I've added the attributes into overriden copy of


and hey presto it worked.

A big thank you to those who replied and tried to help and I hope this answers helps others.

Now all I need to do is get them to show up in the cart and throughout checkout


  • Hi. Are you saying you had to add a copy of part of the Grouped model with your plugin for it to work, without any changes? I'm having a similar problem and was hoping i just needed to get the details right in my di.xml :S
    – iphigenie
    Aug 17, 2018 at 8:12

Please try below

<type name="Magento\GroupedProduct\Model\Product\Type\Grouped">
    <plugin name="Grouped" type="Mynamespace\Plugingrouped\Plugin\Grouped" />
  • Thanks for the reply but that didn't work either. It's driving my around the bend, I've spent days on it. It just doesn't return the value in the attribute :-(
    – wjp_bill
    Jul 4, 2018 at 11:46
  • I think you set 'Yes' in Used in Product Listing for this attribute. Jul 4, 2018 at 11:56
  • Yes they are set to "Yes" They show up on the simple product pages but I can't add them to a group grid
    – wjp_bill
    Jul 4, 2018 at 12:06

Your Answer

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

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