Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

fix(store): list products with an empty product_seller allowlist (#1292)

Viktor Holik564c7bacc1de
diff --git a/integration-tests/http/product/store/product.spec.ts b/integration-tests/http/product/store/product.spec.ts
index 824878565..9bd1c25f4 100644
--- a/integration-tests/http/product/store/product.spec.ts
+++ b/integration-tests/http/product/store/product.spec.ts
@@ -85,10 +85,11 @@ medusaIntegrationTestRunner({
)
})
- // Products are master records: creation no longer links a seller.
- // A product only appears in the store when it is assigned to a
- // seller via the `product_seller` restriction link, so the test
- // assigns each created product to the seller whose headers made it.
+ // Products are master records. The `product_seller` allowlist is
+ // opt-in (empty = open to every seller), so it no longer gates
+ // store visibility; the store lists any published product. The
+ // helper still assigns each product to the seller whose headers
+ // created it to mirror how vendors submit against a master product.
const createProduct = async (
headers: any,
overrides: Record<string, any> = {}
@@ -166,7 +167,10 @@ medusaIntegrationTestRunner({
expect(ids).not.toContain(draftProduct.id)
})
- it("should not return products from suspended sellers", async () => {
+ // The `product_seller` allowlist is opt-in and no longer gates
+ // store visibility, so a published product stays listed even
+ // when its assigned seller is suspended.
+ it("should still list published products from suspended sellers", async () => {
const product = await createProduct(
suspendedSellerHeaders,
{ title: "Suspended Seller Product" }
@@ -184,10 +188,10 @@ medusaIntegrationTestRunner({
)
const ids = response.data.products.map((p: any) => p.id)
- expect(ids).not.toContain(product.id)
+ expect(ids).toContain(product.id)
})
- it("should not return products from sellers within closure window", async () => {
+ it("should still list published products from sellers within a closure window", async () => {
const product = await createProduct(approvedSellerHeaders, {
title: "Closed Seller Product",
})
@@ -215,7 +219,7 @@ medusaIntegrationTestRunner({
)
const ids = response.data.products.map((p: any) => p.id)
- expect(ids).not.toContain(product.id)
+ expect(ids).toContain(product.id)
})
it("should filter products by id", async () => {
@@ -412,7 +416,9 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(404)
})
- it("should return 404 for a product from a suspended seller", async () => {
+ // Suspending the assigned seller no longer hides a published
+ // product from the store detail route.
+ it("should still retrieve a published product from a suspended seller", async () => {
const product = await createProduct(
suspendedSellerHeaders,
{ title: "Suspended Seller Product" }
@@ -424,11 +430,13 @@ medusaIntegrationTestRunner({
adminHeaders
)
- const response = await api
- .get(`/store/products/${product.id}`, storeHeaders)
- .catch((e) => e.response)
+ const response = await api.get(
+ `/store/products/${product.id}`,
+ storeHeaders
+ )
- expect(response.status).toEqual(404)
+ expect(response.status).toEqual(200)
+ expect(response.data.product.id).toEqual(product.id)
})
})
})
diff --git a/packages/core/src/api/store/products/middlewares.ts b/packages/core/src/api/store/products/middlewares.ts
index 5be1f39cb..64a060f1f 100644
--- a/packages/core/src/api/store/products/middlewares.ts
+++ b/packages/core/src/api/store/products/middlewares.ts
@@ -1,7 +1,6 @@
import {
applyDefaultFilters,
authenticate,
- maybeApplyLinkFilter,
MedusaNextFunction,
MedusaRequest,
MedusaResponse,
@@ -21,7 +20,6 @@ import {
StoreGetProductsParams,
} from "./validators"
import { ProductStatus } from "@mercurjs/types"
-import { resolveVisibleSellerIds } from "../../utils/sellers"
/**
* Apply the store-facing defaults that vanilla Medusa applies on its own
@@ -45,17 +43,6 @@ const applyProductFilters = applyDefaultFilters({
},
})
-async function applyVisibleSellerIdsFilter(
- req: MedusaRequest,
- _res: MedusaResponse,
- next: MedusaNextFunction
-) {
- req.filterableFields ??= {}
- req.filterableFields.seller_id = await resolveVisibleSellerIds(req.scope)
-
- next()
-}
-
/**
* Translate global product-attribute filters (`attributes[<handle>]=v1,v2`)
* into native variant-option filters. Every filterable global attribute is a
@@ -123,12 +110,6 @@ export const storeProductsMiddlewares: MiddlewareRoute[] = [
),
applyProductFilters,
transformAttributeFilters,
- applyVisibleSellerIdsFilter,
- maybeApplyLinkFilter({
- entryPoint: "product_seller",
- resourceId: "product_id",
- filterableField: "seller_id",
- }),
...pricingMiddlewares,
],
},
@@ -141,12 +122,6 @@ export const storeProductsMiddlewares: MiddlewareRoute[] = [
storeProductQueryConfig.retrieve
),
applyProductFilters,
- applyVisibleSellerIdsFilter,
- maybeApplyLinkFilter({
- entryPoint: "product_seller",
- resourceId: "product_id",
- filterableField: "seller_id",
- }),
...pricingMiddlewares,
],
},