我需要将客户的“公司”属性添加到发票网格中。下面是我更改的代码,它在 phpmyadmin 中显示了正确的查询结果,但不知何故,它只显示 2 作为发票网格上的总记录。
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinInner(array('order_address' => Mage::getSingleton('core/resource')->getTableName('sales_flat_order_address')),'order_address.parent_id = main_table.order_id',array('company'))->group('parent_id')->order('entity_id', 'desc');
$this->setCollection($collection);
return parent::_prepareCollection();
}
查询是
SELECT `main_table`.*, `order_address`.`company` FROM `sales_flat_invoice_grid` AS `main_table` INNER JOIN `sales_flat_order_address` AS `order_address` ON order_address.parent_id = main_table.order_id GROUP BY `parent_id`
如果我将记录数更改为每页 200 条,它会显示所有记录,但分页和总记录存在一些问题。
它总是显示 1 页和“共找到 2 条记录”。所以我不能移动到下一页。
请帮忙。
谢谢