I'm trying to add a new function to the \Magento\GroupedProduct\Model\Product\Type\Grouped class

in \USR\GroupedByCore\etc\di.xml I have

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    <preference for="\Magento\GroupedProduct\Model\Product\Type\Grouped"
            type="\USR\GroupedByCore\Model\Product\Type\Grouped" />

in \USR\GroupedByCore\Model\Product\Type\Grouped.php

namespace USR\GroupedByCore\Model\Product\Type;

class Grouped extends \Magento\GroupedProduct\Model\Product\Type\Grouped    

    public function getAssociatedProductsByCore($product,$core)

        return "Something";


I'm calling it this way in Magento_GroupedProdcut\templates\product\view\type\grouped.p‌​html

<?php echo "This should be something: " . $this->getAssociatedProductsByCore($_product,'6'); ?>

Its not returning anything at all. The results is merely "This should be something:".

  • From where you try to call, write more detail.
    – Sohel Rana
    May 19, 2017 at 16:29
  • Magento_GroupedProdcut\templates\product\view\type\grouped.phtml
    – sharmstr
    May 19, 2017 at 16:57

1 Answer 1


Figured it out. I needed to call it like this:

$this->getProduct()->getTypeInstance()->getAssociatedProductsByCore($_product, 6); 

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.