Fetch the Product of Shopware 6

538 Views Asked by At

I am using this endpoint (http://localhost/store-api/product/{productId}) to fetch the specific product. But when I send the request it returns the best variant product. I want the main products, not the variant product how can I fetch that?

API reference

I tried to this by passing product id, parentproduct id in the place of productID in the endpoint but I am unable to get the main product with different varriant.

https://i.stack.imgur.com/wPYMG.png

1

There are 1 best solutions below

5
On BEST ANSWER

You can't retrieve the parent product record via the store-api, as it is not a purchasable item.

The parent merely acts as glue for the variants which are the actual goods. Furthermore it exists as a means to allow the variants to possibly inherit one and the same value. The parent passing on its values as inheritance is also the reason why it should not be accessed directly.

If the parent record would be made available to fetch via the store-api, it could lead to faulty purchases, that's why it will always return a variant instead.

You may use the admin-api if you must retrieve the raw data of the parent.