This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clone a collection's select object when cloning the collection
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.
- Loading branch information