1

我已经修改了 magento 客户管理网格../app/code/local/Mage/Adminhtml/Block/Customer/Grid.php以包含总订单,但需要应用过滤器,我一直在使用 filter_condition_callback 但无法使其工作。有什么建议么?

修改集合:

    $collection->getSelect()->joinLeft(array('sales_flat_order'), 'sales_flat_order.customer_id=e.entity_id', array('order_total' => 'COUNT(customer_id)'));
    $collection->groupByAttribute('entity_id')

订单总计栏:

        $this->addColumn('order_total', array(
        'header' => Mage::helper('customer')->__('Total Orders'),
        'type' => 'text',
        'index' => 'order_total',
        //'filter' => true,
        'sortable' => false,
        'filter_condition_callback' => array($this, '_orderTotalFilter'),
    ));

OrderTotalFilter 回调:

    protected function _orderTotalFilter($collection, $column) {
    if (!$value = $column->getFilter()->getValue()) {
        return $this;
    }

        $this->getCollection()->getSelect()->where('condition = ?', "$value");
//        $query = $collection->getSelect()->__toString();
//        echo $query;

        return $this;
    }
4

1 回答 1

0

这与 filter_condition_callback 函数无关,

Magento 网格不允许组语句。因此,您的分页和过滤器已损坏。

于 2014-12-11T10:06:57.787 回答