#Trying to include categories inside product retrieve function doesn't work

3 messages · Page 1 of 1 (latest)

oak schooner
#

I am trying to include categories of the product when I fetch one, currently I do it like this:

        const { product } = await medusa.store.product.retrieve(id, {
            region_id: activeRegion?.id,
            fields: `*variants.calculated_price,+variants.inventory_quantity`,
        });

it works nicely

but when I add categories
like so:

        const { product } = await medusa.store.product.retrieve(id, {
            region_id: activeRegion?.id,
            fields: `*variants.calculated_price,+variants.inventory_quantity,categories`,
        });

I am getting error, Error: Product with id: prod_01JVS2GB9RKGXXFG1RC3HR2AKF was not found.
Why?? The ID is the damned same it shouldn't fail to fetch it so what is the issue here?

I tried setting it as both +categories and *categories but nothing same issue

#

Okay i think i found what the issue is... it appears that when u dont have a category set for a product it will give this error, but why would it return this error instead of something like "no category found" or at least give an empty categories array

oak schooner
#

should i open an issue on github?