3

I want to know what is this function functionality in admin grid.

protected function _afterLoadCollection()
{
    $this->getCollection()->walk('afterLoad');
    parent::_afterLoadCollection();
}

2 Answers 2

5

_afterLoadCollection is called automatically in the grid block.
It gives you an additional callback for the grid collection.
$this->getCollection()->walk('afterLoad'); calls afterLoad method for each item in the collection.

Usually, this afterLoad method is called when calling load on an object but not on a collection.
This code forces the afterLoad call for each item even if we are not calling load on each of them.

0
2

It call afterLoad method on each object from collection class which is similar as below

foreach($collection as $_object) {
     $_object->afterLoad();
}

as Marius said Usually, this afterLoad method is called when calling load on an object but not on a collection. This code forces the afterLoad call for each item even if we are not calling load on each of them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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