mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move taxon discovery to own class for additions
This commit is contained in:
11
engines/dfc_provider/app/services/product_type_importer.rb
Normal file
11
engines/dfc_provider/app/services/product_type_importer.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ProductTypeImporter < DfcBuilder
|
||||
def self.taxon(product_type)
|
||||
dfc_id = product_type&.semanticId
|
||||
|
||||
# Every product needs a primary taxon to be valid. So if we don't have
|
||||
# one or can't find it we just take a random one.
|
||||
Spree::Taxon.find_by(dfc_id:) || Spree::Taxon.first
|
||||
end
|
||||
end
|
||||
@@ -111,11 +111,7 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
end
|
||||
|
||||
def self.taxon(supplied_product)
|
||||
dfc_id = supplied_product.productType&.semanticId
|
||||
|
||||
# Every product needs a primary taxon to be valid. So if we don't have
|
||||
# one or can't find it we just take a random one.
|
||||
Spree::Taxon.find_by(dfc_id:) || Spree::Taxon.first
|
||||
ProductTypeImporter.taxon(supplied_product.productType)
|
||||
end
|
||||
|
||||
private_class_method :product_type, :taxon
|
||||
|
||||
Reference in New Issue
Block a user