Method: Spree::Product#property

Defined in:
app/models/spree/product.rb

#property(property_name) ⇒ String

Returns the value of the given property. nil if property is undefined on this product.

Parameters:

  • property_name (String)

    the name of the property to find

Returns:

  • (String)

    the value of the given property. nil if property is undefined on this product



240
241
242
243
# File 'app/models/spree/product.rb', line 240

def property(property_name)
  return nil unless prop = properties.find_by(name: property_name)
  product_properties.find_by(property: prop).try(:value)
end