From cf39aa6e298143ee605d80dc556838711736ebf3 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 7 Mar 2016 15:49:29 +0100 Subject: [PATCH] Have Spree::Product#prices return master prices All other associations are `:through variants_including_master`, this one strangely is not. --- CHANGELOG.md | 7 +++++++ core/app/models/spree/product.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 338e1d1b614..5e4f4931cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## Solidus 1.3.0 (unreleased) +* Make Spree::Product#prices association return all prices + + Previously, only non-master variant prices would have been returned here. + Now, we get all the prices, including those from the master variant. + + https://github.com/solidusio/solidus/pull/969 + * Changes to Spree::Stock::Estimator * The package passed to Spree::Stock::Estimator#shipping_rates must have its diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index b21aa133ddd..74ecb59862c 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -48,7 +48,7 @@ class Product < Spree::Base class_name: 'Spree::Variant', dependent: :destroy - has_many :prices, -> { order(Spree::Variant.arel_table[:position].asc, Spree::Variant.arel_table[:id].asc, :currency) }, through: :variants + has_many :prices, -> { order(Spree::Variant.arel_table[:position].asc, Spree::Variant.arel_table[:id].asc, :currency) }, through: :variants_including_master has_many :stock_items, through: :variants_including_master