1

I am using the Gridcontrol to add/remove new columns.

This is my XML:

<sales_order_grid>
.....
<customer_increment_id>
    <add>
        <header>Customer ID</header>
        <type>text</type>
        <index>customer_increment_id</index>
        <join table="customer/entity" condition="main_table.customer_id={{table}}.entity_id" field="increment_id as customer_increment_id"/>
     </add>
     <after>scheduled_at</after>
</customer_increment_id>
.....
</sales_order_grid>

This is the query generated:

SELECT `main_table`.*, `customer/entity`.`increment_id` AS 

`customer_increment_id` FROM `sales_flat_order_grid` AS `main_table`

INNER JOIN `customer_entity` AS `customer/entity`

ON main_table.customer_id=`customer/entity`.entity_id

The query returns me values. I want to get the customer_increment_id, but for some reason I m getting empty results in my grid for this column. Why?

2

Due to the fact that I cannot add an alias to my join from XML. I came with the idea to add a renderer, like:

 <customer_increment_id>
         <add>
            <header>Customer ID</header>
            <type>text</type>  
            <renderer>Mynamespace_Mymodule_Block_Adminhtml_Sales_Order_Renderer_Customers</renderer>
         </add>
         <after>scheduled_at</after>
    </customer_increment_id>

and this is my block:

class Mynamespace_Mymodule_Block_Adminhtml_Sales_Order_Renderer_Customers extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{

    public function render(Varien_Object $row)
    {
        $customerId = $row->getData('customer_id');
        $customer = Mage::getModel('customer/customer')->load($customerId);
        return $customer->getData('increment_id');
    }
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.