swipestripe
[ class tree: swipestripe ] [ index: swipestripe ] [ all elements ]

Class: Variation

Source Location: /code/product/Variation.php

Class Overview

DataObject
   |
   --Variation

Represents a Variation for a Product. A variation needs to have a valid Option set for each Attribute that the product has e.g Size:Medium, Color:Red, Material:Cotton. Variations are Versioned so that when they are added to an Order and then changed, the Order can still access the correct information.


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright (c) 2011, Frank Mullenger

Variables

Methods



Class Details

[line 14]
Represents a Variation for a Product. A variation needs to have a valid Option set for each Attribute that the product has e.g Size:Medium, Color:Red, Material:Cotton. Variations are Versioned so that when they are added to an Order and then changed, the Order can still access the correct information.



Tags:

author:  Frank Mullenger <frankmullenger@gmail.com>
version:  1.0
copyright:  Copyright (c) 2011, Frank Mullenger


[ Top ]


Class Variables

static $db = array(
    'Amount' => 'Money',
     'Status' => "Enum('Enabled,Disabled','Enabled')",
  )

[line 21]

DB fields for a Variation



Tags:

access:  public

Type:   Array


[ Top ]

static $extensions = array(
      "Versioned('Live')",
   )

[line 64]

Versioning for a Variation, so that Orders can access the version that was purchased and correct information can be retrieved.


Type:   Array


[ Top ]

static $has_one = array(
    'Product' => 'Product',
    'Image' => 'ProductImage',
    'StockLevel' => 'StockLevel'
  )

[line 31]

Has one relation for a Variation



Tags:

access:  public

Type:   Array


[ Top ]

static $many_many = array(
    'Options' => 'Option'
  )

[line 42]

Many many relation for a Variation



Tags:

access:  public

Type:   Array


[ Top ]

static $summary_fields = array(
    'SummaryOfStock' => 'Stock',
    'SummaryOfPrice' => 'Added Price',
    'Status' => 'Status',
   )

[line 52]

Summary fields for displaying Variations in the CMS



Tags:

access:  public

Type:   Array


[ Top ]



Class Methods


method getCMSFields_forPopup [line 107]

FieldSet getCMSFields_forPopup( )

Add fields for editing a Variation in the CMS popup.



Tags:

access:  public


[ Top ]

method getOptionForAttribute [line 91]

Option getOptionForAttribute( Int $attributeID)

Get a Variation option for an attribute



Tags:

access:  public


Parameters:

Int   $attributeID  

[ Top ]

method getUnprocessedQuantity [line 471]

Int getUnprocessedQuantity( )

Get the quantity of this product that is currently in shopping carts or unprocessed orders



[ Top ]

method hasValidOptions [line 260]

Boolean hasValidOptions( )

Convenience method to check that this Variation has valid options.



Tags:

access:  public


[ Top ]

method InStock [line 211]

Boolean InStock( )

Basic check to see if Product is in stock. Not currently used.



Tags:

access:  public


[ Top ]

method isDeleted [line 365]

Boolean isDeleted( )

Check if the variation has been deleted, need to check the actual variation and not just this version.



Tags:

access:  public


[ Top ]

method isDuplicate [line 313]

Boolean isDuplicate( )

Convenience method to check that this Variation is not a duplicate.



Tags:

access:  public


[ Top ]

method isEnabled [line 354]

Boolean isEnabled( )

If current variation is enabled, checks lastest version of variation because status is saved in versions. So a variation can be saved as enabled, the version can be added to cart, then the variation is disabled but the previous version stays enabled.



Tags:

access:  public


[ Top ]

method isNegativeAmount [line 376]

Boolean isNegativeAmount( )

Check if Variation amount is a negative value



Tags:

access:  public


[ Top ]

method onAfterWrite [line 413]

void onAfterWrite( )

Unpublish Products if after the Variations have been saved there are no enabled Variations.

TODO check that this works when changing attributes




Tags:

access:  protected


[ Top ]

method onBeforeWrite [line 430]

void onBeforeWrite( )

Update stock level associated with this Variation.

(non-PHPdoc)




[ Top ]

method SummaryOfOptions [line 153]

String SummaryOfOptions( )

Get a summary of the Options, helper method for displaying Options nicely

TODO allow attributes to be sorted




[ Top ]

method SummaryOfOptionValueForAttribute [line 173]

String SummaryOfOptionValueForAttribute( Int $attributeID)

Get attribute option value, helper method



Tags:

access:  public


Parameters:

Int   $attributeID  

[ Top ]

method SummaryOfPrice [line 202]

String SummaryOfPrice( )

Summarize the Product price, returns Amount formatted with Nice()



Tags:

access:  public


[ Top ]

method SummaryOfStock [line 189]

String SummaryOfStock( )

Summary of stock, not currently used.



Tags:

access:  public


[ Top ]

method updateStockBy [line 454]

Void updateStockBy( Int $quantity)

Update the stock level for this Product. A negative quantity is passed when product is added to a cart, a positive quantity when product is removed from a cart.



Tags:

access:  public


Parameters:

Int   $quantity  

[ Top ]

method validate [line 386]

ValidationResult validate( )

Validate the Variation before it is saved.



Tags:

access:  protected


[ Top ]

method validateForCart [line 227]

ValidationResult validateForCart( )

Validate that this variation is suitable for adding to the cart.



[ Top ]

method __get [line 75]

void __get( $property)

Overloaded magic method so that attribute values can be retrieved for display in CTFs etc.



Tags:

access:  public


Parameters:

   $property  

[ Top ]


Documentation generated on Thu, 08 Mar 2012 16:47:29 +1300 by phpDocumentor 1.4.4