\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
implements
HiddenClass
{
- // members
- protected Boolean $firstWrite = false;
- private static Array $db = ;
- private static Array $has_many = ;
- private static array $has_one = ;
- private static Array $belongs_many_many = ;
- private static Array $defaults = ;
- private static Array $summary_fields = ;
- private static array $searchable_fields = ;
- private static array $casting = ;
- // methods
- public void OnSpecial()
- public void ShowVariations()
- public Price Amount()
- public Price Price()
- public Price OriginalAmount()
- public Price OriginalPrice()
- public void onBeforeWrite()
- public void onAfterWrite()
- public void onBeforePublish()
- public void onAfterPublish()
- public void onBeforeDelete()
- public void onAfterDelete()
- public void canView()
- public void canAddChildren()
- public FieldList getCMSFields()
- public void getCMSValidator()
- public String Link()
- public Boolean requiresVariation()
- public ArrayList getOptionsForAttribute()
- public ValidationResult validate()
- public void CheckStock()
Hierarchy
Extends
- Page
Implements
- HiddenClass
Tasks
Line | Task |
---|---|
105 | Multi currency |
140 | Multi currency |
247 | FIX THIS |
Members
private
- $belongs_many_many
—
Array
Belongs many many relations for Product - $casting
- $db
—
Array
DB fields for Product. - $defaults
—
Array
Defaults for Product - $has_many
—
Array
Has many relations for Product. - $has_one
- $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.
- CheckStock()
- Link() — Get the URL for this Product, products that are not part of the SiteTree are displayed by the {@link Product_Controller}.
- OnSpecial()
- OriginalAmount() — Original price in base currency, can decorate to apply discounts etc.
- OriginalPrice() — Display original price, can decorate for multiple currency etc.
- Price() — Display price, can decorate for multiple currency etc.
- ShowVariations()
- canAddChildren()
- canView()
- getCMSFields() — Set some CMS fields for managing Products
- getCMSValidator()
- getOptionsForAttribute() — Get options for an Attribute of this Product.
- onAfterDelete() — Unpublish products if they get deleted, such as in product admin area
- onAfterPublish()
- onAfterWrite()
- onBeforeDelete() — Delete images and clear categories link
- onBeforePublish()
- onBeforeWrite()
- 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}.