I want to add custom product attribute to sales order grid, and here is my code below,

$collection = Mage::getResourceModel($this->_getCollectionClass())
$vendor1_total = Mage::getResourceModel('catalog/product')->getAttribute('vendor1_total');
            ->join(array('ce1' => 'catalog_product_entity_varchar'), 'ce1.entity_id=main_table.product_id', array('vendor1_total' => 'value'))
            ->where('ce1.attribute_id=' . $vendor1_total->getAttributeId())

            ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`"));

and Im getting Unknown column error, and query is,

SELECT COUNT(*) FROM `sales_flat_order_grid` AS `main_table`
 INNER JOIN `sales_flat_order_address` AS `soas` ON soas.parent_id=main_table.entity_id and soas.address_type = "shipping"
 INNER JOIN `sales_flat_order_item` AS `sales/order_item` ON `sales/order_item`.order_id=`main_table`.entity_id
 INNER JOIN `catalog_product_entity_varchar` AS `ce1` ON ce1.entity_id=sales_flat_order_item.product_id
 LEFT JOIN `sales_flat_order` AS `order` ON order.entity_id=main_table.entity_id

Of course the error is correct, there is no column name of product_id in sales_flat_order_grid . But I tried to replace the table name - main_table with sales_flat_order_item where the column is exist. But still its taking old table main_table - sales_flat_order_grid. So I want to changes this main_table to sales_flat_order_item (If it will not affect other parts) or how to use this table sales_flat_order_item to fetch my column into grid. Please help me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.