Skip to content

[Bug]: Storefront sdk.store.product.list() returns count including products from other sales channels #14362

@jalagania

Description

@jalagania

Package.json file

{
  "name": "name",
  "version": "0.0.1",
  "author": "author",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@google-cloud/storage": "^7.15.1",
    "@imgproxy/imgproxy-node": "^1.1.0",
    "@medusajs/admin-sdk": "^2.12.3",
    "@medusajs/cli": "^2.12.3",
    "@medusajs/framework": "^2.12.3",
    "@medusajs/index": "^2.12.3",
    "@medusajs/medusa": "^2.12.3",
    "@react-email/components": "0.0.33",
    "@sentry/cli": "^2.43.0",
    "@sentry/node": "^9.11.0",
    "@sentry/profiling-node": "^9.11.0",
    "add": "^2.0.6",
    "bwip-js": "^4.6.0",
    "cors": "^2.8.5",
    "dayjs": "^1.11.18",
    "exceljs": "^4.4.0",
    "i18n-js": "^4.5.1",
    "jwt-decode": "^4.0.0",
    "mime-types": "^2.1.35",
    "multer": "^2.0.2",
    "posthog-node": "^5.5.0",
    "qrcode": "^1.5.4",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-is": "^18.3.1",
    "yarn": "^1.22.22",
    "zod": "3.22.4",
    "zustand": "^5.0.5"
  },
  "devDependencies": {
    "@medusajs/test-utils": "^2.12.3",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/cors": "^2.8.17",
    "@types/jest": "^29.5.13",
    "@types/mime-types": "^2.1.4",
    "@types/multer": "^2.0.0",
    "@types/node": "^20.0.0",
    "@types/qrcode": "^1.5.5",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prettier": "^3.6.2",
    "prop-types": "^15.8.1",
    "react-email": "3.0.7",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.6.2",
    "vite": "^5.2.11"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

v22

Database and its version

PostgreSQL

Operating system name and version

Mac OS

Browser name

No response

What happended?

When calling the Storefront JS SDK method:
const { products, count } = await sdk.store.product.list()
the products array appears correctly scoped to the sales channels associated with the publishable API key, but the count value seems to include products from other sales channels as well

Expected behavior

From the docs, both products and count should be scoped the same way to the sales channels inferred from the publishable API key.

sdk.store.product.list() should return:
products: list of products available in the sales channels associated with the publishable API key.
count: total number of products matching the same filters and sales-channel scope as products.

Actual behavior

products array appears correctly scoped to the sales channels associated with the publishable API key, but the count value seems to include products from other sales channels as well

so:

products.length = number of products in the current sales channel(s)
count = total number of products across more channels than the current key is scoped to

Link to reproduction repo

Just log count variable to the console and compare it with the total amount of products

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions