Source of file Option.php
Size: 2,153 Bytes - Last Modified: 2021-12-23T10:10:26+00:00
/var/www/docs.ssmods.com/process/src/code/product/Option.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | <?php /** * Represents an Option for an Attribute, e.g: Small, Medium, Large, Red etc. * Default Options can be created for Attributes, they are pre populated and duplicated into the Product * when the Attribute is added to a Product. Options can be changed for each Product. * Default Options will have a ProductID of 0. * * @author Plato Creative * @copyright Copyright (c) 2017, Plato Creative * @package PlatoEcommerce * @subpackage product */ class Option extends DataObject implements PermissionProvider { private static $singular_name = 'Option'; private static $plural_name = 'Options'; /** * DB fields for this Option * * @var Array */ private static $db = array( 'Title' => 'Varchar(255)', 'Description' => 'Text', 'SortOrder' => 'Int' ); /** * Has one relations for an Option * * @var Array */ private static $has_one = array( 'Attribute' => 'Attribute', //'Product' => 'Product' ); /** * Belongs many many relations for an Option * * @var Array */ private static $belongs_many_many = array( 'Variations' => 'Variation' ); private static $default_sort = 'SortOrder ASC'; public function providePermissions() { return array( 'EDIT_OPTIONS' => 'Edit Options', ); } public function canEdit($member = null) { return Permission::check('EDIT_OPTIONS'); } public function canView($member = null) { return true; } public function canDelete($member = null) { return Permission::check('EDIT_OPTIONS'); } public function canCreate($member = null) { return Permission::check('EDIT_OPTIONS'); } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Variations'); //$fields->removeByName('ProductID'); $fields->removeByName('AttributeID'); $fields->removeByName('SortOrder'); return $fields; } public function onBeforeWrite() { parent::onBeforeWrite(); //$this->ProductID = 0; } } /* class Option_Default extends Option { private static $singular_name = 'Option'; private static $plural_name = 'Options'; public function onBeforeWrite() { parent::onBeforeWrite(); $this->ProductID = 0; } } */ |