fix(medusa): export product prices in human-readable format (#3739)
* fix: export product prices in human-readable format * feat: add changesets * fix: update snaps * fix: update more snaps --------- Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
5
.changeset/gold-garlics-worry.md
Normal file
5
.changeset/gold-garlics-worry.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): invalidate price selection cache on update
|
||||
5
.changeset/nine-chicken-cheat.md
Normal file
5
.changeset/nine-chicken-cheat.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): align prices formating in the import & export strategies
|
||||
@@ -7,11 +7,11 @@ Array [
|
||||
"product-export-strategy-product-1;test-product-product-1;Test product;;\\"test-product-description-1
|
||||
test-product-description-1 second line
|
||||
test-product-description-1 third line
|
||||
forth line\\";draft;;;;;;;;;;Test collection 1;test-collection1;test-type-1;123_1;true;;profile_1;profile_type_1;product-export-strategy-variant-1;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;100;110;130;;test-option-1;option 1 value 1;test-option-2;option 2 value 1;test-image.png
|
||||
forth line\\";draft;;;;;;;;;;Test collection 1;test-collection1;test-type-1;123_1;true;;profile_1;profile_type_1;product-export-strategy-variant-1;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;1;1.1;1.3;;test-option-1;option 1 value 1;test-option-2;option 2 value 1;test-image.png
|
||||
",
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-2;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;;;110;test-option;Option 1 value 1;;;test-image.png
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-2;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;;;1.1;test-option;Option 1 value 1;;;test-image.png
|
||||
",
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-3;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;120;;;test-option;Option 1 Value 1;;;test-image.png
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-3;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;1.2;;;test-option;Option 1 Value 1;;;test-image.png
|
||||
",
|
||||
]
|
||||
`;
|
||||
@@ -23,14 +23,14 @@ Array [
|
||||
"product-export-strategy-product-1;test-product-product-1;Test product;;\\"test-product-description-1
|
||||
test-product-description-1 second line
|
||||
test-product-description-1 third line
|
||||
forth line\\";draft;;;;;;;;;;Test collection 1;test-collection1;test-type-1;123_1;true;;profile_1;profile_type_1;product-export-strategy-variant-1;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;100;110;130;;test-option-1;option 1 value 1;test-option-2;option 2 value 1;test-image.png;SC 1;SC 1;\\"SC 1
|
||||
forth line\\";draft;;;;;;;;;;Test collection 1;test-collection1;test-type-1;123_1;true;;profile_1;profile_type_1;product-export-strategy-variant-1;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;1;1.1;1.3;;test-option-1;option 1 value 1;test-option-2;option 2 value 1;test-image.png;SC 1;SC 1;\\"SC 1
|
||||
SC 1 second line
|
||||
SC 1 third line
|
||||
SC 1 forth line\\";;;
|
||||
",
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-2;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;;;110;test-option;Option 1 value 1;;;test-image.png;SC 1;SC 1;SC 1;SC 2;SC 2;SC 2
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-2;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;;;1.1;test-option;Option 1 value 1;;;test-image.png;SC 1;SC 1;SC 1;SC 2;SC 2;SC 2
|
||||
",
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-3;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;120;;;test-option;Option 1 Value 1;;;test-image.png;SC 1;SC 1;SC 1;SC 2;SC 2;SC 2
|
||||
"product-export-strategy-product-2;test-product-product-2;Test product;;test-product-description;draft;;;;;;;;;;Test collection;test-collection2;test-type;123;true;;profile_2;profile_type_2;product-export-strategy-variant-3;Test variant;test-sku;test-barcode;10;false;true;;;;;;;;;;1.2;;;test-option;Option 1 Value 1;;;test-image.png;SC 1;SC 1;SC 1;SC 2;SC 2;SC 2
|
||||
",
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
import { humanizeAmount } from "medusa-core-utils"
|
||||
|
||||
import { AbstractBatchJobStrategy, IFileService } from "../../../interfaces"
|
||||
import { Product, ProductVariant } from "../../../models"
|
||||
import { BatchJobService, ProductService } from "../../../services"
|
||||
@@ -460,7 +463,12 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
||||
priceData.currency_code.toLowerCase()
|
||||
)
|
||||
})
|
||||
return price?.amount?.toString() ?? ""
|
||||
return price?.amount
|
||||
? humanizeAmount(
|
||||
price?.amount,
|
||||
priceData.currency_code!
|
||||
).toString()
|
||||
: ""
|
||||
},
|
||||
entityName: "variant",
|
||||
},
|
||||
@@ -487,7 +495,12 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
||||
priceData.region?.id?.toLowerCase()
|
||||
)
|
||||
})
|
||||
return price?.amount?.toString() ?? ""
|
||||
return price?.amount
|
||||
? humanizeAmount(
|
||||
price?.amount,
|
||||
priceData.region!.currency_code!
|
||||
).toString()
|
||||
: ""
|
||||
},
|
||||
entityName: "variant",
|
||||
},
|
||||
@@ -546,7 +559,7 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximun number of each relation that must appears in the export.
|
||||
* Return the maximum number of each relation that must appears in the export.
|
||||
* The number of item of a relation can vary between 0-Infinity and therefore the number of columns
|
||||
* that will be added to the export correspond to that number
|
||||
* @param products - The main entity to get the relation shape from
|
||||
|
||||
Reference in New Issue
Block a user