<bdo id='3HnSQ'></bdo><ul id='3HnSQ'></ul>

    <small id='3HnSQ'></small><noframes id='3HnSQ'>

  • <tfoot id='3HnSQ'></tfoot>

        <legend id='3HnSQ'><style id='3HnSQ'><dir id='3HnSQ'><q id='3HnSQ'></q></dir></style></legend>
        <i id='3HnSQ'><tr id='3HnSQ'><dt id='3HnSQ'><q id='3HnSQ'><span id='3HnSQ'><b id='3HnSQ'><form id='3HnSQ'><ins id='3HnSQ'></ins><ul id='3HnSQ'></ul><sub id='3HnSQ'></sub></form><legend id='3HnSQ'></legend><bdo id='3HnSQ'><pre id='3HnSQ'><center id='3HnSQ'></center></pre></bdo></b><th id='3HnSQ'></th></span></q></dt></tr></i><div id='3HnSQ'><tfoot id='3HnSQ'></tfoot><dl id='3HnSQ'><fieldset id='3HnSQ'></fieldset></dl></div>

        如何在 magento 订单网格中正确添加 shipping_description 列?

        时间:2024-08-22
            <i id='TpWQP'><tr id='TpWQP'><dt id='TpWQP'><q id='TpWQP'><span id='TpWQP'><b id='TpWQP'><form id='TpWQP'><ins id='TpWQP'></ins><ul id='TpWQP'></ul><sub id='TpWQP'></sub></form><legend id='TpWQP'></legend><bdo id='TpWQP'><pre id='TpWQP'><center id='TpWQP'></center></pre></bdo></b><th id='TpWQP'></th></span></q></dt></tr></i><div id='TpWQP'><tfoot id='TpWQP'></tfoot><dl id='TpWQP'><fieldset id='TpWQP'></fieldset></dl></div>
              <bdo id='TpWQP'></bdo><ul id='TpWQP'></ul>

            • <small id='TpWQP'></small><noframes id='TpWQP'>

              <tfoot id='TpWQP'></tfoot>
                <tbody id='TpWQP'></tbody>
                <legend id='TpWQP'><style id='TpWQP'><dir id='TpWQP'><q id='TpWQP'></q></dir></style></legend>

                1. 本文介绍了如何在 magento 订单网格中正确添加 shipping_description 列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有很多教程和建议,包括安装自定义扩展等.

                  There are many tutorials and suggestions including installing a custom extensions etc.

                  我已经根据各种提示和技巧添加了 shipping_description 罚款,方法是使用以下代码修改 Grid.php,但是当按价格或状态对其进行排序时,它会引发错误:

                  I've added the shipping_description fine based on various tips and tricks by modifying the Grid.php with the following code, but when it comes to sorting it by Price or Status it throws an error:

                  SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列状态"不明确或者SQLSTATE[23000]: 完整性约束违规: 1052 where 子句中的列 'increment_id' 不明确

                  SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous or SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'increment_id' in where clause is ambiguous

                  不过,按帐单和发货名称排序没问题.

                  It sorts ok by Billing and Shipping Name though.

                  在 Grid.php 中添加了以下代码:

                  The following code was added to Grid.php:

                  protected function _prepareCollection()
                  {
                      $collection = Mage::getResourceModel($this->_getCollectionClass());
                  
                      $tableName = Mage::getSingleton("core/resource")->getTableName('sales_flat_order');                  
                      $collection->getSelect()->join($tableName, "main_table.entity_id =          $tableName.entity_id",array("shipping_description"));
                      $this->setCollection($collection);               
                      return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
                  }     
                  
                  
                  protected function _prepareColumns()
                  {
                      $this->addColumnAfter('shipping_description', array(
                          'header'    => Mage::helper('sales')->__('Delivery'),
                          'width'     => '180px',
                          'type'      => 'text',
                          'index'     => 'shipping_description'
                  
                      ),'shipping_name');   
                  
                      return parent::_prepareColumns();
                  } 
                  

                  任何想法,想法将不胜感激!!!

                  any thoughts, ideas would be appreciated!!!

                  推荐答案

                  以下在我的情况下有效.排序现在适用于每个字段.没有覆盖核心文件.

                  The following worked in my case. Sorting now works from every single field. No core files overridden.

                  步步为营的人.在 1.8.1 中测试

                  Step by step for someone who is in the same boat. Tested in 1.8.1

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

                  如果路径不存在,则创建它.

                  if the path doesn't exist create it.

                  打开新的 Grid.php 并将以下代码添加到 getResourceModel 行之后的 _prepareCollection() 中:

                  Open your new Grid.php and add the following code into _prepareCollection() after getResourceModel line:

                  $collection->getSelect()->join(array('mt'=>'sales_flat_order'),'mt.entity_id = main_table.entity_id',array('mt.increment_id','mt.store_id','mt.created_at','mt.shipping_description','mt.status','mt.base_grand_total','mt.grand_total'));

                  $collection->getSelect()->group('main_table.entity_id');

                  将以下代码添加到 _prepareColumns() 函数中(在所需的 addColumn() 调用之间)

                  Add the following code into _prepareColumns() function (in between your desired addColumn() calls)

                  $this->addColumn('shipping_description', array('标题' =>Mage::helper('sales')->__('Delivery'),'类型' =>'文本','索引' =>'shipping_description',
                  'filter_index' =>'mt.shipping_description',));

                  increment_id、store_id、created_at、base_grand_total、grand_total、status 找到 addColumns() 函数,并在每个函数中添加以下参数:

                  Find addColumns() functions for increment_id, store_id, created_at, base_grand_total, grand_total, status and add the following argument in each:

                  'filter_index' =>'mt.___your_column_name____',

                  欢迎任何关于如何优化上述代码的建议.

                  Any suggestion on how to optimise above code are welcome.

                  这篇关于如何在 magento 订单网格中正确添加 shipping_description 列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 PHP 在 Firebase 上创建主题 下一篇:网格生成与用 css/js/php 划分

                  相关文章

                    <bdo id='AzDOU'></bdo><ul id='AzDOU'></ul>

                  <tfoot id='AzDOU'></tfoot>

                2. <small id='AzDOU'></small><noframes id='AzDOU'>

                3. <legend id='AzDOU'><style id='AzDOU'><dir id='AzDOU'><q id='AzDOU'></q></dir></style></legend>

                  1. <i id='AzDOU'><tr id='AzDOU'><dt id='AzDOU'><q id='AzDOU'><span id='AzDOU'><b id='AzDOU'><form id='AzDOU'><ins id='AzDOU'></ins><ul id='AzDOU'></ul><sub id='AzDOU'></sub></form><legend id='AzDOU'></legend><bdo id='AzDOU'><pre id='AzDOU'><center id='AzDOU'></center></pre></bdo></b><th id='AzDOU'></th></span></q></dt></tr></i><div id='AzDOU'><tfoot id='AzDOU'></tfoot><dl id='AzDOU'><fieldset id='AzDOU'></fieldset></dl></div>