magento - 搜索销售订单网格重定向到 magento 1.7 中的仪表板

标签 magento magento-1.7

我已使用自定义模块向 Magento 中的 Sales_Order_Grid 添加新列,但如果我搜索 Order_Id,页面将​​重定向到仪表板。

如果我尝试再次选择销售/订单,我会收到错误消息:

a:5:{i:0;s:104:"SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous";i:1;s:6229:"#0

我不知道如何解决这个问题,能否提供一些指导?

这是 Grid.php 代码:

<?php
class Excellence_Salesgrid_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{


    protected function _addColumnFilterToCollection($column)
    {
        if ($this->getCollection()) {
            if ($column->getId() == 'shipping_telephone') {
                $cond = $column->getFilter()->getCondition();
                $field = 't4.telephone';
                $this->getCollection()->addFieldToFilter($field , $cond);
                return $this;
            }else if ($column->getId() == 'shipping_city') {
                $cond = $column->getFilter()->getCondition();
                $field = 't4.city';
                $this->getCollection()->addFieldToFilter($field , $cond);
                return $this;
            }else if ($column->getId() == 'shipping_region') {
                $cond = $column->getFilter()->getCondition();
                $field = 't4.region';
                $this->getCollection()->addFieldToFilter($field , $cond);
                return $this;
            }else if ($column->getId() == 'shipping_postcode') {
                $cond = $column->getFilter()->getCondition();
                $field = 't4.postcode';
                $this->getCollection()->addFieldToFilter($field , $cond);
                return $this;
            }else if($column->getId() == 'product_count'){
                $cond = $column->getFilter()->getCondition();
                $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
                $this->getCollection()->getSelect()->having($this->getCollection()->getResource()->getReadConnection()->prepareSqlCondition($field, $cond));
                return $this;
            }else if($column->getId() == 'skus'){
                $cond = $column->getFilter()->getCondition();
                $field = 't6.sku';
                $this->getCollection()->joinSkus();
                $this->getCollection()->addFieldToFilter($field , $cond);
                return $this;
            }else{
                return parent::_addColumnFilterToCollection($column);
            }
        }
    }

    protected function _prepareColumns()
    {

        $this->addColumnAfter('shipping_description', array(
                'header' => Mage::helper('sales')->__('Shipping Method'),
                'index' => 'shipping_description',
        ),'shipping_name');
        $this->addColumnAfter('method', array(
                'header' => Mage::helper('sales')->__('Payment Method'),
                'index' => 'method',
                'type'  => 'options',
                'options' => Mage::helper('payment')->getPaymentMethodList()
        ),'shipping_description');

        $this->addColumnAfter('shipping_city', array(
                'header' => Mage::helper('sales')->__('Shipping City'),
                'index' => 'shipping_city',
        ),'method');

        $this->addColumnAfter('shipping_telephone', array(
                'header' => Mage::helper('sales')->__('Shipping Telephone'),
                'index' => 'shipping_telephone',
        ),'method');

        $this->addColumnAfter('shipping_region', array(
                'header' => Mage::helper('sales')->__('Shipping Region'),
                'index' => 'shipping_region',
        ),'method');

        $this->addColumnAfter('shipping_postcode', array(
                'header' => Mage::helper('sales')->__('Shipping Postcode'),
                'index' => 'shipping_postcode',
        ),'method');

        /*$this->addColumnAfter('product_count', array(
                'header' => Mage::helper('sales')->__('Product Count'),
                'index' => 'product_count',
                'type' => 'number'
        ),'increment_id');

        /*$this->addColumnAfter('skus', array(
                'header' => Mage::helper('sales')->__('Product Purchased'),
                'index' => 'skus',
        ),'increment_id');*/

        return parent::_prepareColumns();

    }


}

最佳答案

这就是我的案例:

$collection->addFilterToMap('increment_id', 'main_table.increment_id');

关于magento - 搜索销售订单网格重定向到 magento 1.7 中的仪表板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15343967/

相关文章:

Magento 管理员登录在 chrome 中不起作用,但在 firefox 中工作正常

php - 批量导入自定义属性 Magento

magento - 获取与特定产品相关的产品

magento-1.7 - .magento 。必须加载 PHP 扩展 "soap"

magento - 以编程方式创建订单时如何使用折扣代码设置折扣金额?

php - 如何从 Magento 1.7 REST API 获取访问 token 和访问 token secret

magento - 在 Magento 中通过商店明智地获取产品价格和描述

php - 将 Magento 类别复制到父级

magento - 删除内容暂存网站

magento - 如何在magento中下载文件