mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update more variant data on import
This commit is contained in:
@@ -53,14 +53,10 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
end
|
||||
else
|
||||
product = import_product(supplied_product, supplier)
|
||||
product.variants.first
|
||||
product.variants.first.tap { |variant| apply(supplied_product, variant) }
|
||||
end.tap do |variant|
|
||||
link = supplied_product.semanticId
|
||||
catalog_item = supplied_product&.catalogItems&.first
|
||||
offer = catalog_item&.offers&.first
|
||||
variant.semantic_links.new(semantic_id: link) if link.present?
|
||||
CatalogItemBuilder.apply_stock(catalog_item, variant)
|
||||
OfferBuilder.apply(offer, variant)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,6 +98,11 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
variant.primary_taxon = taxon(supplied_product)
|
||||
QuantitativeValueBuilder.apply(supplied_product.quantity, variant.product)
|
||||
variant.unit_value = variant.product.unit_value
|
||||
|
||||
catalog_item = supplied_product&.catalogItems&.first
|
||||
offer = catalog_item&.offers&.first
|
||||
CatalogItemBuilder.apply_stock(catalog_item, variant)
|
||||
OfferBuilder.apply(offer, variant)
|
||||
end
|
||||
|
||||
def self.product_type(variant)
|
||||
|
||||
@@ -66,6 +66,7 @@ RSpec.describe "DFC Product Import" do
|
||||
}.to change { enterprise.supplied_products.count }
|
||||
.and change { linked_variant.display_name }
|
||||
.and change { linked_variant.unit_value }
|
||||
.and change { linked_variant.price }
|
||||
|
||||
expect(page).to have_content "Importing a DFC product catalog"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user