Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有特定id的magento产品集合_Magento - Fatal编程技术网

具有特定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的顺序相同

谢谢

查看更多@


nice我的解决方案更糟糕:$collection->getSelect()->order(($p1path[1]时的案例e.entity_id,然后$p2path[1]时的案例1,然后$p3path[1]时的案例2,然后3,否则0结束)”@雷诺·斯图尔特:你救了我好几天的命。谢谢:D
    $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();
    }