Blame view

common/modules/product/widgets/similarProducts.php 789 Bytes
4253cbec   root   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <?php
  
  namespace common\modules\product\widgets;
  
  use common\modules\product\helpers\ProductHelper;
  use common\modules\product\models\Category;
  use yii\base\Widget;
  use Yii;
  
  class similarProducts extends Widget {
      public $count = 10;
  
      public $title;
  
      public $product;
  
      public function init()
      {
          parent::init(); // TODO: Change the autogenerated stub
      }
  
      public function run() {
          $products = ProductHelper::getSimilarProducts($this->product, $this->count);
  
          if (!$this->title) {
              $this->title = Yii::t('product', 'Similar products');
          }
  
          return $this->render('products_block', [
              'title' => $this->title,
              'class' => 'similar-products',
              'products' => $products,
          ]);
      }
  }