I know it's possible to filter a collection by one SKU, as below:
$_testproductCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('SKU', array('like'=>array('my-sku')));
$_testproductCollection->load();
But is there some way to add a list of SKU's, like the following (which doesn't work):
->addAttributeToFilter('SKU', array('like'=>array('my-sku1, my-sku2, my-sku3')))
I haven't tested this, but I believe something like this should work:
->addAttributeToFilter( 'sku', array( 'in' => array( 'my-sku1', 'my-sku2', 'my-sku3' ) ) )
For future adventurers.
$productSkuString = 'PROD001, PROD002, PROD003';
$productIds = explode(', ', $productSkuString);
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*') // <- careful with this
->addAttributeToFilter(
'sku', array('in' => $productIds)
)
->load();
// usage
foreach($products as $prod) {
echo $prod->getName();
}
Tested in 1.7.0.2 and 1.8.1.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With