Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogFilter
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • FlowerGarden_Size
  • ForeignKey
  • Hierarchy
  • HouseCatalogProductDecorator
  • HTMLText
  • HTMLVarchar
  • Import1CLog
  • Import1CLog_File
  • Import1CLog_Item
  • Import1CLog_Task
  • ImportCatalog1C_PriceType
  • ImportCatalog1C_ProductProp
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MonumentGalleryItem
  • MonumentPhotoGallery
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • Notification
  • OrderDataObject
  • OrderDecorator
  • OrderHandlersDecorator
  • OrderItemDecorator
  • OrderItemVariationDecorator
  • Orders1CExchange_OrdersDecorator
  • OrderService
  • OrderServiceOrder
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • Person
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PortraitType
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • ProductImportLog
  • ProductImportLog_Item
  • ProductParam
  • ProductParamValue
  • ProductVariation
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
  1 <?php
  2 // Параметр категории - определение параметров товара в этой категории
  3 class ProductParam extends DataObject {
  4     static $db = array(
  5         'Title' => 'Varchar(250)',
  6         'TechTitle' => 'Varchar(50)',
  7         'Type' => "Enum('text, number, bool')",
  8         'ShowInList' => 'Boolean', //Показывать в списке товаров 
  9         'ShowInView' => 'Boolean', //Показывать в карточке товара      
 10         'Sort' => 'Int', //Сортировка в карточке товара, если не указана берется максимальная + 1
 11         'ShowDefault' => 'Boolean',     
 12         //'Important' => 'Boolean', // пока не используем       
 13         'PossibleValues' => 'Text', // возможные значения (через \n)
 14         'MultiValues' => 'Boolean',
 15         'ParamForVariation' => 'Boolean', // этот параметр может использоваться в вариациях товара
 16     );
 17     
 18     static $has_one = array(
 19         'ParentCatalog' => 'Catalog'
 20     );
 21     
 22     static $belongs_many_many = array(
 23         'Catalogs' => 'Catalog'
 24     );
 25     
 26     static $defaults = array(
 27         'Type' => 'text',
 28         'ShowInView' => 1,
 29     );
 30     
 31     function fieldLabels($relations = true) {       
 32         $labels = parent::fieldLabels($relations);
 33         $labels['LocalType'] = $labels['Type'];     
 34         return $labels;
 35     }
 36     
 37     static $default_sort = 'Sort ASC, Title ASC'; //Important DESC, 
 38     
 39     static $searchable_fields = array('Title', 'TechTitle', 'Type', 'ShowDefault', 'Sort');
 40     
 41     static $summary_fields = array('Title', 'TechTitle', 'LocalType', 'ShowDefault', 'Sort');
 42 
 43     static function getParamTypes() {
 44         $types = array();
 45         foreach(singleton('ProductParam')->dbObject('Type')->enumValues() as $val) {
 46             $types[$val] = _t('ProductParam.Type_' . $val);
 47         }
 48         return $types;      
 49     }
 50     
 51     // группируем разные значения одного параметра (если ProductParam->MultiValues == true) в строку через запятую
 52     static function group_values_list($list) {
 53         if ($list) {
 54             $rs = array();
 55             foreach($list as $value) {
 56                 if (isset($rs[$value->ProductParamID])) {
 57                     $rs[$value->ProductParamID]->Value .= ", {$value->Value}";
 58                 } else {
 59                     $rs[$value->ProductParamID] = $value;
 60                 }
 61             }
 62             return new DataObjectSet($rs);
 63         }
 64         return false;
 65     }
 66     
 67     /**
 68      * Единица измерения параметра
 69      * Доработать, ?создать поле?, добавить проверку в фильтрах - если там нет Unit, брать тут
 70      * 
 71      * @return string
 72      */
 73     
 74     function getUnit() {
 75         return 'м';
 76     }
 77     
 78     function getLocalType() {
 79         $types = self::getParamTypes();
 80         return $types[$this->Type];
 81     }
 82     
 83     function populateDefaults() {
 84         parent::populateDefaults();
 85         $this->TechTitle = 'param' . (DB::query("select max(ID) from ProductParam")->value() + 1);
 86         $this->Sort = $max = DB::query("select max(Sort) from ProductParam")->value() + 1;
 87     }
 88     
 89     function getCMSFields() {
 90         $fields = parent::getCMSFields();
 91         $fields->replaceField('Type', new DropdownField('Type', $this->fieldLabel('Type'), self::getParamTypes(), $this->Type));    
 92         $fields->replaceField('ParentCatalogID', new HiddenField('ParentCatalogID', $this->fieldLabel('ParentCatalog')));
 93         $fields->removeByName('Catalogs');
 94         if (!Catalog::$use_variations) {
 95             $fields->removeByName('ParamForVariation');
 96         }
 97         return $fields;
 98     }
 99     
100     function onBeforeDelete() {
101         parent::onBeforeDelete();
102         // Удаляем значения этого параметра
103         if ($oldParamValues = DataObject::get('ProductParamValue', "ProductParamID = {$this->ID}")) {
104             foreach($oldParamValues as $oldParamValue)
105                 $oldParamValue->delete();
106         }
107     }
108     
109     function PossibleValuesList() {
110         if (trim($this->PossibleValues)) {          
111             $values = array();
112             foreach(explode("\n", $this->PossibleValues) as $value) {
113                 if ($val = trim($value)) {
114                     $values[$val] = $val;                   
115                 }
116             }           
117             return $values;
118         }
119         return false;
120     }
121 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0