-
Notifications
You must be signed in to change notification settings - Fork 7
fix: [SFCC-471] Changed the default value of Algolia_InStockThreshold to 1, additional related fixes #246
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
Conversation
9e880c4 to
9474268
Compare
sbellone
left a comment
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.
Thanks 👍
There is a lint issue to fix, and please target develop as this is an independent fix.
| let inStock = productFilter.isInStock(product, ALGOLIA_IN_STOCK_THRESHOLD); | ||
|
|
||
| if (!inStock && !INDEX_OUT_OF_STOCK) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return inStock; |
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.
| let inStock = productFilter.isInStock(product, ALGOLIA_IN_STOCK_THRESHOLD); | |
| if (!inStock && !INDEX_OUT_OF_STOCK) { | |
| return undefined; | |
| } | |
| return inStock; | |
| return productFilter.isInStock(product, ALGOLIA_IN_STOCK_THRESHOLD); |
73ffb11 to
3a8c8d0
Compare
…nal in_stock checks, made comments and descriptions more precise
e18c67c to
84c1121
Compare
82599d1 to
dbd88dc
Compare
|
Closing pull request, re-opened in #248, pointing to develop |
Issue description
Setting the value of the Algolia_InStockThreshold site preference to 0 (the current default) breaks
in_stockcalculation.The default value was changed from no value to 0 in #110 .
When setting up a new cartridge installation, a default value of 0 leads to all products always returning
in_stock == true.Context: SFCC didn’t require a default to be set before – the code treated leaving it empty as if there was no limit set and handled it correctly (i.e. didn’t take the value of this preference into account at all, falling back to the expected behavior of “treat a product as in-stock if it has at least 1 product in stock”).
The documentation shows this value as set to 1, which results in correct behavior.
#110 introduced an explicit 0 as the default value of this preference, which leads to problems due to the code returning
in_stock === trueif the product has at least 0 products in stock, so it always returns true for all products, which is erroneous behavior. Existing cartridge installations where there was no default value set should not encounter problems, but new installations will as all products will always returnin_stock === true. To solve this, the logic was changed so that an ATS of 0 will never returntrue, no matter what value theAlgolia_InStockThresholdpreference is set to. This also guards against user error as the user can set 0 as theInStockThreshold, even if that’s not the default.Changes in this PR
Algolia_InStockThresholdto 1 so new installations will now set this valueisInStock()inproductFilter.jsnow returnstrueonly ifATS > 0isInStock()method didn't previously return anything, fixedisInStoreStock()inproductFilter.jsnow returnstrueonly ifATS > 0isCustomVariationGroupInStock()inproductFilter.jsnow returnstrueonly ifATS > 0storeAvailability()inalgoliaLocalizedProduct.jsnow returnstrueonly ifATS > 0productFilterConfig.example.jsnow shows the correct default of 1Algolia_InStockThresholdsite preference more explicit