Magento:销售订单网格中单独行上的订单项

时间:2012-12-19 15:28:20

标签: mysql magento zend-db magento-1.6

我正在运行Magento Community 1.6.2

我正在尝试编辑我的销售订单网格,以便各个项目(多个项目订单的一部分)显示在他们自己的行上。

我添加到我的Grip.php中的prepareCollection函数(首先要操作这些列)如下:

     protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass())
        ->join(
            'sales/order_item',
            '`sales/order_item`.order_id=`main_table`.entity_id',
            array(
                'skus'  => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR "<br>")'),
                'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR "<br>")'),
                'quantities' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR "<br>")'),
                )
            );
            $collection->getSelect()->group('entity_id');

        $this->setCollection($collection);
    return parent::_prepareCollection();
}

我已使用以下内容添加了列:

    $this->addColumn('skus', array(
        'header'    => Mage::helper('Sales')->__('SKUs'),
       'width'     => '120px',
        'index'     => 'skus',
       'type'        => 'text',

      ));


     $this->addColumn('names', array(
       'header'    => Mage::helper('Sales')->__('Item Names'),
       'width'     => '320px',
       'index'     => 'names',
       'type'        => 'text',
    )); 

      $this->addColumn('quantities', array(
        'header'    => Mage::helper('Sales')->__('Quantities'),
        'width'     => '100px',
        'index'     => 'quantities',
        'type'        => 'text',

    )); 

目前,在该功能中,我只需输入<br>即可在查看订单网格时显示单独的行。这不足以满足我的需求。我计划利用此网格中导出的CSV,并且绝对必须在单独的行上包含明细订单组件。

谢谢你的帮助!

2 个答案:

答案 0 :(得分:0)

我真的不知道在没有创建Mage销售订单项目网格的情况下是否可以按照您的要求进行操作。

以下是你问过我的上一篇文章的内容......也许他们会帮助你:

$collection->getSelect()->join('catalog_product_index_eav', '`catalog_product_index_eav`.`entity_id` = `main_table`.`product_id` AND `catalog_product_index_eav`.`attribute_id` = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = "brand")', array('attribute_id'));
$collection->getSelect()->join('eav_attribute_option_value', '`eav_attribute_option_value`.`option_id` = `catalog_product_index_eav`.`value`', array('brand' => 'value'));

答案 1 :(得分:0)

我修改了sku数组定义,而不是创建“数量”。

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

我相信你可以使用floor(sales/order_item。qty_ordered)将你的'quantity'定义转换为整数。

订单网格上的

SKU列结果如下: MBA001(2),MOF004(1)

相关问题