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

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • 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

  • Catalog
  • CatalogAdmin
  • CatalogBaseFiltersExtension
  • CatalogCMSActionDecorator
  • CatalogPrice
  • CatalogSiteConfig
  • CMSSiteTreeFilter_Catalog
  • Orders1CExchangeSiteConfig
  • PaymentType
  • Product
  • ProductSearchPage
  • SimpleOrderButton
  • SimpleOrderData
  • SimpleOrderPage
  • StartCatalog
  • VirtualProduct

Interfaces

  • OrderButtonInterface
 1 <?php
 2 
 3 /**
 4  * Настройки для каталога
 5  *
 6  * @package Catalog
 7  * @author inxo, menedem, dvp
 8  */
 9 class CatalogSiteConfig extends SiteConfigDecorator {
10 
11     static $hidden_fields  = array();
12     
13     function extraStatics() {
14         return array(
15             'db' => array(
16                 'ProductPerPage' => 'Int', // товаров на страницу каталога
17                 'CatalogCurrency' => 'Varchar', // Валюта
18                 'CatalogDiscountCeil' => 'Boolean', // Округление до целых
19                 'CatalogDefaultSort' => 'Varchar', // Сортировка товаров по-умолчанию
20                 'CatalogDefaultView' => 'Varchar', // Отображение товаров по-умолчанию
21                 'CatalogDefaultFilter' => 'Varchar(255)', // поля фильтра товаров по-умолчанию
22                 'ProductShowInTree' => 'Boolean', // флаг показывать товары в дереве (для ручной сортировки) - требует наличия варианта ручной сортировки в Catalog::$sort_options
23             ),
24             'defaults' => array(
25                 'ProductPerPage' => 20,
26                 'CatalogCurrency' => 'руб.',
27                 'CatalogDiscountCeil' => true,
28                 'CatalogDefaultSort' => 'title',
29                 'CatalogDefaultView' => 'table',
30                 'CatalogDefaultFilter' => 'Title,Price',
31                 'ProductShowInTree' => false,
32             )
33         );
34     }
35 
36     public function updateCMSFields(FieldSet &$fields) {
37         $tab = self::get_config_tab($fields, 'Catalog');
38         
39         $tab->push(new NumericField('ProductPerPage', $this->owner->FieldLabel('ProductPerPage')));
40         $tab->push(new TextField('CatalogCurrency', $this->owner->FieldLabel('CatalogCurrency')));
41         $tab->push(new CheckboxField('CatalogDiscountCeil', $this->owner->FieldLabel('CatalogDiscountCeil')));
42 
43         if (count(Product::get_sort_options()) > 1)
44             $tab->push(new DropDownField('CatalogDefaultSort', $this->owner->FieldLabel('CatalogDefaultSort'), Product::sort_options_dropdown_map()));
45 
46         if (count(Catalog::get_view_options()) > 1)
47         $tab->push(new DropDownField('CatalogDefaultView', $this->owner->FieldLabel('CatalogDefaultView'), Catalog::view_options_dropdown_map()));
48 
49         if (Product::filter_fields_list())
50             $tab->push(new CheckboxSetField('CatalogDefaultFilter', $this->owner->fieldLabel('CatalogDefaultFilter'), Product::filter_fields_list()));
51             
52         if (Director::IsDev())
53             $tab->push(new CheckboxField('ProductShowInTree', $this->owner->FieldLabel('ProductShowInTree')));
54             
55         $this->hideUnselectedFields($fields);       
56     }
57     
58     /**
59      * Проверка изменения галочки 'Показывать товары как страницы сайта' и обновление товаров в соответствии с ней
60      */
61     public function onBeforeWrite() {
62         parent::onBeforeWrite();
63         if ($this->owner->isChanged('ProductShowInTree')) {
64             $state = (1 - $this->owner->ProductShowInTree);
65             // черновые версии товаров
66             DB::query("UPDATE `Page` SET `ShowOnlyInTab` = {$state} WHERE `ID` in (SELECT `ID` FROM `Product`)");           
67             // опубликованные товары
68             DB::query("UPDATE `Page_Live` SET `ShowOnlyInTab` = {$state} WHERE `ID` in (SELECT `ID` FROM `Product_Live`)");         
69         }       
70     }
71 }
72 
[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.1 API Docs API documentation generated by ApiGen 2.8.0