-
Notifications
You must be signed in to change notification settings - Fork 30
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 product/variant processors according to Shopify Product CSVs #22
Conversation
17cb813
to
e479f18
Compare
product.slug = @data['Handle'] | ||
product.price = options[:price] | ||
product.shipping_category = options[:shipping_category] | ||
end.tap do |product| |
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.
👍
def prepare_variant(product) | ||
Spree::Variant.find_or_initialize_by(sku: @data['Variant SKU']) do |variant| | ||
def prepare_variant | ||
@prepare_variant ||= Spree::Variant.find_or_initialize_by(sku: sku) do |variant| |
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.
Looks like Shopify bases the variant identity on the product + the name of the first option-value, maybe we should do the same, e.g.:
- update the master variant if the incoming data is for a master-variant
- use "Option1 Value" to identify the variant and maybe also to generate the sku when missing (E.g.:
"#{product.slug}-#{@data["Option1 Value"].parameterize}"
)
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.
👍 (pending the rebase/fixup of course 😉)
Refs. - https://github.com/shopifypartners/product-csvs.git - https://www.shopify.com/partners/blog/shopify-upload-products-csv These new examples are failing. We fix in next commits.
I found some product export sample CSV files in [this repository](https://github.com/shopifypartners/product-csvs.git). I've added some spec examples to test our import against those files. These tests are failing, so we need to change some of our assumptions about import logic: + `Variant SKU` is optional, so if present use it, generate new one otherwise. + when `Title` field is present we update a product. + when no `OptionValue1` is blank or `Default Title`, we update the master variant.
24f0d73
to
9293e57
Compare
I found some product export sample CSV files in this repository.
I've added some spec examples to test our import against those files. These tests are failing, so we need to change some of our assumptions about import logic:
Variant SKU
is optional, so if present use it, generate new one otherwise.Title
field is present we update a product.OptionValue1
is blank orDefault Title
, we update the master variant.This also resolve #16