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.

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();
   }
}
  • 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 at 6:23
  • you can override list.phtml file and apply filter to display grouped products without simple products – Rk Rathod May 13 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 at 10:12
  • vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml – Rk Rathod May 13 at 10:15
  • in this file load collection and display product – Rk Rathod May 13 at 10:16

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.