2014-02-07 56 views
0

我需要的是显示公司名称,而不是显示客户地址时的名字和姓氏。Magento添加公司名称来订购和客户网格

除此之外,我需要添加公司名称注册表格,客户和订单网格。

达到此目的的最佳方法是什么?

+0

在默认magento中,公司不是必填字段。你是否将它定制为必填字段? –

+0

您可以尝试在“系统/配置/客户配置”中编辑“地址模板”。 –

回答

1

我今天加入了一些Magento商店,看到这个老问题,也许我的回答会帮助别人。这只会回答你如何将公司名称添加到订单网格中。为此,您需要扩展Mage_Adminhtml_Block_Sales_Order_Grid类。然后重写_prepareCollection和_prepareColumns函数。此代码基于this free extension

protected function _prepareCollection() 
{ 
    $collection = Mage::getResourceModel($this->_getCollectionClass()); 

    $tableName = Mage::getSingleton("core/resource")->getTableName('sales_flat_order_address');     
    $collection->getSelect()->join($tableName, "main_table.entity_id = $tableName.parent_id AND $tableName.address_type='billing'",array('company')); 
    $this->setCollection($collection);    
    return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection(); 
} 

protected function _prepareColumns() 
{ 
    $this->addColumnAfter('company', array(
     'header' => Mage::helper('customer')->__('Company'), 
     'index'  => 'company' 
    ),'billing_name'); 

    return parent::_prepareColumns(); 
} 
相关问题