0

I'm trying to get product collection with multiple skus filter, don't know what I'm missing or doing wrong:

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $productCollectionFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
    $collection = $productCollectionFactory->create();
    $collection->addAttributeToSelect(['name','sku']);
    $collection->addAttributeToFilter('sku', ['in' => ['IS-OB-2165','TM-VIVO-Y15']]);
    $collection->setPageSize(3);

    foreach ($collection as $product) {
        print_r($product->getName());
    }
0

use below code

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollectionFactory = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$collection = $productCollectionFactory->create();
$collection ->addFieldToSelect('*'); // only need sku, price, id,
$collection ->addAttributeToFilter('sku', ['in' => array('IS-OB-2165','TM-VIVO-Y15')]);

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.