In Magento, how do I populate a new column in sales_order_grid with data from sales_flat_order?

后端 未结 1 1820
有刺的猬
有刺的猬 2021-01-18 15:32

I am following Ivan\'s tutorial (Adding order attribute to the orders grid in Magento 1.4.1) to add an extra column to the sales_order_grid table (the Shipping Description t

1条回答
  •  盖世英雄少女心
    2021-01-18 16:09

    this should work:

    $select = $this->getConnection()->select();
    $select->join(
        array('order_shipping'=>$this->getTable('sales/order')),//alias=>table_name
        $this->getConnection()->quoteInto(
            'order_shipping.entity_id = order_grid.entity_id',
            Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
        ),//join clause
        array('shipping_description' => 'shipping_description')//fields to get
    );
    $this->getConnection()->query(
        $select->crossUpdateFromSelect(
            array('order_grid' => $this->getTable('sales/order_grid'))
        )
    );
    

    If you want, take a look at my extension :)
    HTH

    0 讨论(0)
提交回复
热议问题