prevent tagging existing products when first seen by task #297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update was suggested by a merchant who noted that when the bulk scan task runs for the first time, the task will tag all existing products that were already in stock.
To prevent this, a "first seen" timestamp metafield value is now added to a product when it is first encountered by the task (in any run mode). New logic was added to prevent adding tags to products unless their "first seen" date is older than their "back in stock" date.
That logic however would prevent newly created products from being tagged, so on product creation events only, the "first seen" metafield value is set to the product creation date. This allows the first back in stock timestamp set on the new product to always be newer, and thus the product would be tagged.