Magento2 – How to Get Product Collection with Manufacturer Attribute Filter

magento2

I am newbie in Magento 2 I try to get product collection with attribute filter 'Manufacturer'.
I try to implement with below code but not get result-set as per manufacturer filter:-

$manufacturer = 'Bosch';
$productCollectionFactory = $objectManager->get('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');

$collection = $productCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->getManufacturerName($manufacturer,['eq'=> $manufacturer]);
$collection->setCurPage(9);
$collection->setPageSize(100);

Best Answer

try this code

$manufacturerLabel = 'Bosch';
$manufacturerValue = 10; //assumed value of manufacturer Bosch
$productCollectionFactory = $objectManager->get('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');

$collection = $productCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('manufacturer', $manufacturerValue); // here filter with manufacturer value instead of label 
$collection->setCurPage(9);
$collection->setPageSize(100);