Magento 2分页无法与产品集合和自定义表联接

时间:2017-10-27 06:00:03

标签: pagination magento2

$page=($this->getRequest()->getParam('p'))? $this->getRequest()->getParam('p') : 1;

$pageSize=($this->getRequest()->getParam('limit'))? $this->getRequest()->getParam('limit') : 4;

$collection = $this->productcollection->create()->addAttributeToSelect(array('group_name','name','status'));

$collection->addAttributeToFilter('status',1);

$collection->getSelect()
    ->join(['firmware_product' => $collection->getTable('firmware_product')],'firmware_product.product_id = e.entity_id',[]);
$collection->getSelect()
    ->join(['firmware' => $collection->getTable('firmware')],'firmware.entity_id = firmware_product.firmware_id',[])
    ->columns(array("firmware.version_no","firmware.build_date","firmware.is_active"));


$collection->getSelect()->where("firmware.is_active = ?",1);

$collection->getSelect()->order('firmware.entity_id', 'DESC');

$collection->setPageSize($pageSize);$collection->setCurPage($page);

上面的代码给出了与已存在的entity_id相同的代码。我重置了列并仅获取固件记录,它仍然在固件entity_id中给出了相同的错误。如果我使用此代码

 $collection->getSelect()->group('e.entity_id'); 
然后分页不起作用。谁能告诉我这个解决方案是什么?

0 个答案:

没有答案