dongyishe6689 2015-05-01 06:54
浏览 39

销售订单中的自定义列如何在magento中与市场多厂商扩展

I am trying to add column in my sales_order grid. My column will be seller name of the product. I have a multivendor marketplace extension. I find the seller id which is the customer id but I can find the full name with the help of seller id.

I trying to solve it and here is the code that i used.

 protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass());
        $collection->getSelect()->join('marketplace_saleslist', 'main_table.entity_id = marketplace_saleslist.mageorderid',array('mageproownerid'));
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

And now I add the following column.

    $this->addColumn('mageproownerid', array(
        'header' => Mage::helper('sales')->__('Seller ID'),
        'index' => 'mageproownerid',
    ));

The Grid.php is :

public function __construct()
{
    parent::__construct();
    $this->setId('sales_order_grid');
    $this->setUseAjax(true);
    $this->setDefaultSort('created_at');
    $this->setDefaultDir('DESC');
    $this->setSaveParametersInSession(true);
}
protected function _getCollectionClass()
{
    return 'sales/order_grid_collection';
}
protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $collection->getSelect()->join('marketplace_saleslist', 'main_table.entity_id = marketplace_saleslist.mageorderid',array('mageproownerid'));
    $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' => 'date',
        'format'=> 'M/d/y',
        'width' => '100px',
    ));
    $this->addColumn('mageproownerid', array(
        'header' => Mage::helper('sales')->__('Seller ID'),
        'index' => 'mageproownerid',
    ));

    $this->addColumn('shipping_name', array(
        'header' => Mage::helper('sales')->__('Ship to Name'),
        'index' => 'shipping_name',
    ));

    $this->addColumn('base_grand_total', array(
        'header' => Mage::helper('sales')->__('G.T. (Base)'),
        'index' => 'base_grand_total',
        'type'  => 'currency',
        'currency' => 'base_currency_code',
    ));

    $this->addColumn('grand_total', array(
        'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
        'index' => 'grand_total',
        'type'  => 'currency',
        'currency' => 'order_currency_code',
    ));

    $this->addColumn('status', array(
        'header' => Mage::helper('sales')->__('Status'),
        'index' => 'status',
        'type'  => 'options',
        'width' => '70px',
        'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
    ));

    if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
        $this->addColumn('action',
            array(
                'header'    => Mage::helper('sales')->__('Action'),
                'width'     => '50px',
                'type'      => 'action',
                'getter'     => 'getId',
                'actions'   => array(
                    array(
                        'caption' => Mage::helper('sales')->__('View'),
                        'url'     => array('base'=>'adminhtml/sales_order/view'),
                        'field'   => 'order_id'
                    )
                ),
                'filter'    => false,
                'sortable'  => false,
                'index'     => 'stores',
                'is_system' => true,
        ));
    }
    $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));

    $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
    $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));

    return parent::_prepareColumns();
}

protected function _prepareMassaction()
{
    $this->setMassactionIdField('entity_id');
    $this->getMassactionBlock()->setFormFieldName('order_ids');
    $this->getMassactionBlock()->setUseSelectAll(false);

    $this->getMassactionBlock()->addItem('approve_order', array(
         'label'=> Mage::helper('sales')->__('Approve Order'),
         'url'  => $this->getUrl('*/*/massstatus'),
    ));
    return $this;
}

public function getRowUrl($row)
{
    if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
        return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
    }
    return false;
}

public function getGridUrl()
{
    return $this->getUrl('*/*/grid', array('_current'=>true));
}

}

I want to relate the above table with "customer_account" table using join on "marketplace_saleslist" field "mageproownerid".

How can we find the customer fullname.

Please let me know the solutions.

Thanks and regards.

  • 写回答

1条回答 默认 最新

  • douzhan4522 2015-05-01 07:07
    关注

    You can create helper function and change column in grid.php file

    $this->addColumn('mageproownerid', array(
        'header' => Mage::helper('sales')->__('Seller ID'),
        'index' => 'mageproownerid',
        'type'  =>  'options',  
        'options'   =>  Mage::helper('yourmodule')->getCustomerName(),
    ));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大