0

I've a custom Model, with user_entity_id on database (it's creator of object). But I need to display customer name on admin grid (not customer ID) - an on other place.

Think I need to add some code on _beforeLoad function of my custom Collection, but don't find wich code can do this..

Do you have an idea ?

Thanks in advance

0

You'll actually want to use afterLoad as you'll need access to the data you've loaded. This will add the customer name into your model:

/**
 * Load customer and add in the customer name to the mode
 */
public function afterLoad() {
    $_customer = Mage::getModel('customer/customer')->load($this->getUserEntityId());
    if($_customer && $_customer->getId()) {
        $this->setCustomerName($_customer->getName());
    }
}

You can then add a new column to your grid called customer_name.

Alternatively you could add a grid renderer for this column but it seems like having the customer name stored in the model could be more beneficial for you.

  • Thanks for reply. afterLoad seems to not works on model. When paste on collection (_afterLoad), error display explain getUserEntityId doesn't exist. Thinks your right, I'll add customer name on my model. Seems to have better performance.. I also try to do getSelect()->join, but not find good information to put on.. Thanks Dave – magexcustomer Jul 13 '14 at 14:29

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.