Update more variant data on import

This commit is contained in:
Maikel Linke
2024-10-10 16:59:04 +11:00
parent cde757efbd
commit 86c91143b7
2 changed files with 7 additions and 5 deletions

View File

@@ -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)

View File

@@ -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"