fix(medusa): Product option values in CSV Export (#5781)
* https://github.com/medusajs/medusa/issues/5712 * fix-5712 added a comment * fix/5712 - changing to context object * Create yellow-games-reflect.md --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
5
.changeset/yellow-games-reflect.md
Normal file
5
.changeset/yellow-games-reflect.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Product option values in CSV Export
|
||||
@@ -497,11 +497,17 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
||||
|
||||
const columnNameNameValue = columnNameValueBuilder(i)
|
||||
|
||||
// option values are not guaranteed to keep the same order as options on product. Pick them in the same order as product options
|
||||
this.columnsDefinition[columnNameNameValue] = {
|
||||
name: columnNameNameValue,
|
||||
exportDescriptor: {
|
||||
accessor: (variant: ProductVariant) =>
|
||||
variant?.options[i]?.value ?? "",
|
||||
accessor: (
|
||||
variant: ProductVariant,
|
||||
context?: { product?: Product }
|
||||
) =>
|
||||
variant?.options.find(
|
||||
(ov) => ov.option_id === context!.product!.options[i]?.id
|
||||
)?.value ?? "",
|
||||
entityName: "variant",
|
||||
},
|
||||
}
|
||||
@@ -597,7 +603,7 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
||||
}
|
||||
if (columnSchema.entityName === "variant") {
|
||||
const formattedContent = csvCellContentFormatter(
|
||||
columnSchema.accessor(variant)
|
||||
columnSchema.accessor(variant, { product: product })
|
||||
)
|
||||
variantLineData.push(formattedContent)
|
||||
}
|
||||
|
||||
@@ -72,7 +72,10 @@ export type ProductExportDescriptor =
|
||||
entityName: Extract<ProductExportColumnSchemaEntity, "product">
|
||||
}
|
||||
| {
|
||||
accessor: (variant: ProductVariant) => string
|
||||
accessor: (
|
||||
variant: ProductVariant,
|
||||
context?: { product?: Product }
|
||||
) => string
|
||||
entityName: Extract<ProductExportColumnSchemaEntity, "variant">
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user