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:
1 parent
7d04f95603
commit
9b447f99ff
3 files changed
+18
-4
No files matched your search
@@ -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)
|
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] = {
|
this.columnsDefinition[columnNameNameValue] = {
|
||||||
name: columnNameNameValue,
|
name: columnNameNameValue,
|
||||||
exportDescriptor: {
|
exportDescriptor: {
|
||||||
accessor: (variant: ProductVariant) =>
|
accessor: (
|
||||||
variant?.options[i]?.value ?? "",
|
variant: ProductVariant,
|
||||||
|
context?: { product?: Product }
|
||||||
|
) =>
|
||||||
|
variant?.options.find(
|
||||||
|
(ov) => ov.option_id === context!.product!.options[i]?.id
|
||||||
|
)?.value ?? "",
|
||||||
entityName: "variant",
|
entityName: "variant",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -597,7 +603,7 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
|||||||
}
|
}
|
||||||
if (columnSchema.entityName === "variant") {
|
if (columnSchema.entityName === "variant") {
|
||||||
const formattedContent = csvCellContentFormatter(
|
const formattedContent = csvCellContentFormatter(
|
||||||
columnSchema.accessor(variant)
|
columnSchema.accessor(variant, { product: product })
|
||||||
)
|
)
|
||||||
variantLineData.push(formattedContent)
|
variantLineData.push(formattedContent)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,10 @@ export type ProductExportDescriptor =
|
|||||||
entityName: Extract<ProductExportColumnSchemaEntity, "product">
|
entityName: Extract<ProductExportColumnSchemaEntity, "product">
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
accessor: (variant: ProductVariant) => string
|
accessor: (
|
||||||
|
variant: ProductVariant,
|
||||||
|
context?: { product?: Product }
|
||||||
|
) => string
|
||||||
entityName: Extract<ProductExportColumnSchemaEntity, "variant">
|
entityName: Extract<ProductExportColumnSchemaEntity, "variant">
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user