diff --git a/app/services/sets/product_set.rb b/app/services/sets/product_set.rb index 06f3ac4f4f..7eb73e3bee 100644 --- a/app/services/sets/product_set.rb +++ b/app/services/sets/product_set.rb @@ -20,10 +20,9 @@ module Sets end def collection_attributes=(attributes) - ids = attributes.each_value.map { |product| product[:id] }.compact - @collection = [] + ids = attributes.values.pluck(:id).compact # Find and load existing products in the order they are provided - @collection = Spree::Product.find(ids) if ids.present? + @collection = Spree::Product.find(ids) @collection_hash = attributes end