I am trying to remove prices for certain products in a group from being displayed. I created an interceptor with the afterIsSalable method to check for my condition and return false if met.

This works fine mostly however within grouped.phtml which shows all the grouped prices on the product view page the $_item->isSalable() returns true (when it should return false for this case).

If I grab the product like below it correctly returns false however:

    //test just to grab the product from the item id and check value:
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
    $_producttest = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getId());
    echo "DISP:" . $_producttest->isSalable(); //RETURNS FALSE

Compared with:

$_item->isSalable(); //RETURNS TRUE

Why would this be working like this?


The function getAssociatedProducts() adds only a select few attributes to the collection. I created a preference for the Magento\GroupedProduct\Model\Product\Type\Grouped class and then modified getAssociatedProducts() to add the 'msrp_display_actual_price_type' attribute to the collection like below:

namespace Vendor\Module\Model;

class Grouped extends \Magento\GroupedProduct\Model\Product\Type\Grouped
  public function getAssociatedProducts($product)
    if (!$product->hasData($this->_keyAssociatedProducts)) {
        $associatedProducts = [];


        $collection = $this->getAssociatedProductCollection(
            ['name', 'price', 'special_price', 'special_from_date', 'special_to_date', 'tax_class_id', 'msrp_display_actual_price_type']
            ['in' => $this->getStatusFilters($product)]

        foreach ($collection as $item) {
            $associatedProducts[] = $item;

        $product->setData($this->_keyAssociatedProducts, $associatedProducts);
    return $product->getData($this->_keyAssociatedProducts);
| improve this answer | |

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.