Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution for Magento mass actions and large number of records problem?

Tags:

magento

Currently Magento has a problem with the way it handles mass actions. It returns a bit of JS that contains EVERY db id for the current collection and filter, regardless of pagination. This is to support the 'Select All' vs. 'Select All Visible' option in the grid header. This isn't such a problem when you have a smaller number of records, but if you have 850k records (orders in this case) it becomes a serious problem.

My question is, does anyone have an elegant solution to this problem?

I can think of several solutions, each with its own drawbacks, but I'm hoping someone has solved this in a simple manner that works as an add-on module. Paid or Open-Source solutions are both welcome suggestions.

Clarification:

I'm looking for an elegant/drop-in solution to the problem of 850k+ records using the grid widget in Magento. The stock Magento code makes the bone headed decision to return the id for every record that is matched by the current filter, even if they are not being displayed. This is not about offline processing of records, it's about using the grid widget for daily admin tasks.

One possible solution would be to store the results of the filtered search in a temp table and return a reference to the search result. Then you could change it from using the actual ids on a 'Select All' to using a specific callback for the action using the reference. This would preserve the current behavior.

So, to ask again, does anyone have a good solution to this already created?

like image 294
Lee Saferite Avatar asked Mar 24 '11 09:03

Lee Saferite


2 Answers

I'm running heavy operations from within a shell script. I have a generic iterator (in my case products, but can be done with everything else), and I only implement a class that does the action on the product. My product_iterator shell script takes care of looping over the products, while processing only x products at once (to avoid memory leaks).

like image 88
fbrnc Avatar answered Oct 24 '22 04:10

fbrnc


Well, the least invasive solution to the problem is to turn off the 'Select All' option for grids with large numbers of records. This is easily accomplished by extending the grid class and adding the following code:

protected function _prepareMassaction()
{
    $this->getMassactionBlock()->setUseSelectAll(false);
    return parent::_prepareMassaction();
}
like image 5
Lee Saferite Avatar answered Oct 24 '22 04:10

Lee Saferite