-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(promotions): add product_variant attribute #14086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "integration-tests-http": patch | ||
| "@medusajs/medusa": patch | ||
| --- | ||
|
|
||
| feat(promotions): add product_variant attribute |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,14 +62,30 @@ export const GET = async ( | |
| filters: filterableFields, | ||
| ...req.queryConfig.pagination, | ||
| }, | ||
| fields: [queryConfig.labelAttr, queryConfig.valueAttr], | ||
| fields: ruleAttributeId === "product_variant" | ||
| ? ["title", "sku", queryConfig.valueAttr] | ||
| : [queryConfig.labelAttr, queryConfig.valueAttr], | ||
| }) | ||
| ) | ||
|
|
||
| const values = rows.map((r) => ({ | ||
| label: r[queryConfig.labelAttr], | ||
| value: r[queryConfig.valueAttr], | ||
| })) | ||
| const values = rows.map((r) => { | ||
| let label = r[queryConfig.labelAttr] | ||
|
|
||
| if (ruleAttributeId === "product_variant") { | ||
| const title = r.title | ||
| const sku = r.sku | ||
| if (sku) { | ||
| label = `${title} (SKU: ${sku})` | ||
| } else { | ||
| label = title | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Ambiguous product variant labels in responseThe generated label for product variants includes only the variant title and SKU. This results in indistinguishable options when multiple products share generic variant names (e.g., "Small" or "Red") or when SKUs are similar. Users cannot differentiate which product a variant belongs to without the product title explicitly included in the label. |
||
|
|
||
| return { | ||
| label, | ||
| value: r[queryConfig.valueAttr], | ||
| } | ||
| }) | ||
|
|
||
| res.json({ | ||
| values, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,14 @@ const itemsAttributes = [ | |
| field_type: "multiselect", | ||
| operators: Object.values(operatorsMap), | ||
| }, | ||
| { | ||
| id: "product_variant", | ||
| value: "items.variant.id", | ||
| label: "Product Variant", | ||
| required: false, | ||
| field_type: "multiselect", | ||
| operators: Object.values(operatorsMap), | ||
| }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Variant ID Path MismatchThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Align Data Paths for API and Rule EvaluationThe |
||
| { | ||
| id: "product_category", | ||
| value: "items.product.categories.id", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Ambiguous product variant labels in response
The generated label for product variants includes only the variant title and SKU. This results in indistinguishable options when multiple products share generic variant names (e.g., "Small"). Users cannot differentiate which product a variant belongs to without the product title in the label.