博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过产品ID得到collection!!!
阅读量:4202 次
发布时间:2019-05-26

本文共 714 字,大约阅读时间需要 2 分钟。

You can do as following for filtering products id 10 and 12

$products->addAttributeToFilter('entity_id', array('in'=>array(10,12)));
当然这种方式的上面,必须用  ->addAttributeToSelect();
下面这种方式比较实用的,如果想按照名字排序,那么使用方法:setOrder("name","asc");如果想按照ids中的排列的顺序,那么实用   $collection->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$ids)."')");  此为zf框架!
$idss = Mage::registry("idss");
$ids =  explode(",",$idss);
 //= array(3552,3553,3554,3555);
        $collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('*')
        ->addAttributeToFilter('entity_id',$ids);
    //    ->setOrder("name", "asc");
        $collection->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$ids)."')");
       
        $this->setCollection($collection);

转载地址:http://qncli.baihongyu.com/

你可能感兴趣的文章
Redis和Memcache对比及选择
查看>>
用谷歌账号登陆magento、
查看>>
php oauth 模块在linux下安装
查看>>
代替nginx的服务器 - The Tengine Web Server
查看>>
nginx 升级成 tengine 的代码
查看>>
magento rest api 调用
查看>>
magento rest api 调用!
查看>>
magento rest api get Token key and secret
查看>>
谷歌获取货币汇率代码
查看>>
安装nginx
查看>>
手动6 - 隐藏Nginx版本号
查看>>
手动7 - nginx 日志切割
查看>>
magento - 使用后台设置的时间用法
查看>>
Linux常用命令
查看>>
清除文件中的.svn文件
查看>>
手动11 -nginx 优化配置
查看>>
php加速器 - zendopcache
查看>>
手动12 - 安装php加速器 Zend OPcache
查看>>
set theme -yii2
查看>>
yii2 - 模块(modules)的view 映射到theme里面
查看>>