Version: current

     1 <?php
     2 /**
     3  * Сопутствующие товары к товару
     4  *
     5  * @author menedem
     6  */
     7 class ProductProductLinkedDecorator extends DataObjectDecorator {
     8
     9     static function add_extension($class='Product') {
    10         Object::add_extension($class, 'ProductProductLinkedDecorator');
    11     }
    12
    13     function extraStatics() {
    14         return array(
    15             'many_many' => array(
    16                 'LinkedProducts' => 'Product',
    17             )
    18         );
    19     }
    20
    21     function updateCMSFields(FieldSet &$fields) {
    22         $m = new ManyManyDataObjectManager(
    23             $this->owner,
    24             'LinkedProducts',
    25             'Product',
    26             array('Title' => 'Товар'),
    27             new FieldSet(),
    28             '"ClassName" = \'Product\' AND "SiteTree"."ID" <> ' . $this->owner->ID
    29         );
    30         $m->setPermissions(array());
    31         $fields->findOrMakeTab('Root.Content.LinkedProducts', 'Связанные товары');
    32         $fields->addFieldToTab("Root.Content.LinkedProducts", $m);
    33
    34     }
    35
    36     static $showProductCount = 10;
    37
    38     static function setShowProductCount($value) {
    39         self::$showProductCount = $value;
    40     }
    41
    42     static function getShowProductCount() {
    43         return self::$showProductCount;
    44     }
    45
    46     /**
    47      * Получение связнанных(с текущим продуктом) продуктов
    48      *
    49      * @return DataObjectSet
    50      */
    51      /*
    52     function LinkedProducts() {
    53         return $this->owner->LinkedProducts();
    54     }
    55     */
    56 }

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