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.

refactor(core-plugin): remove validateVariantBySku from inventory items

vholik632d85fea598
diff --git a/packages/core-plugin/src/api/vendor/inventory-items/[id]/route.ts b/packages/core-plugin/src/api/vendor/inventory-items/[id]/route.ts
index d9cb61cfc..5f2cdd0a5 100644
--- a/packages/core-plugin/src/api/vendor/inventory-items/[id]/route.ts
+++ b/packages/core-plugin/src/api/vendor/inventory-items/[id]/route.ts
@@ -9,7 +9,7 @@ import {
} from "@medusajs/core-flows"
import { HttpTypes } from "@mercurjs/types"
-import { refetchInventoryItem, validateSellerInventoryItem, validateVariantBySku } from "../helpers"
+import { refetchInventoryItem, validateSellerInventoryItem } from "../helpers"
import { VendorUpdateInventoryItemType } from "../validators"
export const GET = async (
@@ -44,10 +44,6 @@ export const POST = async (
await validateSellerInventoryItem(req.scope, req.auth_context.actor_id, id)
- if (req.validatedBody.sku) {
- await validateVariantBySku(req.scope, req.auth_context.actor_id, req.validatedBody.sku)
- }
-
await updateInventoryItemsWorkflow(req.scope).run({
input: {
updates: [{ id, ...req.validatedBody }],
diff --git a/packages/core-plugin/src/api/vendor/inventory-items/helpers.ts b/packages/core-plugin/src/api/vendor/inventory-items/helpers.ts
index 9df58db86..ef5c6f0f0 100644
--- a/packages/core-plugin/src/api/vendor/inventory-items/helpers.ts
+++ b/packages/core-plugin/src/api/vendor/inventory-items/helpers.ts
@@ -47,28 +47,3 @@ export const validateSellerInventoryItem = async (
)
}
}
-
-export const validateVariantBySku = async (
- scope: MedusaContainer,
- sellerId: string,
- sku: string
-) => {
- const query = scope.resolve(ContainerRegistrationKeys.QUERY)
-
- const {
- data: [variant],
- } = await query.graph({
- entity: "product_variant",
- filters: { sku },
- fields: ["id", "product.id", 'product.seller.id'],
- })
-
- if (!variant || variant.product.seller.id !== sellerId) {
- throw new MedusaError(
- MedusaError.Types.NOT_FOUND,
- `Variant with sku: ${sku} was not found`
- )
- }
-
- return variant
-}
diff --git a/packages/core-plugin/src/api/vendor/inventory-items/route.ts b/packages/core-plugin/src/api/vendor/inventory-items/route.ts
index 2e0184117..9de427848 100644
--- a/packages/core-plugin/src/api/vendor/inventory-items/route.ts
+++ b/packages/core-plugin/src/api/vendor/inventory-items/route.ts
@@ -6,7 +6,7 @@ import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
import { HttpTypes } from "@mercurjs/types"
import { createSellerInventoryItemsWorkflow } from "../../../workflows/inventory-item"
-import { refetchInventoryItem, validateVariantBySku } from "./helpers"
+import { refetchInventoryItem } from "./helpers"
import {
VendorCreateInventoryItemType,
VendorGetInventoryItemsParamsType,
@@ -39,10 +39,6 @@ export const POST = async (
) => {
const sellerId = req.auth_context.actor_id
- if (req.validatedBody.sku) {
- await validateVariantBySku(req.scope, sellerId, req.validatedBody.sku)
- }
-
const { result } = await createSellerInventoryItemsWorkflow(req.scope).run({
input: {
seller_id: sellerId,