集合空magento

时间:2015-11-30 19:35:17

标签: php magento

Hello我的集合没有填充本地计算机上的数据库中的值正在运行,但是在非生产环境中。 当我运行时,生成的SQL值通常显示在银行中,但不会填充集合。你能救我吗?

public function __construct() {
    parent::__construct();

    $userid = Mage::getSingleton('customer/session')->getCustomer()->getId();
    $post = $this->getRequest()->getPost();
    $rowdata=array();

    $querydata = Mage::getModel('stock/product')->getCollection()
        ->addFieldToFilter('userid', array('eq' => $userid))
        ->addFieldToFilter('status', array('neq' => 2))
        ->setOrder('stockproductid');

    foreach ($querydata as  $value) {
        $qty = (int)Mage::getModel('cataloginventory/stock_item')
            ->loadByProduct($value->getStockproductid())->getQty();
        if($qty) {
            $rowdata[] = $value->getStockproductid();
        }
    }

    $collection = Mage::getModel('catalog/product')->getCollection();
    $collection->addAttributeToSelect('*');
    $collection->addAttributeToFilter('entity_id', array('in' => $rowdata));
    $collection->addAttributeToSort('name', 'ASC');

    //filter with search content
    if(!empty($post)) {
        $collection->addAttributeToFilter(array(array('attribute'=>'name', 'like'=>'%'.$post['searchfr'].'%')));
    }

    $this->setCollection($collection);
}

1 个答案:

答案 0 :(得分:0)

您是否启用了平面目录? 我的猜测是尝试重新编制您的生产环境索引。