-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CHG] review product aggregation by backend to improve performance #9
Conversation
for backend in self.mapped('backend_id'): | ||
self._recompute_magento_qty_backend( | ||
backend, self.filtered( | ||
lambda x: x.backend_id.id == backend.id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then if you have more than 1 backend, each binding will be iterated N times + 1 where N is the number of backend (1 loop for filtered
on each backend + 1 loop for mapped
to obtain the backends). In the best case when you have 1 backend, you still loop 2 times on the records.
If the recordset's |=
is a concern (I didn't know it was particularly slow), then I would use a simple set in a dictionary and rebrowse afterwards:
backends = defaultdict(set)
for product in self:
backends[product.backend_id].add(product.id)
for backend, product_ids in backends.iteritems():
self._recompute_magento_qty_backend(backend, self.browse(product_ids))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but itering on a recordset is quicker than creating a new big one.
I have more than 26.000 products binded. The original code took more than 15 minutes to complete the dictionnary.
This version takes only 6 secondes ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good to know that updating a recordset is so slow...it's What about the version I propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version you propose is good, just a few second to proceed. :-)
800372e
to
8989e07
Compare
@guewen I updated my PR with your suggestion. |
Thanks! |
@@ -108,12 +108,13 @@ def recompute_magento_qty(self): | |||
informations for each product. | |||
""" | |||
# group products by backend | |||
backends = defaultdict(self.browse) | |||
backends = defaultdict(set) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guewen If you want to squeeze some more perfs out of this, make this defaultdict(list)
and:
- on line 113 use append instead of add
- on line 117 below use
self.browse(set(product_ids))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually no.
The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9 (cherry picked from commit 5d617fd)
The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9 (cherry picked from commit 5d617fd)
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
* [FIX] Fix export when no location has flag prestashop_synchronized When there is no location with the flag prestashop_synchronized in the location tree, Current behavior: The `location` key in the context is empty then the qty_available is computed for *every* locations/warehouses. Expected behavior: If there is at least one location flagged, use it, otherwise, use all the locations of the tree, starting from the selected location or selected warehouse location. When no location can be found (for instance because user selected a location with a usage different than 'internal'), then it should just fail and not return the stock of all warehouses. Being able to synchronize without activating 'prestashop_synchronized' is important: when used, this feature will trigger an export every time a quant is changed or created, on a large catalog, we might prefer only using the cron to have less frequent updates and less jobs. A second fix is that when a stock_location_id is set on the backend, it should be used, it was only used for the import of stock. * [FIX] Exclude children from qty computation We already pass the children in 'location', if we don't disable 'compute_child', the qty computation will try to get the children of each child and generates query of 1mio chars. * [IMP] Group computation of qty_available Stats with 6700 products: Before: 570s After: 28s * [FIX] Apply filter on locations for variants quantities It was only applied on export of template quantities. * [IMP] Improve performance on prestashop qty recompute The add/union operation between recordsets is slow, aggregate the ids in a set and call the browse only once on the complete set is dramatically faster. See guewen/connector-magento#9
I skipped the usage of a dictionnary because the |= on a big recordset is really slow and not very usefull.
What do you htink ?