Version: current

     1 <?php
     2
     3 /**
     4  * Выбор товара в админке
     5  *
     6  * @package cart
     7  * @author dvp
     8  */
     9 class OrderItemField extends TreeDropdownField {
    10
    11     public function __construct($name, $title = null) {
    12         $_REQUEST['filter'] = 'CMSSiteTreeFilter_Search';
    13
    14         parent::__construct($name, $title, 'SiteTree', 'ID', 'Title', true);
    15 //      $this->setTreeBaseID(DataObject::get_one('StartCatalog')->ID);
    16         $this->setFilterFunction(array('OrderItemField', 'tree_filter'));
    17         $this->setSearchFunction(array('OrderItemField', 'tree_search'));
    18     }
    19
    20     public function Field() {
    21         $res = parent::Field();
    22         Requirements::javascript('cart/javascript/OrderItemField.js');
    23         Requirements::css('cart/css/OrderItemField.css');
    24         return $res;
    25     }
    26
    27     public static function tree_filter($node) {
    28         return ($node->ClassName == 'Catalog' || $node->ClassName == 'StartCatalog' || $node->ClassName == 'Product');
    29     }
    30
    31     public static function tree_search($class, $field, $search) {
    32         return DataObject::get('Product', "\"Title\" LIKE '%$search%' OR Import LIKE '$search%'");
    33     }
    34 }
    35

[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. -