Commit 71bd843eef31b26aacd35c8a827c3450807a9731
1 parent
5de26717
-Some fixes
Showing
3 changed files
with
14 additions
and
2 deletions
Show diff stats
common/modules/product/models/Product.php
... | ... | @@ -208,6 +208,17 @@ |
208 | 208 | // return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png'; |
209 | 209 | } |
210 | 210 | |
211 | + public function getMainImageUrl() | |
212 | + { | |
213 | + $image = $this->getImage()->andWhere([ | |
214 | + 'product_variant_id' => NULL, | |
215 | + ])->one(); | |
216 | + if(!empty($image)) { | |
217 | + return $image->imageUrl; | |
218 | + } | |
219 | + return null; | |
220 | + } | |
221 | + | |
211 | 222 | /** |
212 | 223 | * @return \yii\db\ActiveQuery |
213 | 224 | */ | ... | ... |
frontend/views/catalog/_product_list.php
... | ... | @@ -21,8 +21,9 @@ use yii\widgets\ListView; |
21 | 21 | 'product' => $model->alias, |
22 | 22 | 'variant' => $model->variant->sku, |
23 | 23 | ])?>"> |
24 | + <div class="picture" style="background-image:url('<?php echo ArtboxImageHelper::getImageSrc($model->getImageUrl(), 'product_list_item'); ?>');"></div> | |
24 | 25 | <?php |
25 | - echo ArtboxImageHelper::getLazyDiv($model->getImageUrl(), 'product_list_item', ['class' => 'picture']); | |
26 | +// echo ArtboxImageHelper::getLazyDiv($model->getImageUrl(), 'product_list_item', ['class' => 'picture']); | |
26 | 27 | ?> |
27 | 28 | <div class="title_1"><?php echo $model->name; ?></div> |
28 | 29 | <div class="title_2"><?php echo $model->variant->sku; ?></div> | ... | ... |
frontend/views/category/collection.php
... | ... | @@ -54,7 +54,7 @@ $this->params['breadcrumbs'][] = $this->title; |
54 | 54 | 'variant' => $product->variant->sku, |
55 | 55 | ]); ?>" alt="nabuco"> |
56 | 56 | <div class="label"><span><?php echo $product->name; ?></span></div> |
57 | - <?php echo ArtboxImageHelper::getImage($product->getImageUrl(), 'collections_thumb');?> | |
57 | + <?php echo ArtboxImageHelper::getImage($product->getMainImageUrl(), 'collections_thumb');?> | |
58 | 58 | </a> |
59 | 59 | <?php } ?> |
60 | 60 | </div> | ... | ... |