skip to Main Content

I’m getting memory exhaustion error when executing mass action on a model with large amount of records. I’m trying to optimize this by setting an limit on the collection, however it seems that the full collection is loaded before the limit is even set. Here’s the code that causes the memory exhaustion:

$collection = $this->filter->getCollection($this->collectionFactory->create())->setPageSize(1)->setCurPage(1);

It’s inside mass action’s controller execute method.

edit: So I guess MagentoUiComponentMassAction::getFilterIds() is at fault as it generates all selected ids inside an array, to later execute sql in statement to filter which model rows need to be used. Not sure if I even can fix it.

2

Answers


  1. Chosen as BEST ANSWER

    So apperently, the issue was inside MagentoUiComponentMassAction::getCollection() that is called inside the filter->getCollection() method. The Id retrievieng method has two options - either rely on dataprovider to get the selected ids, which is the optimized option or go trough each item and add it's id to an array. The problem was that we were not using the first option, for which our modules UI component's dataprovider needed to extend MagentoUiDataProviderAbstractDataProvider.


  2. $collection = $this->filter->getCollection($this->collectionFactory->create()->setPageSize(1)->setCurPage(1));
    

    move the limitation of the page right after creating the collection.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search