【问题标题】:Filter count column Magento Customer Admin grid with filter_condition_callback使用 filter_condition_callback 过滤计数列 Magento 客户管理网格
【发布时间】:2013-11-05 17:37:54
【问题描述】:

我已修改 ../app/code/local/Mage/Adminhtml/Block/Customer/Grid.php 中的 magento 客户管理网格以包含总订单,但需要应用过滤器,我一直在使用 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;
    }

【问题讨论】:

  • 你期望发生什么?
  • 嗨@afuzzyllama,我希望能够过滤magento后端中的order_total列,但是我的条件有问题-$this->getCollection()->getSelect()->where('order_total = ?', "$value");日志显示未找到字段错误.
  • 你找到解决办法了吗?

标签: php magento zend-framework magento-1.7


【解决方案1】:

这与 filter_condition_callback 函数无关,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多