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(core): scope rule value options to seller's resources

vholik69df3c77991e
diff --git a/packages/core-plugin/src/api/vendor/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts b/packages/core-plugin/src/api/vendor/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts
index 6ab46fb4e..0aac86aae 100644
--- a/packages/core-plugin/src/api/vendor/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts
+++ b/packages/core-plugin/src/api/vendor/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts
@@ -45,9 +45,20 @@ export const GET = async (
delete filterableFields.application_method_target_type
}
+ const { data: sellerResources } = await query.graph({
+ entity: `${queryConfig.entryPoint}_seller`,
+ fields: [`${queryConfig.entryPoint}_id`],
+ filters: {
+ seller_id: req.auth_context.actor_id,
+ },
+ })
+
const { data: rows, metadata } = await query.graph({
entity: queryConfig.entryPoint,
- filters: filterableFields,
+ filters: {
+ ...filterableFields,
+ id: sellerResources.map(r => r[`${queryConfig.entryPoint}_id`]),
+ },
fields: [queryConfig.labelAttr, queryConfig.valueAttr],
pagination: req.queryConfig.pagination,
})