diff --git a/helpers/ProductHelper.php b/helpers/ProductHelper.php index 0e7a79a..754fb50 100755 --- a/helpers/ProductHelper.php +++ b/helpers/ProductHelper.php @@ -4,6 +4,7 @@ use artweb\artbox\ecommerce\models\Category; use artweb\artbox\ecommerce\models\Product; + use artweb\artbox\ecommerce\models\ProductVariant; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; use yii\base\Object; @@ -179,6 +180,23 @@ $product->id, ] ); + + + $query->andWhere([ + '>=', + ProductVariant::tableName() . '.price', + ($product->variant->price * 0.8), + ]); + + + $query->andWhere([ + '<=', + ProductVariant::tableName() . '.price', + ($product->variant->price * 1.2), + ]); + + + $query->groupBy('product.id'); $query->limit($count); return $query; diff --git a/widgets/similarProducts.php b/widgets/similarProducts.php index fbcc712..67ce843 100755 --- a/widgets/similarProducts.php +++ b/widgets/similarProducts.php @@ -22,8 +22,9 @@ public function run() { - $products = ProductHelper::getSimilarProducts($this->product, $this->count); - + $products = ProductHelper::getSimilarProducts($this->product, $this->count)->all(); + + if (!$this->title) { $this->title = Yii::t('product', 'Similar products'); } diff --git a/widgets/views/product_smart.php b/widgets/views/product_smart.php index a4064a3..340993a 100755 --- a/widgets/views/product_smart.php +++ b/widgets/views/product_smart.php @@ -1,111 +1,260 @@ -
-
-
- -
- lang->title, - Url::to( - [ - 'catalog/product', - 'product' => $product->lang->alias, - ] - ), - [ 'class' => 'btn-product-details' ] - ) ?> -
-
- +
+ is_discount) { + echo Html::tag( + 'div', + Html::tag('span', \Yii::t('app', 'акция')), + [ + 'class' => 'sale_bg', + ] + ); + } + if ($model->is_top) { + echo Html::tag( + 'div', + Html::tag('span', \Yii::t('app', 'top')), + [ + 'class' => 'top_bg', + ] + ); + } + if ($model->is_new) { + echo Html::tag( + 'div', + Html::tag('span', \Yii::t('app', 'new')), + [ + 'class' => 'new_bg', + ] + ); + } + ?> +
+
+ $fullname, + 'title' => $fullname, + ], + 90, + true + ), + [ + 'catalog/product', + 'product' => $model->lang->alias, + 'variant' => $firstImage[ 'sku' ], + ], + [ + 'data-pjax' => 0, + 'title' => $fullname, + ] + ); + ?> +
+ $model->lang->alias, + 'variant' => $variant->sku, + ], + [ + 'class' => 'style title_cat', + 'data-pjax' => 0, + 'title' => $model->lang->title, + ] + ); + ?> +

+ brand) ?$model->brand->lang->title:''; + ?> +

+
+ price_old )) { + ?> +

+ price_old; ?> + price; + ?> + грн. +

+
+ -price * 100 / $variant->price_old )); ?> % +
+ +

+ price; + ?> + +

+ +
+
+ -
-
- Цена: - - variant->price ?> - грн - -
-
-
-
Особенности
-
-
-
    - -
  • Бренд: brand->lang->title ?>
  • - - getProperties() as $group): ?> -
  • - lang->title ?> customOptions as $option ) : ?> lang->value ?> -
  • - - - -
-
-
-
- +
+
+
+
$model->lang->alias, + 'variant' => $variant->sku, + '#' => 'video', + ], + [ + 'class' => 'videos_btn' . ( empty( $model->videos ) ? ' disabled' : '' ), + ] + ) + ?>
+
+
+
    "> '; - - // есть скидка - echo '

    '; - if ($product->enabledVariants[ 0 ]->price_old != 0 && $product->enabledVariants[ 0 ]->price_old != $product->enabledVariants[ 0 ]->price) { - echo '' . $product->enabledVariants[ 0 ]->price_old . ' грн. '; - echo $product->enabledVariants[ 0 ]->price . ' грн.

    '; - } else { - echo '' . $product->enabledVariants[ 0 ]->price . ' грн.

    '; + foreach ($imageMap as $item) { + if (!empty( $item )) { + echo Html::tag( + 'li', + Html::a( + ArtboxImageHelper::getImage( + '/storage/white.jpg', + 'category_thumb', + [ + 'alt' => $model->lang->title, + 'title' => $model->lang->title, + 'class' => 'artbox-lazy-event', + 'data-original' => ArtboxImageHelper::getImageSrc(current($item), 'category_thumb', null, 90), + ], + 10 + ), + [ + 'catalog/product', + 'product' => $model->lang->alias, + 'variant' => key($item), + ], + [ + 'data-pjax' => 0, + ] + ) + ); } - echo ''; - echo '
'; - + } ?> - + +
+
+
-
-
\ No newline at end of file + endCache(); }?> \ No newline at end of file diff --git a/widgets/views/products_block.php b/widgets/views/products_block.php index ba647d7..5989208 100755 --- a/widgets/views/products_block.php +++ b/widgets/views/products_block.php @@ -1,35 +1,41 @@ - -
-
- -
- - render('product_smart', [ 'product' => $product ]); ?> - +if (!empty($products)) { + ?> +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
-
- registerJs($js, View::POS_READY); - ?> - \ No newline at end of file + \ No newline at end of file -- libgit2 0.21.4