-
Notifications
You must be signed in to change notification settings - Fork 115
Export fixes #182
base: 1.0.0-wip
Are you sure you want to change the base?
Export fixes #182
Conversation
mwgamble
commented
May 20, 2015
- Fix issue with exporting more than 1000 items in a grid at one time. If you attempted to export more than one page worth of results for a grid whose collection modifies the select object to add new column correlations in the _beforeLoad() method, you would get an error because it would attempt to create the correlation on every page iteration of the export process.
- Fix issue with exporting any number of items. You would always get one more than you asked for.
- Fix general issues with Transactions grid due to it not resetting the collection object when preparing the collection for a 2nd time.
Thanks for the fixes to the transactions grids ! Regarding the number of exported items, I get the opposite behaviour : the exported count is correct when using |
My apologies, there was indeed a bug in our code. We had inadvertently moved the |
PHP object cloning is shallow. Therefore, any objects owned by the cloned object are also owned by the original object, because it's all passed around by reference. This means that if the select object is modified after the clone, this will still affect the original collection's select object. This creates problems when you have collections that modify the select object in the _beforeLoad() method. We encountered issues when exporting the Sales Transactions grid, where it would complain that it had already added a column name correlation whenever it reached the 2nd page when exporting a collection. This was happening because it was using the same shared select object from the original collection. To get around this, we now clone the original select object, and manually set it on the cloned collection on each iteration of the loop, using reflection to do so. This appears to work fine for all grids, and is a general improvement. It is worth noting that this exact issue is probably why Magento never made exporting possible on some grids, such as the Sales Transactions grid.
The extension relies on the fact that a new collection object is created during the second call to _prepareCollection(). This doesn't happen with the transactions grid, because it always first looks to see if there is a collection already set. It does this because there is a subclass which also creates a collection, and utilises this class to do most of the work. We don't need this for the main transactions grid, so we unset the collection before calling _prepareCollection() for the 2nd time. This makes everything work a lot more nicely.
1023f71
to
4812ef5
Compare
Hi, I just wanted to let you know that I've rebased this branch on top of the latest commits from the 1.0.0-wip branch to resolve the merge conflicts that were there. You should be able to safely merge it in now. |