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
<?php
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)
{
$result->addAttributeToSelect('my_attribute_weight');
$result->addAttributeToSelect('my_attribute_height');
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" />
</type>
And then I tried calling a custom attribute in
app/design/frontend/Mynamespace/base/Magento_GroupedProduct/templates/product/view/type/grouped.html
<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.
namespace
.