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 product/variant processors according to Shopify Product CSVs #22

Merged
merged 2 commits into from
Apr 17, 2020

Conversation

MinasMazar
Copy link
Contributor

@MinasMazar MinasMazar commented Apr 17, 2020

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.
  • When no OptionValue1 is blank or Default Title, we update the master variant.

This also resolve #16

product.slug = @data['Handle']
product.price = options[:price]
product.shipping_category = options[:shipping_category]
end.tap do |product|
Copy link
Member

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|
Copy link
Member

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}")

MinasMazar pushed a commit that referenced this pull request Apr 17, 2020
MinasMazar pushed a commit that referenced this pull request Apr 17, 2020
Copy link
Member

@elia elia left a 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 😉)

Flavio Auciello added 2 commits April 17, 2020 19:11
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.
@MinasMazar MinasMazar merged commit ef74f60 into master Apr 17, 2020
@MinasMazar MinasMazar deleted the mm/fix-import branch April 17, 2020 18:41
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.

Test the importer with data coming from a sample Shopify store
2 participants