mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Include product group objects in our catalog response
And when we import a catalog, we don't try to import those product groups as Spree::Variant. We just see them as reference to Spree::Product.
This commit is contained in:
@@ -19,6 +19,7 @@ module DfcProvider
|
||||
*person.affiliatedOrganizations,
|
||||
*person.affiliatedOrganizations.flat_map(&:catalogItems),
|
||||
*person.affiliatedOrganizations.flat_map(&:catalogItems).map(&:product),
|
||||
*person.affiliatedOrganizations.flat_map(&:catalogItems).map(&:product).flat_map(&:isVariantOf),
|
||||
*person.affiliatedOrganizations.flat_map(&:catalogItems).flat_map(&:offers),
|
||||
)
|
||||
end
|
||||
|
||||
@@ -13,9 +13,13 @@ class DfcCatalog
|
||||
@graph = graph
|
||||
end
|
||||
|
||||
# List all products in this catalog.
|
||||
# These are SuppliedProduct objects which may be grouped as variants.
|
||||
# But we don't return the parent products having variants.
|
||||
def products
|
||||
@products ||= @graph.select do |subject|
|
||||
subject.is_a? DataFoodConsortium::Connector::SuppliedProduct
|
||||
subject.is_a?(DataFoodConsortium::Connector::SuppliedProduct) &&
|
||||
subject.variants.blank?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -180,6 +180,9 @@ paths:
|
||||
dfc-b:isVariantOf: http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
ofn:spree_product_id: 90000
|
||||
ofn:spree_product_uri: http://test.host/api/dfc/enterprises/10000?spree_product_id=90000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
"@type": dfc-b:SuppliedProduct
|
||||
dfc-b:hasVariant: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
"@type": dfc-b:Offer
|
||||
dfc-b:hasPrice:
|
||||
|
||||
Reference in New Issue
Block a user