Version: current

     1 <?php
     2 /**
     3  * Расширение каталога для страницы товара для сохранения кук (последних просмотренных товаров)
     4  *
     5  * @author menedem
     6  */
     7 class ShowViewedProductExtention extends Extension {
     8
     9     /**
    10      * Возвращает товары из сохраненной куки
    11      *
    12      * @return DataObjectSet;
    13      */
    14     function getHistoryProducts() {
    15         $rs = new DataObjectSet();
    16         $products = CookieExtention::get_cookie_data(ViewedProductExtention::$viewed_cookie_name);
    17         if ($products) {
    18             $IDs = explode(',', $products);
    19             foreach($IDs as $id) {
    20                 $product = Dataobject::get_by_id('Product', $id);
    21                 if ($product) {
    22                     $rs->push($product);
    23                 }
    24             }
    25         }
    26         return $rs;
    27     }
    28
    29 }

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