Skip to content
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: improve product availability check in algoliaLocalizedProduct.js #217

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

htuzel
Copy link
Collaborator

@htuzel htuzel commented Jan 7, 2025

What is Changed?

Updated the in_stock handler to utilize the ProductAvailabilityModel for better accuracy in determining product availability. The logic now checks the availability status directly for master products and variation groups, and retrieves the inventory record for other products to assess stock levels against the defined threshold.

Important Note

Note: Should be changed:

in_stock: {
    localized: false,
    variantAttribute: true,
}

to:

in_stock: {
    localized: false,
}

To update in_stock partially and move it to the record level.

Doc link is here: https://github.com/algolia/doc/pull/9652

htuzel added 2 commits January 7, 2025 17:18
Updated the in_stock handler to utilize the ProductAvailabilityModel for better accuracy in determining product availability. The logic now checks the availability status directly for master products and variation groups, and retrieves the inventory record for other products to assess stock levels against the defined threshold.
@htuzel htuzel self-assigned this Jan 14, 2025
Copy link
Collaborator

@sbellone sbellone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is ok but I don't understand the use case. In the doc update, you write:

to update only stock and price attributes for each variant, move the in_stock and price attributes to the record level

But what do you plan to do with this information? Currently, we could improve the UI to only display variants that are in stock. With the info moved at the product-level, we will have to show all variants, even if they are out-of-stock.

Was there a request for this change?

@htuzel
Copy link
Collaborator Author

htuzel commented Jan 16, 2025

The change is ok but I don't understand the use case. In the doc update, you write:

to update only stock and price attributes for each variant, move the in_stock and price attributes to the record level

But what do you plan to do with this information? Currently, we could improve the UI to only display variants that are in stock. With the info moved at the product-level, we will have to show all variants, even if they are out-of-stock.

Was there a request for this change?

Some clients who are using the base record model are keeping the in_stock attribute on the first level (not in variants), and they want to be able to update the in_stock attribute. I opened this ticket by discussing this with @matthias-meier-algolia a long time ago.

@htuzel htuzel requested a review from sbellone January 16, 2025 15:01
@htuzel htuzel merged commit 1fb2093 into develop Jan 17, 2025
5 checks passed
@htuzel htuzel deleted the feature/SFCC-334 branch January 17, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants