2014-02-07 53 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(); 
} 
相關問題