Assign supplier_id when saving new product to products list

This commit is contained in:
Matt-Yorkley
2018-10-02 13:15:18 +01:00
parent e7a909e828
commit 5c2b5377bc
2 changed files with 2 additions and 0 deletions

View File

@@ -166,6 +166,7 @@ module ProductImport
product = Spree::Product.new
product.assign_attributes(entry.attributes.except('id'))
product.supplier_id = entry.enterprise_id
assign_defaults(product, entry)
if product.save

View File

@@ -207,6 +207,7 @@ module ProductImport
def mark_as_new_product(entry)
new_product = Spree::Product.new
new_product.assign_attributes(entry.attributes.except('id'))
new_product.supplier_id = entry.enterprise_id
if new_product.valid?
entry.validates_as = 'new_product' unless entry.errors?