0

我需要将客户的“公司”属性添加到发票网格中。下面是我更改的代码,它在 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 条记录”。所以我不能移动到下一页。

请帮忙。

谢谢

4

2 回答 2

0

请检查以下链接。你可能会有一个想法。

为 grid.php 文件添加到网格选择

http://www.magentocommerce.com/boards/viewthread/197590/

http://www.widgetsandburritos.com/adding-fields-order-invoice-grid-magento/

于 2012-04-26T05:04:31.640 回答
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;
}
于 2012-05-01T11:47:45.500 回答