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
Magento添加库存或数量大于1的随机项目_Magento_Random - Fatal编程技术网

Magento添加库存或数量大于1的随机项目

Magento添加库存或数量大于1的随机项目,magento,random,Magento,Random,我希望筛选只有库存或数量>=1的项目 我的代码: $_category = Mage::getModel('catalog/category')->load($this->getCategoryId()); $_productCollection = Mage::getResourceModel('catalog/product_collection') ->addAttributeToSelect('*')

我希望筛选只有库存或数量>=1的项目

我的代码:

$_category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$_productCollection = Mage::getResourceModel('catalog/product_collection')
                   ->addAttributeToSelect('*')
                   ->addAttributeToFilter('sku', array('gt' => 140));
$_productCollection->getSelect()->order(new Zend_Db_Expr('RAND()'));                  
$_productCollection->setPage(1, 8);

我试图添加->addAttributeToFilter'is_in_stock'、'1';但是没有运气。

@user1139767如果你把答案贴在下面,可能会对其他人有所帮助。