mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-07 22:46:06 +00:00
Using properties_including_inherited for product properties on the shop page
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user