0

I have product Attribute "Model". Now, I want those product which have model attribute from product Collection

how I achieve that?

1 Answer 1

1

You can collection by this below code :

protected $productCollectionFactory;

public function __construct(
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory  $productCollectionFactory

){
     $this->productCollectionFactory = $productCollectionFactory;
}

$productcollection = $this->productCollectionFactory->create()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('status', 1);

set your attribute code and value in addAttributeToFilter() based on your requirement.

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.