How can I get only grouped products in a product collection in Magento 2?

is there any filter for that?

protected $productCollectionFactory;

public function __construct(
    \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
) {
    $this->productCollectionFactory = $productCollectionFactory;    

Now you can use this like,

$groupProductCollection = $this->productCollectionFactory->create() 
                                        ->addAttributeToFilter('type_id', array('eq' => 'grouped'));

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.