Class: Spree::InventoryProvider::Internal
- Defined in:
- app/models/spree/inventory_provider/internal.rb
Overview
Spree's own stock records. Returns the association untouched so Stock::Quantifier keeps its loaded-association fast path — a preloaded variant must not fall back to a query per stock item.
Location narrowing and active-location filtering stay in the Quantifier, which already does both; doing them here as well would break that preload branch for no gain.
Instance Method Summary collapse
Methods included from Spree::IntegrationBackedProvider
Instance Method Details
#stock_levels_for(variant, stock_location: nil) ⇒ Enumerable<Spree::StockLevel>
14 15 16 17 18 19 |
# File 'app/models/spree/inventory_provider/internal.rb', line 14 def stock_levels_for(variant, stock_location: nil) return variant.stock_levels if stock_location.blank? return variant.stock_levels.select { |item| item.stock_location_id == stock_location.id } if variant.association(:stock_levels).loaded? variant.stock_levels.where(stock_location: stock_location) end |