0
votes

I wrote my own Magento function which calculates the percentage relation of orders to retours. In this way you can categorize customers into those, who never give bought things back (green - good customers), who sometimes make retours (yellow) and those ones, who return most of bought things (red - bad customers).

For this, I added a new db table which saves required information.

Now, I would like to add a new column in Magento's admin Customers->Manage customers which shows the appropriate color. I managed to add the header of the new column, but I have no clue how to show my custom calculations from my custom db table. Magento makes everything so complicated.

I edited the "app/code/core/Mage/Adminhtml/Block/Customer/Grid.php" and added the following code into the "prepareColumns":


    $this->addColumn('abc', array(
      'header' => "ABC"
    ));

So, how do I fill it with any data?

I appreciate any help.

2

2 Answers

1
votes

The very simplest solution is to edit the prepareCollection function in the same class, and join your table to the results set. Then you simply have to set the correct index in your addColumn definition and the column should be populated.

Ideally of course you shouldn't be editing the core files, a slightly better option would be to instead rewrite the class, or you could go the whole hog and do it with events.

0
votes

So do you maybe know how do to this? What do all the parameters exactly mean?:


    ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')

Please give me any piece of advice. Let's say, I would just make a raw SQL query for each customer, make some calculations and put it out. I only need the customer's id to do this.