0

We need to display grouped products without simple products associated with it in listing page. By default in Magento 2, if there is no simple product associated with grouped product then the grouped product doesn't show in product listing ,but we need to display grouped products without simple products associated with it. Can anyone done this before.

1 Answer 1

0

Try This :-

$productFactory = $obj->create('Magento\Catalog\Model\ProductFactory')->create()
    ->getCollection()->addFieldToFilter('type_id', array('eq' => 'grouped'));
foreach ($productFactory as $product)
{
   $associatedProduct = $product->getTypeInstance()->getAssociatedProducts();
   if(!isset($associatedProduct))
   {
       $productName = $product->getName();
   }
}
5
  • hii , thanks for the code but i need to modify product collection in list page so that i need to show grouped products without simple products.
    – Prasanth
    May 13, 2019 at 6:23
  • you can override list.phtml file and apply filter to display grouped products without simple products May 13, 2019 at 6:25
  • in magento 2.2.5 they are showing but from magento 2.2.6 the grouped without simple are not showing . Is there any path to debug that in collection level.
    – Prasanth
    May 13, 2019 at 10:12
  • vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml May 13, 2019 at 10:15
  • in this file load collection and display product May 13, 2019 at 10:16

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.