Using properties_including_inherited for product properties on the shop page

This commit is contained in:
Rob Harrington
2015-04-22 16:15:59 +10:00
parent e546388784
commit 4a4b3da551

View File

@@ -31,17 +31,20 @@ class Api::CachedProductSerializer < ActiveModel::Serializer
#delegate :cache_key, to: :object
attributes :id, :name, :permalink, :count_on_hand, :on_demand, :group_buy,
:notes, :description
:notes, :description, :properties
has_many :variants, serializer: Api::VariantSerializer
has_many :taxons, serializer: Api::IdSerializer
has_many :properties, serializer: Api::IdSerializer
has_many :images, serializer: Api::ImageSerializer
has_one :supplier, serializer: Api::IdSerializer
has_one :primary_taxon, serializer: Api::TaxonSerializer
has_one :master, serializer: Api::VariantSerializer
def properties
object.properties_including_inherited
end
def variants
# We use the in_stock? method here instead of the in_stock scope because we need to
# look up the stock as overridden by VariantOverrides, and the scope method is not affected