I need to filter the products by store. However, after many try for almost a day, I can't filter products by store.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $productCollectionFactory->create(); // filter current store products $collection->addStoreFilter(); $collection->addFieldToFilter('entity_id', ['in' => $best_selling_product_id]);
$best_selling_product_id is an array of product ID's. However, above code returns products from all stores.
Can someone help me here?