【发布时间】:2016-12-23 01:17:45
【问题描述】:
public function getAllProductById($id=0)
{
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('entity_id', array('eq' => $id))
->joinTable(
'cataloginventory_stock_item',
'product_id=entity_id',
array('quantite' => 'qty'),
null,
'left'
)
->load()
;
if ($products) {
return $products;
} else {
return $products == null;
}
}
即使我使用未在 Magento 中设置的 id ($id),变量 $products 也不会返回 null。
【问题讨论】:
-
return $products == null;将其更改为返回 $products = null;
标签: php eclipse magento collections return