autotelik / datashift

Full Excel/CSV Import/Export facilities for Rails
http://www.autotelik.co.uk
Other
136 stars 75 forks source link

product isn't saved even if price value is set in .xsl spreadsheet #57

Closed LucaDev13 closed 7 years ago

LucaDev13 commented 7 years ago

Following https://github.com/autotelik/datashift/wiki/Walkthroughs but keep getting errors in the datashift.log about Cannot Save Spree::Product : ["Price can't be blank"] whereas the prices column in the spreadsheet is set with a numeric value.

datashift_log.txt

product_newtest.xlsx

autotelik commented 7 years ago

Hi

What version of Spree are you working with ?

Unfortunately I do not currently work with Spree, so I am not familiar with that field being a has_many Prices.

When I worked with Spree, it was a singular field on product called Price

N.B column ordering important, required fields (like SKU, Price etc) must come before any associations (as you need a saved Product to create an association)

I would try creating a Price column after name and setting a singular price

LucaDev13 commented 7 years ago

Hi

'spree', '~> 3.1.0' https://github.com/spree/spree/tree/3-1-stable ruby => 2.3.0 rails => 4.2.5

From the log I see

[2017-08-22T22:23:29.248719 #5313] DEBUG -- : Column [prices] (1) - mapped to :

      Class         [Spree::Product]
      Operator Type [has_many]
      Operator      [prices]

#Or if instead we use `price`

[2017-08-22T22:46:44.728367 #5863] DEBUG -- : Column [price] (1) - mapped to :
      Class         [Spree::Product]
      Operator Type [has_many]
      Operator      [prices]

From the below screenshot it can be seen that those values are present in the spreadsheet and I followed your advise about the ordering.

image

Attached is the last log where you can see also complaints about the shipping category - this field is also filled.

Any idea on the reason of this and how to resolve this issue? Thank you!

ds_log.txt

autotelik commented 7 years ago

Hi

So had a look at Spree 3 and seems there is now a Price on Product and a has_many Prices through variant

Its odd that a column named 'price' is not matching the price column but the prices association .. looks like a bug so will investigate

Could be that having shipping_category_id and shipping_category is confusing it ?

Also the master of datashift_spree is built against Spree 2, I started a Spree3 branch here

https://github.com/autotelik/datashift_spree/tree/feature/update_api_latest_ds_and_spree

Maybe worth trying that although since I no long work day to day with Spree this maybe still not complete

autotelik commented 7 years ago

Can you please try with Gemfile :

gem 'datashift', git: 'https://github.com/autotelik/datashift.git'
gem 'datashift_spree', git: 'https://github.com/autotelik/datashift_spree.git', :branch => 'feature/update_api_latest_ds_and_spree'

I have successfully loaded into a Spree 3.1 store using following

image

LucaDev13 commented 7 years ago

Hello @autotelik

I can confirm that it now works without issue, thanks! Please let me know if I can help in any way for testing, closing this issue.