Skip to content
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

fix: setup price list import #2210

Merged
merged 20 commits into from
Sep 28, 2022
Merged

fix: setup price list import #2210

merged 20 commits into from
Sep 28, 2022

Conversation

srindom
Copy link
Collaborator

@srindom srindom commented Sep 14, 2022

What

  • Adds a batch job strategy that can handle importing prices to a PriceList
  • The import format is:
Product Variant ID SKU Price {currency code} Price {region name} [{currency code}] ...
variant_1234 32.53 123.20
MY-PROD-BLUE 44.32 42.22
  • Each row must either have a Product Variant ID or SKU (variant ID takes precedent).
  • Currency prices are entered in human format (i.e., as decimals) (this PR introduces computerizeAmount utility to convert human format to DB format)
  • PR also makes changes to product import to make sure pricing import formats are aligned
  • Adds a clearPrices method in the PriceListService that can be used to delete all prices in a price list.

Usage

POST /admin/batch-job
{
  context: {
    fileKey: "import.csv",
    price_list_id: "pl_my_id",
  }
}

Note: the import strategy will delete all existing prices in the price list, before creating the prices as specified by the import file.

Testing

  • Integration test for importing price list prices; covers case with
    • Price based on Variant ID
    • Price based on SKU
    • Non-division and division currencies (USD, EUR, JPY)
    • Currency and Region price
    • Trimming of headers in import
  • Integration test for failed import due to invalid format
    • Checks that error is stored in batchJob.result.errors

Fixes CORE-590

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2022

🦋 Changeset detected

Latest commit: a579131

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@medusajs/medusa Major
medusa-core-utils Minor
medusa-react Major
medusa-interfaces Major
medusa-file-minio Major
medusa-file-s3 Major
medusa-file-spaces Major
medusa-fulfillment-manual Major
medusa-fulfillment-webshipper Major
medusa-payment-adyen Major
medusa-payment-klarna Major
medusa-payment-manual Major
medusa-payment-paypal Major
medusa-payment-stripe Major
medusa-plugin-algolia Major
medusa-plugin-brightpearl Major
medusa-plugin-contentful Major
medusa-plugin-discount-generator Major
medusa-plugin-economic Major
medusa-plugin-ip-lookup Major
medusa-plugin-mailchimp Major
medusa-plugin-meilisearch Major
medusa-plugin-restock-notification Major
medusa-plugin-segment Major
medusa-plugin-sendgrid Major
medusa-plugin-slack-notification Major
medusa-plugin-twilio-sms Major
medusa-plugin-wishlist Major
medusa-source-shopify Major
@medusajs/medusa-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@srindom srindom marked this pull request as ready for review September 16, 2022 13:23
@srindom srindom requested a review from a team as a code owner September 16, 2022 13:23
@srindom srindom requested a review from fPolic September 16, 2022 13:23
Copy link
Contributor

@fPolic fPolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Very nice 💪
I added a couple of questions/suggestions which are non-blocking

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@olivermrbl olivermrbl merged commit 7dc8d3a into develop Sep 28, 2022
@olivermrbl olivermrbl deleted the feat/price-list-import branch September 28, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants