Blame view

frontend/views/catalog/product.php 14.2 KB
055ecc3b   Karnovsky A   Karnovsky 11052016
1
  <?php
e608c5f7   Yarik   Comment added
2
3
4
5
6
      use common\modules\comment\models\Comment;
      use common\modules\comment\models\Rating;
      use common\modules\comment\widgets\CommentWidget;
      use kartik\rating\StarRating;
      use yii\widgets\Breadcrumbs;
ccc7a9d3   Karnovsky A   Karnovsky 12052016
7
8
  use yii\web\View;
  use yii\helpers\Url;
1f3add0a   Dmytry Fedorchuk   All seo
9
  use frontend\widgets\Seo;
e608c5f7   Yarik   Comment added
10
      
1f3add0a   Dmytry Fedorchuk   All seo
11
12
13
14
15
16
  $this->params['seo']['key'] = $product->category->categoryName->value;
  $this->params['seo']['fields']['name'] = $product->fullname;
  $this->params['seo']['h1'] = !empty(Seo::widget([ 'row'=>'h1'])) ? Seo::widget([ 'row'=>'h1']) : $product->fullname;
  
  //$this->params['seo']['title'] =  "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
  //$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
060b4806   Karnovsky A   -
17
18
19
  $this->title = $product->fullname;
  //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname;
  //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]);
ccc7a9d3   Karnovsky A   Karnovsky 12052016
20
21
  //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
  
8724ec1f   Karnovsky A   -
22
23
24
25
  //foreach($product->category->getParents()->all() as $parent) {
  //    $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
  //}
  $this->params['breadcrumbs'][] = ['label' => 'Каталог', 'url' => ['catalog/category']];
055ecc3b   Karnovsky A   Karnovsky 11052016
26
  $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]];
c7852657   Karnovsky A   -
27
  $this->params['breadcrumbs'][] = $product->fullname .' #'. $product->enabledVariants[0]->sku;
055ecc3b   Karnovsky A   Karnovsky 11052016
28
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
29
  $this->registerJs ('
055ecc3b   Karnovsky A   Karnovsky 11052016
30
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
31
32
          var checkData = function($index)
          {
f307b0a8   Karnovsky A   -
33
34
35
36
              var sourceNew = $(".productLeftBar .product_mod > li").eq($index);
              $(".productLeftBar .product_mod > li").removeClass("active")
              sourceNew.addClass("active");
              var $source = sourceNew.find("a");
ccc7a9d3   Karnovsky A   Karnovsky 12052016
37
              var $target = $(".productLeftBar .cost_box");
055ecc3b   Karnovsky A   Karnovsky 11052016
38
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
39
40
              $("#cost").text($source.data("cost"));
              $("#old_cost").text($source.data("old_cost"));
055ecc3b   Karnovsky A   Karnovsky 11052016
41
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
42
43
44
45
46
47
48
49
              if (parseInt ($source.data("old_cost")) == 0)
              {
                  $target.find("strike").hide();
              }
              else
              {
                  $target.find("strike").show();
              }
055ecc3b   Karnovsky A   Karnovsky 11052016
50
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
51
52
53
54
55
56
              $("#product_id").val($source.data("id"));
              $("#art").text($source.data("art"));
              $("#color").text($source.data("color"));
              $("#pic").attr("src",$source.data("image"));
              $("#picoriginal").attr("href",$source.data("imageoriginal"));
          }
055ecc3b   Karnovsky A   Karnovsky 11052016
57
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
58
59
60
          $(".product_mod > li").click(function()
          {
              checkData($(this).index());
055ecc3b   Karnovsky A   Karnovsky 11052016
61
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
62
              Shadowbox.setup($("#picoriginal"));
055ecc3b   Karnovsky A   Karnovsky 11052016
63
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
64
65
              return false;
          });
055ecc3b   Karnovsky A   Karnovsky 11052016
66
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
          checkData(0);
  
      ', View::POS_READY, 'fasovka');
  
  $this->registerJs ("
          $('#nav_product li a').addClass('active');
          $('#nav_product li').find('.info').toggle();
  
          $('#nav_product li a').bind('click',function()
          {
              if($(this).parent().find('.info').css('display')=='none')$(this).addClass('active');
              else $(this).removeClass('active');
              $(this).parent().find('.info').toggle();
  
              return false;
          });
      ", View::POS_READY, 'nav_product');
  
  $this->registerCssFile (Yii::$app->request->BaseUrl . '/js/shadowbox-3.0.3/shadowbox.css');
3a8a9bd9   Administrator   image size
86
  $this->registerJsFile (Yii::$app->request->baseUrl . '/js/shadowbox-3.0.3/shadowbox.js', ['position' => View::POS_END, 'depends' => ['yii\web\JqueryAsset']]);
ccc7a9d3   Karnovsky A   Karnovsky 12052016
87
88
89
90
91
92
  $this->registerJs ("
          Shadowbox.init({
  
      });
      ", View::POS_READY, 'Shadowbox');
  ?>
e608c5f7   Yarik   Comment added
93
      
ccc7a9d3   Karnovsky A   Karnovsky 12052016
94
95
  <nav class="bread-crumbs">
      <?= Breadcrumbs::widget ([
8724ec1f   Karnovsky A   -
96
97
98
          'links' => $this->params['breadcrumbs'],
      ])
      ?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
99
100
101
102
103
104
      <div class="both"></div>
  </nav>
  <?php if ($flash = Yii::$app->session->getFlash ('success')): ?>
      <div class="alert-success"><?= $flash ?></div>
  <?php endif; ?>
  <div class="loyout">
bd406ee6   Eugeny Galkovskiy   123
105
      <div itemscope itemtype="http://schema.org/Product">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
106
      <div class="productLeftBar">
bd406ee6   Eugeny Galkovskiy   123
107
          <div itemprop="name"><h1><?= Seo::widget([ 'row'=>'h1'])?></h1></div>
c7852657   Karnovsky A   -
108
109
          <?php foreach($product->enabledVariantsGrouped as $variantGroup) :?>
          <div class="begin"><?= $variantGroup->name2?></div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
110
          <ul class="product_mod">
c7852657   Karnovsky A   -
111
              <?php foreach ($variantGroup->_variants as $variant): ?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
112
                  <li>
83be3cfb   Karnovsky A   -
113
                      <a id='m<?= $variant->product_variant_id ?>' href="#<?=$variant->product_variant_id ?>"
ccc7a9d3   Karnovsky A   Karnovsky 12052016
114
115
116
                         data-cost="<?= $variant->price ?>"
                         data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>"
                         data-color="<?= $variant->name ?>"
f307b0a8   Karnovsky A   -
117
                         data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
dc2cd017   Karnovsky A   -
118
                         data-imageoriginal="<?= $variant->imageUrl ?>"
060b4806   Karnovsky A   -
119
                         title="<?= $product->fullname ?>">
d0108705   Dmytry Fedorchuk   All seo
120
121
122
                          <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', ['alt' => $product->category->categoryName->value . ' ' .
                              $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
                              $product->fullname])?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
123
124
125
                      </a>
                  </li>
              <?php endforeach; ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
126
          </ul>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
127
          <div class="both"></div>
c7852657   Karnovsky A   -
128
          <?php endforeach; ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
129
  
73bc07bd   Виталий   Веталь
130
          <div class="cost_box product_read_">
bd406ee6   Eugeny Galkovskiy   123
131
              <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
132
              <div class='params'>код: <span id='art'></span><br/> цвет: <span id='color'></span></div>
f307b0a8   Karnovsky A   -
133
134
              <div class="product_read_price">
                  <div class="w">
bd406ee6   Eugeny Galkovskiy   123
135
136
137
                      <strike><span itemprop="price"><span id='old_cost'>0</span></span> грн.</strike>
                      <span class="cost"><span itemprop="price"><span id='cost'>0</span></span> <span class="valute">грн.</span></span>
                      <meta itemprop="priceCurrency" content = "UAH">
f307b0a8   Karnovsky A   -
138
139
                  </div>
                  <input type='hidden' id='product_id'/>
d0108705   Dmytry Fedorchuk   All seo
140
                  <a href="#" rel='product' class="link_buy fl">Купить</a>
f307b0a8   Karnovsky A   -
141
                  <div class="both"></div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
142
              </div>
bd406ee6   Eugeny Galkovskiy   123
143
              </div>
1c8ebc91   Karnovsky A   Share functional
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  
              <div class="product_service">
                  <ul>
                  <?php if (Yii::$app->user->id) :?>
                      <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a></li>
                  <?php endif?>
                  <?php if (FALSE && Yii::$app->user->id) :?>
                      <li class="item2"><a href="<?= Url::to (['iam/price', 'id' => $product->product_id]) ?>">Узнать о снижение цены</a></li>
                  <?php endif?>
                  <?php if (FALSE) :?>
                      <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в сравнение</a></li>
                  <?php endif?>
                  </ul>
              </div>
e608c5f7   Yarik   Comment added
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
              <div class="artbox_comment_description">
                  <?php
                  if(!empty($product->averageRating)) {
                      echo StarRating::widget([
                          'name'          => 'rating_product',
                          'value'         => $product->averageRating->value,
                          'pluginOptions' => [
                              'displayOnly' => true,
                              'size'        => 'xxs',
                              'min'         => 0,
                              'max'         => 5,
                              'stars'       => 5,
                          ],
                      ]);
                  }
                  ?>
                  <p><a href="#artbox-comment">
                          <?php
                              $comment_count = count($product->comments);
                              if($comment_count) {
                                  echo "Отзывов: ".$comment_count;
                              } else {
                                  echo "Оставть отзыв";
                              }
                          ?>
                      </a></p>
              </div>
d0108705   Dmytry Fedorchuk   All seo
185
186
              <br>
              <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
055ecc3b   Karnovsky A   Karnovsky 11052016
187
          </div>
7d9935e2   Administrator   проапдейтил роли
188
          <?php /*
ccc7a9d3   Karnovsky A   Karnovsky 12052016
189
190
191
192
193
194
195
196
197
          <div class="product_service">
              <ul>
                  <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a>
                  </li>
                  <li class="item2"><a href="<?= Url::to (['iam/price', 'id' => $product->product_id]) ?>">Узнать о снижение
                          цены</a></li>
                  <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в
                          сравнение</a></li>
              </ul>
7d9935e2   Administrator   проапдейтил роли
198
          </div>*/?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
199
      </div>
055ecc3b   Karnovsky A   Karnovsky 11052016
200
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
201
202
203
204
205
      <div class="productRightBar">
          <ul id="nav_product">
              <li><a href="#">Характеристики</a>
                  <div class="info">
                      <p>Бренд: <?= $product->brand->name ?></p>
c7852657   Karnovsky A   -
206
                      <?php foreach ($product->properties as $group): ?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
207
208
                          <p><?= $group->name ?> <?php foreach($group->_options as $option) :?>&nbsp;<?= $option->ValueRenderHTML?><?php endforeach?></p>
                      <?php endforeach; ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
209
                  </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
210
211
              </li>
              <li><a href="#">Описание</a>
bd406ee6   Eugeny Galkovskiy   123
212
                  <div itemprop="description"> <div class="info">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
213
                      <?= $product->description ?>
bd406ee6   Eugeny Galkovskiy   123
214
                  </div></div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
215
              </li>
2e9ea16e   Karnovsky A   -
216
              <?php if(!empty($product->video) && strpos($product->video, '.jpg') === FALSE && strpos($product->video, '.png') === FALSE) :?>
f307b0a8   Karnovsky A   -
217
218
                  <li><a href="#">Видео</a>
                      <div class="info product-thumb-video">
2e9ea16e   Karnovsky A   -
219
220
221
222
223
                          <?php if (strpos($product->video, '<iframe') !== FALSE || strpos($product->video, '<object') !== FALSE) :?>
                              <?= $product->video?>
                          <?php else :?>
                              <?= \cics\widgets\VideoEmbed::widget(['responsive' => false, 'url' => $product->video]) ?>
                          <?php endif?>
f307b0a8   Karnovsky A   -
224
225
226
                      </div>
                  </li>
              <?php endif?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
227
228
          </ul>
      </div>
bd406ee6   Eugeny Galkovskiy   123
229
      </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
230
      <div class="content">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
231
232
          <div class="pic">
              <center>
d0108705   Dmytry Fedorchuk   All seo
233
234
235
                  <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'product_view',['id'=>'pic', 'alt' => $product->category->categoryName->value . ' ' .
                          $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
                          $product->fullname])?></a>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
236
              </center>
055ecc3b   Karnovsky A   Karnovsky 11052016
237
          </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
238
239
          <ul class="product_colors">
              <?php foreach ($product->images as $image): ?>
2f93d129   Karnovsky A   -
240
                  <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
d0108705   Dmytry Fedorchuk   All seo
241
242
243
                          <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2',['alt' => $product->category->categoryName->value . ' ' .
                              $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
                              $product->fullname])?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
244
245
246
                      </a></li>
              <?php endforeach; ?>
          </ul>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
247
248
      </div>
      <div class="both"></div>
e608c5f7   Yarik   Comment added
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      <div class="comment-wrapper">
          <?php
              echo CommentWidget::widget([
                      'comment_class' => Comment::className(),
                      'rating_class' => Rating::className(),
                      'success_text' => 'Комментарий успешно добавлен',
                      'class_options' => [
                          'scenario' => \Yii::$app->user->isGuest?Comment::SCENARIO_GUEST:Comment::SCENARIO_USER,
                          'status' => Comment::STATUS_ACTIVE,
                          'user_id' => \Yii::$app->user->isGuest?NULL:\Yii::$app->user->id,
                      ],
                      'model' => $product->className(),
                      'model_id' => $product->product_id,
                      'list_options'  => [
                          'view' => 'list-comment-review',
                      ],
                      'form_options'  => [
                          'view' => 'form-comment-review',
                          'tag'  => 'span',
                      ],
                      'options'       => [
                          'class' => 'proektant-comments-wr style',
                          'id' => 'artbox-comment',
                      ],
                  ]);
          ?>
      </div>
      
e9f291a5   Karnovsky A   Similar products ...
277
      <?= \common\modules\product\widgets\similarProducts::widget(['product' => $product])?>
4902c747   Karnovsky A   -
278
279
280
281
      <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'promo'])?>
      <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'new'])?>
      <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'top'])?>
      <?= \common\modules\product\widgets\lastProducts::widget()?>
463e6d52   Виталий   Веталь
282
  </div>
85235ea6   Виталий   Веталь
283
  <?php
2fcc30a0   Виталий   Веталь
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  $this->registerJs ("
        var productHash = window.location.hash;
              productHash = productHash.replace('#','')
  
              var productUl = $('ul.product_mod li')
              var productA = productUl.find('a#'+productHash)
              productUl.removeClass('active')
              productA.parent().addClass('active')
              var dataLink = productA.attr('data-imageoriginal')
              var dataImg = productA.attr('data-image')
  
              $('#pic').attr('src',dataImg)
              $('#pic').parent().attr('href',dataLink)
      ", View::POS_READY, 'new_script');
  ?>