wayfair-contribs / plentymarkets-plugin

Wayfair plugin for use in the Plentymarkets eCommerce ERP system
https://marketplace.plentymarkets.com/en/plugins/integration/wayfair_6273
Other
4 stars 3 forks source link

Use time filters only for stock CHANGE detection - do not filter out Warehouses from inventory sync #195

Closed jhoule86 closed 3 years ago

jhoule86 commented 3 years ago

Fixes https://github.com/wayfair-contribs/plentymarkets-plugin/issues/194

The updatedAtFrom and updatedAtTwo filters are currently applied to the StockRepositoryContract used for calculating inventory amounts for periodic inventory synchronizations, causing the Wayfair plugin to send the inventory amount(s) only for the Warehouse(s) that changed. If only one warehouse had a change for the item, the item will go out of stock until the next change in stock!

The Wayfair plugin should be sending an up-to-date calculation of ALL inventory for the item, in ALL Warehouses where it appears. The timestamp filters should only be used to detect if the stock amounts for the Variation has experienced any changes.

This PR introduces a hasInventoryChanged helper function which uses its own StockRepositoryContract to check if there is at least one stock change for the Variation. It is invoked only if either (or both) of the timestamp filters are set. If the filters are set and no stock changes are present, inventory calculation for the Variation in view is cancelled, and the Variation is not included in the periodic inventory synchronization.