Apply suggestions from code review

Rails is clever enough to not query the database without ids

Co-authored-by: Maikel <maikel@email.org.au>
This commit is contained in:
David Cook
2023-08-24 08:48:27 +10:00
committed by GitHub
parent 2edf504d65
commit a8d37d0899

View File

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