西部数码主机 | 阿里云主机| 虚拟主机 | 服务器 | 返回乐道官网
当前位置: 主页 > php教程 > magento教程 >

Magento订单后台增加支付接口来源列

时间:2016-02-03 11:05来源: 作者: 点击:
在Magento后台订单列表上增加支付方式,让客服工作更轻松,一眼就看出是哪个支付接口的了 1.3.2.4以前的版本,是修改 app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php protected function _prepare

在Magento后台订单列表上增加支付方式,让客服工作更轻松,一眼就看出是哪个支付接口的了

1.3.2.4以前的版本,是修改

app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

protected function _prepareCollection()
    {
 $tablePre= (string)Mage::getConfig()->getTablePrefix();
         //TODO: add full name logic
  $res = Mage::getResourceModel(“sales/order_payment”);
  
  $paymentWhere = array(“entity_type_id” => $res->getTypeId());
  
  $attributes =$res->loadAllAttributes()->getAttributesByCode();
  
         foreach ($attributes as $attrCode=>$attr) {
   if ($attr->getAttributeCode()==”method”){
    $attId = $attr->getAttributeId();
   }
           
        }
  $paymentMethodWhere = “{{table}}.attribute_id = ‘$attId’”;
         $collection = Mage::getResourceModel(‘sales/order_collection’)
            ->addAttributeToSelect(‘*’)
            ->joinAttribute(‘billing_firstname’, ‘order_address/firstname’, ‘billing_address_id’, null, ‘left’)
            ->joinAttribute(‘billing_lastname’, ‘order_address/lastname’, ‘billing_address_id’, null, ‘left’)
            ->joinAttribute(‘shipping_firstname’, ‘order_address/firstname’, ‘shipping_address_id’, null, ‘left’)
            ->joinAttribute(‘shipping_lastname’, ‘order_address/lastname’, ‘shipping_address_id’, null, ‘left’)
       ->joinTable($tablePre . ‘sales_order_entity’, ‘parent_id=entity_id’, array( ‘quote_payment_id_for_join’ => ‘entity_id’ ) , $paymentWhere, ‘left’ )
            ->joinTable($tablePre.’sales_order_entity_varchar’, ‘entity_id=quote_payment_id_for_join’, array( ‘payment’ => ‘value’ ) , $paymentMethodWhere, ‘left’ )
            ->addExpressionAttributeToSelect(‘billing_name’,
                ‘CONCAT({{billing_firstname}}, ” “, {{billing_lastname}})’,
                array(‘billing_firstname’, ‘billing_lastname’))
            ->addExpressionAttributeToSelect(‘shipping_name’,
                ‘CONCAT({{shipping_firstname}}, ” “, {{shipping_lastname}})’,
                array(‘shipping_firstname’, ‘shipping_lastname’));
        $this->setCollection($collection);
         return parent::_prepareCollection();
    }

然后增加列:
    protected function _prepareColumns()
    {

        $this->addColumn(‘real_order_id’, array(
            ‘header’=> Mage::helper(‘sales’)->__(‘Order #’),
            ‘width’ => ’80px’,
            ‘type’  => ‘text’,
            ‘index’ => ‘increment_id’,
        ));

    $this->addColumn(‘payment’, array(
            ‘header’ => Mage::helper(‘sales’)->__(‘Payment’),
            ‘index’ => ‘payment’,
   ’sortable’  => false,
        ));

 

1.4.2.0 1.5.1.0是修改

app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php

 protected function _prepareCollection()
    {
      
     $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->joinLeft(array(‘payments’ => $collection->getTable(‘sales/order_payment’)),
     ’payments.parent_id = main_table.entity_id’,
  ’method’
 );
         $this->setCollection($collection);
          return parent::_prepareCollection();
    }

protected function _prepareColumns()
    {

        $this->addColumn(‘real_order_id’, array(
            ‘header’=> Mage::helper(‘sales’)->__(‘Order #’),
            ‘width’ => ’80px’,
            ‘type’  => ‘text’,
            ‘index’ => ‘increment_id’,
        ));

        if (!Mage::app()->isSingleStoreMode()) {
            $this->addColumn(‘store_id’, array(
                ‘header’    => Mage::helper(‘sales’)->__(‘Purchased From (Store)’),
                ‘index’     => ‘store_id’,
                ‘type’      => ‘store’,
                ‘store_view’=> true,
                ‘display_deleted’ => true,
            ));
        }

        $this->addColumn(‘created_at’, array(
            ‘header’ => Mage::helper(‘sales’)->__(‘Purchased On’),
            ‘index’ => ‘created_at’,
            ‘type’ => ‘datetime’,
            ‘width’ => ’100px’,
        ));
  $this->addColumn(‘payments’, array(
            ‘header’ => Mage::helper(‘sales’)->__(‘payments’),
            ‘index’ => ‘method’,
        ));

(责任编辑:好模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容