Description
Preconditions and environment
- 2.3.x, 2.4.x
- Any PWA that targets the magento instance using graphql
Steps to reproduce
The problem that we're trying to solve is that we can't get the original behavior of magento with out of stock products.
- Magento needs to be set up to "Do not display out of stock products" in the catalog storefront.
- We need at least one enabled but out of stock product
The existing behavior of magento is that this product won't be visible in collections, but it will be visible on the product page if you access it by a direct URL.
On the PWA using graphql we can only use the products
query in conjunction with the urlResolver
.
When a user access the direct URL, we use urlResolver
to fetch the product ID successfully e.g.
{
"data": {
"urlResolver": {
"canonical_url": "catalog/product/view/id/13869",
"relative_url": "catalog/product/view/id/13869",
"id": 13869,
"type": "PRODUCT"
}
}
}
When we try to fetch the product from the products query with the id it's not fetching it because in the underlying code, a collection is loaded which automatically is flagged to remove out of stock products.
Thus the product cannot be displayed resulting in 404.
This problem is very important for SEO
We need a way to replicate the original behavior of magento to fetch the product data by it's ID via graphQL and then display it as out of stock.
Expected result
The product is fetched by the graphql query by it's ID
Actual result
The product is filtered out because it's out of stock.
Additional information
Keep in mind, we don't want to show all out of stock products everywhere, we just need to retain the functionality of showing the product when it's hit by an indexed direct URL in Google.
IF there's any workaround, could you inform us what it is or what we're doing wrong?
I don't see a path to replicating this functionality currently.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.