我需要将客户的“公司”属性添加到发票网格中。 下面是我更改的代码,它在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条记录'。所以我不能转到下一页。
Anye请帮助。
由于
答案 0 :(得分:0)
请检查以下链接。你可能会有一个想法。
Adding to Grid Selection for grid.php file
http://www.magentocommerce.com/boards/viewthread/197590/
http://www.widgetsandburritos.com/adding-fields-order-invoice-grid-magento/
答案 1 :(得分:0)
对于任何一个管理网格分页器出现问题的人来说,这是解决方案。
从magento / lib / Varien / Data / Collection / Db.php复制Db.php文件 将其粘贴到本地目录,以便生成的文件夹结构如下所示: magento / app / code / local / Varien / Data / Collection / Db.php
public function getSelectCountSql()
{
$this->_renderFilters();
$countSelect = clone $this->getSelect();
$countSelect->reset(Zend_Db_Select::ORDER);
$countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
$countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
$countSelect->reset(Zend_Db_Select::COLUMNS);
if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
$countSelect->reset(Zend_Db_Select::GROUP);
$countSelect->distinct(true);
$group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
$countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
} else {
$countSelect->columns('COUNT(*)');
}
return $countSelect;
}