properties_h uses inherit_properties flag, and returns property id rather than presentation

This commit is contained in:
Rob Harrington
2015-04-22 16:06:01 +10:00
parent f610a709e1
commit 976c24cf4c
2 changed files with 41 additions and 12 deletions

View File

@@ -111,15 +111,18 @@ Spree::Product.class_eval do
def properties_h
# Product properties override producer properties
ps = product_properties.all
supplier.producer_properties.each do |producer_property|
unless ps.find { |product_property| product_property.property.presentation == producer_property.property.presentation }
ps << producer_property
if inherits_properties
supplier.producer_properties.each do |producer_property|
unless ps.find { |product_property| product_property.property.presentation == producer_property.property.presentation }
ps << producer_property
end
end
end
ps.
sort_by { |pp| pp.position }.
map { |pp| {presentation: pp.property.presentation, value: pp.value} }
map { |pp| {id: pp.property.id, value: pp.value} }
end
def in_distributor?(distributor)