diff --git a/common/components/artboximage/ArtboxImageHelper.php b/common/components/artboximage/ArtboxImageHelper.php
index a6c6ae5..0735f98 100755
--- a/common/components/artboximage/ArtboxImageHelper.php
+++ b/common/components/artboximage/ArtboxImageHelper.php
@@ -21,6 +21,7 @@ class ArtboxImageHelper extends Object {
}
public function getPreset($preset) {
+
if (empty(self::$presets)) {
self::$presets = self::getDriver()->presets;
}
diff --git a/common/config/main.php b/common/config/main.php
index ef64fab..5a3ace9 100755
--- a/common/config/main.php
+++ b/common/config/main.php
@@ -98,8 +98,8 @@ return [
],
'slider' => [
'resize' => [
- 'width' => 720,
- 'height' => 340,
+ 'width' => 1400,
+ 'height' => 600,
'master' => null
],
],
diff --git a/common/models/Slider.php b/common/models/Slider.php
index 4ce0975..e1d5520 100755
--- a/common/models/Slider.php
+++ b/common/models/Slider.php
@@ -65,4 +65,24 @@ class Slider extends \yii\db\ActiveRecord
{
return $this->hasMany(SliderImage::className(), ['slider_id' => 'slider_id'])->where([SliderImage::tableName().'.status'=>1]);
}
+
+
+ /**
+ * fetch stored image file name with complete path
+ * @return string
+ */
+ public function getImageFile()
+ {
+ return isset($this->image) ? '/storage/slider/' . $this->image : null;
+ }
+
+ /**
+ * fetch stored image url
+ * @return string
+ */
+ public function getImageUrl()
+ {
+ // return a default image placeholder if your source image is not found
+ return isset($this->image) ? '/storage/slider/'. $this->image : '/storage/no_photo.png';
+ }
}
diff --git a/common/modules/product/widgets/views/products_block.php b/common/modules/product/widgets/views/products_block.php
index feae4a3..59152aa 100755
--- a/common/modules/product/widgets/views/products_block.php
+++ b/common/modules/product/widgets/views/products_block.php
@@ -12,7 +12,7 @@ use yii\web\View;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
font-weight: bold;">= $title?>
-
+
= $this->render('product_smart', ['product' => $product]);?>
@@ -20,12 +20,12 @@ use yii\web\View;
- registerJs($js, View::POS_READY);
?>
\ No newline at end of file
diff --git a/frontend/controllers/SearchController.php b/frontend/controllers/SearchController.php
new file mode 100755
index 0000000..a60e80c
--- /dev/null
+++ b/frontend/controllers/SearchController.php
@@ -0,0 +1,76 @@
+request->get('word', ''));
+
+ if (!empty($word))
+ {
+
+
+ if( preg_match('/^\+?\d+$/', $word) && (iconv_strlen($word) > 4)){
+
+ $params['keywords'][] = $word;
+
+ $categoriesQuery = Category::find()
+ ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.category_id = '. Category::tableName() .'.category_id')
+ ->innerJoin(Product::tableName(), Product::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id')
+ ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id');
+ $categoriesQuery->andWhere(['ilike', 'product.name', $params['keywords'][0]]);
+ $categories = $categoriesQuery->all();
+
+ } else {
+
+ $params['keywords'] = explode(' ', preg_replace("|[\s,.!:&?~();-]|i", " ", $word));
+
+ foreach($params['keywords'] as $i => &$keyword) {
+ $keyword = trim($keyword);
+ if (empty($keyword)) {
+ unset($params['keywords'][$i]);
+ }
+ }
+ array_unshift($params['keywords'], $word);
+
+ $categoriesQuery = Category::find()
+ ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.category_id = '. Category::tableName() .'.category_id')
+ ->innerJoin(Product::tableName(), Product::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id')
+ ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id');
+ foreach ($params['keywords'] as $keyword) {
+ $categoriesQuery->andWhere(['ilike', 'product.name', $keyword]);
+ }
+ $categoriesQuery->andWhere(['!=', ProductVariant::tableName() .'.stock', 0]);
+ $categories = $categoriesQuery->all();
+ }
+
+ $productModel = new ProductFrontendSearch();
+ $productProvider = $productModel->search(null, $params);
+
+
+ return $this->render(
+ 'index',
+ [
+ 'keywords' => $params['keywords'],
+ 'productModel' => $productModel,
+ 'productProvider' => $productProvider,
+ 'categories' => $categories,
+ ]
+ );
+ }
+ else
+ {
+ throw new HttpException(404, 'Данной странице не существует!');
+ }
+ }
+}
\ No newline at end of file
diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php
index 70586e5..ba6e08a 100755
--- a/frontend/views/catalog/products.php
+++ b/frontend/views/catalog/products.php
@@ -229,22 +229,16 @@ use yii\helpers\Url;
-
+
+ Сортировка:
+ = \yii\widgets\LinkSorter::widget([
+ 'sort' => $productProvider->sort,
+ 'attributes' => [
+ 'price',
+ ]
+ ]);
+ ?>
+
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index 716acea..704e4ca 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -150,17 +150,19 @@ AppAsset::register($this);
+
+