diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index 3a5b57dc954..fa563bfa926 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -180,8 +180,7 @@ def self.like_any(fields, values) private def recalculate_count_on_hand product_count_on_hand = has_variants? ? - variants.inject(0) { |acc, v| acc + v.count_on_hand } : - (master ? master.count_on_hand : 0) + variants.sum(:count_on_hand) : (master ? master.count_on_hand : 0) self.count_on_hand = product_count_on_hand end