【问题标题】:Add Delivery Date from the Product Custom Option to Sales Order Grid in magento将产品自定义选项中的交货日期添加到 magento 中的销售订单网格
【发布时间】:2013-07-26 11:16:00
【问题描述】:

我已将交货日期添加为产品的自定义选项。我希望交货日期显示在管理员的销售订单网格中。 我已经创建了Namespace_Module_Block_Adminhtml_Sales_Order_Grid 的本地副本。

_prepareCollection() 函数中,我可以获得产品选项:

$collection = Mage::getResourceModel($this->_getCollectionClass())
    ->join(
    'sales/order_item',
    '`sales/order_item`.order_id=`main_table`.entity_id',
    array(
        **'proptions' => new Zend_Db_Expr('group_concat(`sales/order_item`.product_options SEPARATOR ",")'),**
    )
);

然后我将列添加为:

$this->addColumn('proptions', array(
        'header'    => Mage::helper('Sales')->__('Product Options'),
        'width'     => '100px',
        'index'     => 'proptions',
        'renderer'  =>  new Namespace_Module_Block_Adminhtml_Renderer_Data(),
    ));

现在在Namespace_Module_Block_Adminhtml_Renderer_Data()我有一个方法:

public function _getValue(Varien_Object $row)
{
    $val = $row->getData($this->getColumn()->getIndex());  // row value
    $array = unserialize($val);

    //loop thru the $array and create a format string
    //
    $options = $array['options'];
    $format_val = '';
    foreach ($options as $key=> $value) {
        $format_val = $format_val . $key . "=>" . $value . " , ";
    }

    return $format_val;
}

显示不正确。我认为我没有正确循环数组。我在这里做错了什么?

【问题讨论】:

  • 嗨,这个问题似乎是因为查询返回的值不完整:

标签: grid magento-1.7 ecommerce-sales


【解决方案1】:

如果您想在直接 sql 查询中执行此操作,请打开此文件。->app->design->adminhtml->default->default->template-> 您的模板 ->info.phtml 并添加此代码

<div class="entry-edit">
            <div class="entry-edit-head">
                <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Delivery Time Information') ?></h4>
            </div>
        </div>
        <div class="grid np">

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
//$write = Mage::getSingleton('core/resource')->getConnection('core_write');//for writing to database
$sql = "SELECT * FROM tablename";

$results = $connection->fetchAll($sql);
foreach($results as $result) {
  echo $result['column_name']."<br/>";
} 
</div></div></div>

【讨论】:

    【解决方案2】:

    通过更新 MySQL 解决: 设置会话 group_concat_max_len = 1000000;

    这也可以在全局级别上设置。 谢谢, 尼特

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-13
      • 2019-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多