medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26.25k stars 2.67k forks source link

(js-sdk): Product variant inventory quantity isn't returned even if he has stock + manage inventory enabled #9857

Open Ketlark opened 1 month ago

Ketlark commented 1 month ago

Bug report

Describe the bug

I tried to get stock for a product variant using the js-sdk, but the field inventory_quantity of variant object is never returned (even if the manage_inventory is set to true according to documentation)

None of sdk methods return it, whether it's fetch or list product

System information

Medusa version (including plugins): 2.0.1 Node.js version: 20 Database: PostgreSQL Operating system: linux

Steps to reproduce the behavior

  1. Create a product and a variant
  2. Add inventory stock for it
  3. Try to fetch the product and variants from js-sdk
  4. See that field inventory_quantity isn't returned

Expected behavior

inventory_quantity should be returned inside the variant object

Code snippets

 this.medusaClient.admin.product.list({
        limit: productToListModel.limit ?? 50,
        offset: productToListModel.nextKey as number,
        fields: '*categories,*variants',
      }),
Ketlark commented 2 weeks ago

@olivermrbl Still nothing ? i saw many PR but rarely fix or priority over bug reported by community