Sunnysideup\EcommerceProductVariation\Model\Buyables\ProductWithVariationDecorator
### @@@@ START REPLACEMENT @@@@ ### WHY: automated upgrade OLD: extends DataExtension (ignore case) NEW: extends DataExtension (COMPLEX) EXP: Check for use of $this->anyVar and replace with $this->anyVar[$this->owner->ID] or consider turning the class into a trait ### @@@@ STOP REPLACEMENT @@@@ ###
Synopsis
class ProductWithVariationDecorator
extends DataExtension
{
- // members
- protected $MyClassnameOfVariations = ProductVariation::class;
- private static string $table_name = 'ProductWithVariationDecorator';
- private static array $has_many = ;
- private static array $many_many = ;
- private static array $many_many_extraFields = ;
- private static array $casting = ;
- // methods
- public string getClassNameOfVariations()
- public bool canDelete()
- public int NumberOfVariations()
- public bool HasVariations()
- public DataObject Product()
- public bool IsProduct()
- public void updateCMSFields()
- public GridField getVariationsTable()
- public bool VariationIsInCart()
- public bool VariationOrProductIsInCart()
- public float LowestVariationPrice()
- public Money LowestVariationPriceAsMoney()
- public string VariationsForSaleJSON()
- public int generateVariationsFromAttributeValues()
- public ProductVariation|Datalist|null getVariationByAttributes()
- public void addAttributeValue()
- public void removeAttributeValue()
- public ProductAttributeType addAttributeType()
- public bool canRemoveAttributeType()
- public void removeAttributeType()
- public array getArrayOfLinkedProductAttributeTypeIDs()
- public array getArrayOfLinkedProductAttributeValueIDs()
- public void onBeforeWrite()
- public void onAfterWrite()
- public void onBeforeDelete()
- public void onAfterDelete()
- public void cleaningUpVariationData()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Tasks
Line | Task |
---|---|
449 | change JS so that we dont have to add this default array element (-1 => -1) |
Members
private
-
$casting
standard SS Var. - $has_many
-
$many_many
standard SS Var. -
$many_many_extraFields
standard SS Var. -
$table_name
### @@@@ START REPLACEMENT @@@@ ### OLD: private static $has_many = (case sensitive) NEW: private static $has_many = (COMPLEX) EXP: Check that is class indeed extends DataObject and that it is not a data-extension! ### @@@@ STOP REPLACEMENT @@@@ ###
protected
-
$MyClassnameOfVariations
### @@@@ START REPLACEMENT @@@@ ### WHY: automated upgrade OLD: classNameOfVariations (case sensitive) NEW: MyClassnameOfVariations (COMPLEX) EXP: This has been replaced to avoid confusions with replacements of className / class ### @@@@ STOP REPLACEMENT @@@@ ###
Methods
public
- HasVariations() — tells you whether the product has any variations.
- IsProduct() — tells you whether the current object is a product seems a bit silly, but it can be useful as other buyables can return false from this method.
- LowestVariationPrice() — returns lowest cost variation price for use in FROM XXX.
- LowestVariationPriceAsMoney()
- NumberOfVariations() — tells you the number of variations this product has.
- Product() — this method is really useful when you mix Products and Product Variations That is, in a template, you might have something like $Buyable.Product With the method below, this will work BOTH if the Buyable is a Product and a product Varation.
- VariationIsInCart() — tells us if any of the variations, related to this product, are currently in the cart.
- VariationOrProductIsInCart() — tells us if any of the variations, related to this product, OR the product itself, is currently in the cart.
- VariationsForSaleJSON() — returns a list of variations for sale as JSON.
- addAttributeType() — add an attribute type to the product.
- addAttributeValue()
- canDelete() — standard SS method.
- canRemoveAttributeType()
- cleaningUpVariationData() — based on the ProductVariations for the products removing non-existing Product_VariationAttributes adding existing Product_VariationAttributes.
- generateVariationsFromAttributeValues() — The array provided needs to be TypeID => arrayOfValueIDs TypeID => arrayOfValueIDs TypeID => arrayOfValueIDs you can also make it: NameOfAttritbuteType => arrayOfValueIDs OR: NameOfAttritbuteType => arrayOfValueNames e.g.
- getArrayOfLinkedProductAttributeTypeIDs() — return an array of IDs of the Attribute Types linked to this product.
- getArrayOfLinkedProductAttributeValueIDs() — return an array of IDs of the Attribute Types linked to this product.
- getClassNameOfVariations() — returns what class do we use for Variations.
- getVariationByAttributes() — returns the matching variation if any.
- getVariationsTable() — Field to add and edit product variations.
- onAfterDelete()
- onAfterWrite()
- onBeforeDelete()
- onBeforeWrite() — set price to lowest variation if no price.
- removeAttributeType()
- removeAttributeValue()
- updateCMSFields() — standard SS method.