\Product
Represents a Product, which is a type of a {@link Page}. Products are managed in a seperate admin area {@link ShopAdmin}. A product can have {@link Variation}s, in fact if a Product has attributes (e.g Size, Color) then it must have Variations. Products are Versioned so that when a Product is added to an Order, then subsequently changed, the Order can get the correct details about the Product.
Synopsis
class Product
extends Page
{
- // members
- protected Boolean $firstWrite = false;
- private static Array $db = ;
- private static Array $has_many = ;
- private static Array $defaults = ;
- private static Array $summary_fields = ;
- private static array $searchable_fields = ;
- // methods
- public Price Amount()
- public Price Price()
- public void onBeforeWrite()
- public void onAfterDelete()
- public FieldList getCMSFields()
- public String Link()
- public Boolean requiresVariation()
- public ArrayList getOptionsForAttribute()
- public ValidationResult validate()
Hierarchy
Extends
- Page
Tasks
Line | Task |
---|---|
35 | Multi currency |
Members
private
- $db
—
Array
DB fields for Product. - $defaults
—
Array
Defaults for Product - $has_many
—
Array
Has many relations for Product. - $searchable_fields
- $summary_fields
—
Array
Summary fields for displaying Products in the CMS
protected
- $firstWrite
—
Boolean
Flag for denoting if this is the first time this Product is being written.
Methods
public
- Amount() — Actual price in base currency, can decorate to apply discounts etc.
- Link() — Get the URL for this Product, products that are not part of the SiteTree are displayed by the {@link Product_Controller}.
- Price() — Display price, can decorate for multiple currency etc.
- getCMSFields() — Set some CMS fields for managing Products
- getOptionsForAttribute() — Get options for an Attribute of this Product.
- onAfterDelete() — Unpublish products if they get deleted, such as in product admin area
- onBeforeWrite() — Set firstWrite flag if this is the first time this Product is written.
- requiresVariation() — A product is required to be added to a cart with a variation if it has attributes.
- validate() — Validate the Product before it is saved in {@link ShopAdmin}.