mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-15 04:14:24 +00:00
Only import selected products
This commit is contained in:
@@ -35,13 +35,16 @@ module Admin
|
||||
end
|
||||
|
||||
def import
|
||||
ids = params.require(:semanticIds)
|
||||
|
||||
# Load DFC catalog JSON
|
||||
graph = DfcIo.import(params.require(:catalog_json))
|
||||
catalog = DfcCatalog.new(graph)
|
||||
catalog.apply_wholesale_values!
|
||||
|
||||
# Import all selected products for given enterprise.
|
||||
imported = catalog.products.map do |subject|
|
||||
imported = catalog.products.select{ |subject| ids.include?(subject.semanticId) }
|
||||
.map do |subject|
|
||||
existing_variant = @enterprise.supplied_variants.linked_to(subject.semanticId)
|
||||
|
||||
if existing_variant
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
= render partial: 'spree/admin/shared/product_sub_menu'
|
||||
|
||||
%p= t('.catalog_url', catalog_url: @catalog_url)
|
||||
%p= t('.catalog_url', count: @items.count, catalog_url: @catalog_url)
|
||||
%p= t('.enterprise', enterprise_name: @enterprise.name)
|
||||
%br
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
%tbody
|
||||
- @items.each do |supplied_product, existing_product|
|
||||
%tr{id: supplied_product.semanticId }
|
||||
%td= supplied_product.name
|
||||
%td
|
||||
%label
|
||||
= form.check_box 'semanticIds[]', { checked: true }, supplied_product.semanticId, ""
|
||||
= supplied_product.name
|
||||
%td
|
||||
- if existing_product.present?
|
||||
Update
|
||||
|
||||
Reference in New Issue
Block a user