简体   繁体   中英

Add custom customer address attribute in sales order grid collection in magento

Hi I want to show some custom customer address attribute in sales order grid.

How to achieve that ?

below is my Collection. I have successfully added table fields from another table but unable to add attributes from customer/address

protected function _prepareCollection()
{
            $collection = Mage::getResourceModel('sales/order_grid_collection');
            $collection->getSelect()->joinLeft(array('sfoa'=>'sales_flat_order_address'),
                    'main_table.entity_id = sfoa.parent_id AND sfoa.address_type="shipping"',array('sfoa.street', 'sfoa.city','sfoa.company','sfoa.customer_address_id'));


            $collection->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
            ->setIsCustomerMode(true);


    Mage::log($collection);
    $this->setCollection($collection);

    return parent::_prepareCollection();
}

Thanks guys.

Anurag Patbandha

According to your code ,you can only add fields of sales_flat_order_address . If you want to add customer address attribute to order grid then you need join to customer/address collection with it on default shipping or billing address

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM