Product properties belong to the
Spree::ProductProperty model. They track
individual attributes for a product, especially if the attributes only apply to
one specific product. Typically, product properties are used for technical
specifications or additional product information.
For example, you might see a list of product properties for a limited edition t-shirt as a table on its product page:
|Property name||Property value|
You can retrieve the value for a property on a
Spree::Product object by
property method on it and passing through that property's name:
Spree::Product.find(1).property("fit") => "Tapered"
You can set a property on a product by calling the
If this property doesn't already exist, a new
Property instance with this name
will be created.
A product property should not be confused with an option type , which is used to define variants for a product.
Use product properties to describe a product: "The t-shirt is 100% cotton." Use option types to show how variants are distinct from each other: "The t-shirt can be purchased in one of two colors: red or green."
If you have product properties that only apply to a variant (or a subset of variants), you can set variant properties as well as product properties.
You can access applied variant properties from the
Spree::Variant rather than
Solidus is an open source platform supported by the community. We encourage everyone using Solidus to contribute back to the documentation and the code.