2013-01-21 4 views
2

고객의 우편 번호/우편 번호를 표시하는 주문 그리드를 얻으려고합니다.Magento - Magento 1.6.2에서 주문 그리드에 우편 번호/우편 번호 추가

sales_flat_order_address 별칭을 컬렉션과 결합하려고했지만 성공하지 못했습니다.

protected function _prepareCollection() { 
    $collection = Mage::getResourceModel($this->_getCollectionClass()); 
    $collection->getSelect()->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id',array('postcode')); 
    //var_dump($collection); 
    $this->setCollection($collection); 
    return parent::_prepareCollection(); 
} 

아무에게도 해결책을 찾아 주실 수 있습니까?

답변

2

반환하기 전에 parent :: _ prepareCollection(); 당신은 만들어야합니다 가입 : 대신 배송 우편 번호를 원하는 경우

$collection->getSelect()->joinLeft(array('billing'=>'sales_flat_order_address'), 
    'main_table.entity_id = billing.parent_id AND billing.address_type="billing"',array('billing.postcode AS bp')); 

는 사용 :

$collection->getSelect()->joinLeft(array('shipping'=>'sales_flat_order_address'), 
    'main_table.entity_id = shipping.parent_id AND shipping.address_type="shipping"',array('shipping.postcode AS sp')); 

그리고 메소드 _prepareColumns에 붙여 : A의 나를 위해 일한

$this->addColumn('bp', array(
     'header' => Mage::helper('sales')->__('Billing Postcode'), 
     'index' => 'bp', 
     'width' => '60px', 
     'filter_index' => 'billing.postcode' 
    )); 

최근 프로젝트

+0

고맙게도이 기능은 완벽하게 작동했습니다. – user1997432

관련 문제