具有特定id的magento产品集合
我选择带有具有特定id的magento产品集合,magento,Magento,我选择带有 $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('entity_id', array('in' => $productIds)); 如何存档集合与$productIds中的ID的顺序相同 谢谢 查看更多@ nice我的解决方案更糟糕:$collection->getSelect()->order(($p1path[1]时的案例e.ent
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('entity_id', array('in' => $productIds));
如何存档集合与$productIds中的ID的顺序相同
谢谢
查看更多@
$productIds = array(1,3,2);
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('entity_id', array('in' => $productIds));
$products->getSelect()->order("find_in_set(entity_id,'".implode(',',$productIds)."')");
foreach($products as $product)
{
echo $product->getEntityId();
echo $product->getSku();
}