-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix: 4741 catalog variant inventory flags always false #4742
fix: 4741 catalog variant inventory flags always false #4742
Conversation
…b.com:reactioncommerce/reaction into fix-4741-mikemurray-catalog-variant-inventory
@mikemurray A bigger picture question. Why store these in the catalog at all given how dynamic they are and the fact that the source-of-truth inventory values are stored on Product and are not published? Can we just look them up in the |
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.
@mikemurray I tested several variant/option combinations and I feel like the isSoldout, isLowQuantity
logic is correct and working as expected.
One combination that I felt a little unclear about is when a variant has a warning threshold of 1000 and multiple options. If option "A" has a quantity of 1 while option "B" has a quantity of 2000 both option "A" and the variant will have isLowQuantity: true
. Is that the intended outcome in that situation? It makes sense for the variant to have isLowQuanitity: true
but I could also see it being false
just want to verify.
@aldeed I agree it feels weird for the inventory values to be published to the catalog, but the only time they are/should be published is when there's a change. For example, a product is only sold out when it reaches 0 on all variants/options. Making a resolver is a good idea, but we'll have to make a request to the products collection on every request for a product and its variants, which defeats the purpose of the catalog collection being a sort of cache for product data. |
@aldeed To add... If we stored the inventory quantities in a better place, perhaps in a separate collection away from the products, then that could help with performance if we are requesting inventory status for products on a grid. Doing an extra fetch for variants for the PDP page is less of an issue. |
…1-mikemurray-catalog-variant-inventory
The function |
@nnnnat Pushed some changes Additional testing would include:
Should be ready for your review. |
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.
👍 was able to test and everything looks good data wise. @mikemurray if you can resolve the conflicts I'll merge.
I believe one thing that may need addressing is the customer PDP is still using Product
collection and not Catalog
, but I think that should be another issue/PR.
…b.com:reactioncommerce/reaction into fix-4741-mikemurray-catalog-variant-inventory
@nnnnat There is code in the server publication function that publishes This PR has some failing tests that will need to be fixed before it can be merged. |
@nnnnat All tests are passing now. |
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.
Reapproved! Thanks @mikemurray
Resolves #4741
Impact: major
Type: bugfix
Issue
isSoldOut
andisLowQuantity
for variants and options in the catalog were alwaysfalse
, and not reflective of their actual status.Solution
Fix the transform that creates the catalog variants by processing the correct inventory flags just like it's done for the top-level product
Breaking changes
Added a new, final param to
xformVariant
with the processed inventory flagsTesting
Try to set the quantities and warn at thresholds to various variants and options and check the DB or GQL for the expected results.
For example:
Play around with different combinations of sold out, low inventory and back ordered
Below are some variations
isSoldOut
istrue
isLowQuantity
istrue
isSoldOut
istrue
isSoldOut
istrue
for the option itselfisLowQuantity
istrue
for the option itselfwarn at
at 10Test the Migrations
mongorestore --drop
thereaction-2.0.0-rc.1
mongo dumpisSoldOut
arefalse
. This is incorrect.isSoldOut
are nowtrue