diff --git a/.htaccess b/.htaccess index a08ebbb..026c6cd 100755 --- a/.htaccess +++ b/.htaccess @@ -13,7 +13,6 @@ AddDefaultCharset utf-8 RewriteBase / # deal with admin first - Redirect 301 /Kak_vibrat_ryuksak / Redirect 301 /products/ryukzaki /catalog/ryukzaki Redirect 301 /products/koshel_ki /catalog/koshelki @@ -90,10 +89,8 @@ AddDefaultCharset utf-8 RewriteCond %{THE_REQUEST} \s/+(.+?)/+[?\s] RewriteRule /$ /%1 [R,L] - - -# RewriteCond %{HTTP_HOST} ^([^www].*)$ -# RewriteRule ^(.*)$ http://www.%1/$1 [R=301] + RewriteCond %{HTTP_HOST} ^([^www].*)$ + RewriteRule ^(.*)$ http://www.%1/$1 [R=301] diff --git a/backend/controllers/EventController.php b/backend/controllers/EventController.php index 49cbd6f..3e09590 100755 --- a/backend/controllers/EventController.php +++ b/backend/controllers/EventController.php @@ -161,6 +161,7 @@ class EventController extends Controller public function actionDelimg($id,$field){ $model = $this->findModel($id); + $model->detachBehavior('img'); $model->$field = ''; $model->save(); return true; diff --git a/common/models/Event.php b/common/models/Event.php index 7b8317b..11a12f7 100755 --- a/common/models/Event.php +++ b/common/models/Event.php @@ -47,7 +47,7 @@ class Event extends \yii\db\ActiveRecord public function behaviors() { return [ - [ + 'img'=>[ 'class' => SaveImgBehavior::className(), 'fields' => [ ['name'=>'imageUpload','directory' => 'event' ], diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index 227b497..a618211 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -2,10 +2,12 @@ namespace common\modules\product; - +use common\modules\product\helpers\FilterHelper; +use common\modules\product\models\Brand; +use common\modules\product\models\BrandSearch; use common\modules\product\models\CategorySearch; use common\modules\product\models\ProductSearch; - +use common\modules\rubrication\models\TaxOption; use Yii; use yii\helpers\Url; use yii\web\HttpException; @@ -13,6 +15,8 @@ use yii\web\UrlRuleInterface; class CatalogUrlManager implements UrlRuleInterface { public $route_map = []; + + public $option_prefix = 'o:'; /** * Parses the given request and returns the corresponding route and parameters. * @param \yii\web\UrlManager $manager the URL manager @@ -25,12 +29,6 @@ class CatalogUrlManager implements UrlRuleInterface { $pathInfo = $request->getPathInfo(); $paths = explode('/', $pathInfo); - if(isset($paths[1])) { - if(strripos($request->url,'catalog/'.$paths[1].'?') && (!strripos($request->url,'?page')) && (!strripos($request->url,'?sort'))){ - throw new HttpException(404 ,'Page not found'); - } - - } if (!array_key_exists($paths[0], $this->route_map)) { @@ -56,6 +54,24 @@ class CatalogUrlManager implements UrlRuleInterface { $this->parseFilter($paths[2], $params); } + else if(strpos($paths[2], 'filter:') === 0){ + $this->parseOldFilter($paths[2], $params); + //['catalog/category', 'category' => $category, 'filters' =>$params['filter']] + + $optionsTemplate = FilterHelper::optionsTemplate(); + array_unshift($optionsTemplate, "special", "brands"); + $filterView = []; + foreach($optionsTemplate as $optionKey){ + if(isset($params['filter'][$optionKey])){ + $filterView[$optionKey] = $params['filter'][$optionKey]; + } + + + } + + + Yii::$app->response->redirect(['catalog/category', 'category' => $category, 'filters' =>$filterView],301); + } else { throw new HttpException(404 ,'Page not found'); } @@ -95,7 +111,6 @@ class CatalogUrlManager implements UrlRuleInterface { if (!empty($params['category'])) { $category_alias = is_object($params['category']) ? $params['category']->alias : strtolower($params['category']); $url = 'catalog/'. $category_alias .'/'; - unset($params['category']); } else { $url = 'catalog/'; } @@ -118,7 +133,6 @@ class CatalogUrlManager implements UrlRuleInterface { case 'catalog/product': if (!empty($params['product'])) { $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); - unset($params['product']); } $url = 'product/'. $product_alias; @@ -131,6 +145,23 @@ class CatalogUrlManager implements UrlRuleInterface { return $url; break; +// case 'catalog/brands': +// if (empty($params['brand'])) { +// return 'brands'; +// } else { +// +// $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']); +// } +// $url = 'brands/'. $brand_alias .'/'; +// +// $this->setFilterUrl($params, $url); +// +// if (!empty($params) && ($query = http_build_query($params)) !== '') { +// $url .= '?' . $query; +// } +// +// return $url; +// break; } } @@ -173,18 +204,51 @@ class CatalogUrlManager implements UrlRuleInterface { if (empty($filter_option)) { continue; } + $filter_exp = explode('=', $filter_option); + + if(isset($filter_exp[1])){ + list($filter_key, $filter_option) = explode('=', $filter_option); + if($filter_key == 'prices') { // price-interval section + $prices = explode(':', $filter_option); + $params['filters'][$filter_key] = [ + 'min' => floatval($prices[0]), + 'max' => floatval($prices[1]), + ]; + } + else { // brands and other sections + $params['filters'][$filter_key] = explode(',', $filter_option); + } + } else { + throw new HttpException(404 ,'Page not found'); + } + + } + } + + + + private function parseOldFilter($paths, &$params) { + $params['filter'] = []; + $filter_str = substr($paths, 7); + $filter_options = explode(';', $filter_str); + foreach ($filter_options as $filter_option) { + if (empty($filter_option)) { + continue; + } list($filter_key, $filter_option) = explode('=', $filter_option); if($filter_key == 'prices') { // price-interval section $prices = explode(':', $filter_option); - $params['filters'][$filter_key] = [ + $params['filter'][$filter_key] = [ 'min' => floatval($prices[0]), 'max' => floatval($prices[1]), ]; } + elseif (strpos($filter_key, $this->option_prefix) === 0) { // options section + $params['filter'][substr($filter_key, 2)] = explode(',', $filter_option); + } else { // brands and other sections - $params['filters'][$filter_key] = explode(',', $filter_option); + $params['filter'][$filter_key] = explode(',', $filter_option); } } } - } \ No newline at end of file diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index b09dd64..9c7de08 100755 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -208,7 +208,6 @@ class Category extends \yii\db\ActiveRecord ->innerJoin('product_variant', 'product_variant.product_variant_id = product_variant_option.product_variant_id') ->innerJoin('product', 'product.product_id = product_variant.product_id') ->innerJoin('product_category', 'product_category.product_id = product.product_id') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->innerJoin('tax_group_to_category', 'tax_group.tax_group_id = tax_group_to_category.tax_group_id') ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE,'tax_group_to_category.category_id'=>$this->category_id]) ->andWhere(['!=', 'product_variant.stock', 0]); @@ -224,7 +223,6 @@ class Category extends \yii\db\ActiveRecord ->innerJoin('product', 'product.product_id = product_option.product_id') ->innerJoin('product_category', 'product_category.product_id = product.product_id') ->innerJoin('product_variant', 'product_variant.product_id = product.product_id') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->innerJoin('tax_group_to_category', 'tax_group.tax_group_id = tax_group_to_category.tax_group_id') ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE,'tax_group_to_category.category_id'=>$this->category_id]) ->andWhere(['!=', 'product_variant.stock', 0]); @@ -234,14 +232,13 @@ class Category extends \yii\db\ActiveRecord 'tax_group.*', 'tax_option.alias as option_alias', 'tax_group.alias as group_alias', - 'tax_value_string.value as value', + 'tax_option.name as value', 'tax_option.sort AS tax_option_sort', 'tax_group.sort AS tax_group_sort', ]) ->from(['tax_option' ]) ->where(['tax_option.tax_option_id'=>$query1->union($query2)]) ->innerJoin('tax_group','tax_group.tax_group_id = tax_option.tax_group_id') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->orderBy('tax_option.sort, tax_group.sort'); return $query3; } @@ -251,9 +248,8 @@ class Category extends \yii\db\ActiveRecord $connection = Yii::$app->getDb(); $command = $connection->createCommand(' - SELECT ton.alias as option_alias, * + SELECT ton.alias as option_alias,ton.name as value, * FROM tax_option as ton - LEFT JOIN tax_value_string as tvs ON ton.tax_option_id = tvs.tax_option_id RIGHT JOIN tax_group ON ton.tax_group_id = tax_group.tax_group_id RIGHT JOIN tax_group_to_category ON tax_group.tax_group_id = tax_group_to_category.tax_group_id WHERE ton.tax_option_id IN ( @@ -276,7 +272,7 @@ class Category extends \yii\db\ActiveRecord public function setTaxGroup($value) { - return $this->tax_group = $value; + return $this->taxgroup = $value; } public function getTaxGroup() diff --git a/frontend/controllers/OrderController.php b/frontend/controllers/OrderController.php index 7d326aa..8f09577 100755 --- a/frontend/controllers/OrderController.php +++ b/frontend/controllers/OrderController.php @@ -118,11 +118,7 @@ 'basket' => $basket, ]); } - - public function actionSuccess() - { - return $this->render('success'); - } + public function actionQuick() { @@ -168,7 +164,14 @@ throw new InvalidConfigException('Товар не найден или не удалось загрузить данные о покупателе.'); } } - + + + public function actionSuccess() + { + return $this->render('success'); + } + + public function actionQuickBasket() { $response = \Yii::$app->response; diff --git a/frontend/views/catalog/_product_item.php b/frontend/views/catalog/_product_item.php index db2c240..47db205 100755 --- a/frontend/views/catalog/_product_item.php +++ b/frontend/views/catalog/_product_item.php @@ -51,8 +51,7 @@ use yii\helpers\Url; variant->price_old){?>
- variant->price_old ?> - грн + variant->price_old ?>грн
diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index aca5c9a..867d8e3 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -137,15 +137,25 @@ FlipclockAsset::register($this); - +
+
+ events as $event):?> + banner) && $event->isActive()):?> + getImageUrl('banner'), 'banner_list'),Url::to(['event/show','alias'=>$event->alias,'id'=>$event->primaryKey]))?> + + +
+
- + + + events as $event):?> @@ -267,6 +277,7 @@ FlipclockAsset::register($this);
+
@@ -405,13 +416,7 @@ FlipclockAsset::register($this);
-
- events as $event):?> - banner) && $event->isActive()):?> - getImageUrl('banner'), 'event_in_product'),Url::to(['event/show','alias'=>$event->alias,'id'=>$event->primaryKey]))?> - - -
+

Характеристики name ?> diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php index 3693762..27a63fe 100755 --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php @@ -8,11 +8,16 @@ use frontend\widgets\Seo; use yii\helpers\Url; use yii\web\View; use yii\widgets\ListView; + + $this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : ''; $this->params['seo']['fields']['meta-title'] = $category->meta_title; $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name; $this->params['seo']['seo_text'] = $category->seo_text; + + + $this->params['seo']['description'] = $category->meta_desc; $this->params['seo']['meta'] = $category->meta_robots; $this->params['seo']['category_name'] = $category->name; diff --git a/frontend/views/event/show.php b/frontend/views/event/show.php index 782cac8..b114172 100755 --- a/frontend/views/event/show.php +++ b/frontend/views/event/show.php @@ -58,10 +58,13 @@ $this->title = $model->name; ?>

+
body?> +
+ -
+
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 621a88e..4e2f521 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -63,7 +63,7 @@ use common\models\Event; beginBody() ?> - +
@@ -422,8 +422,8 @@ use common\models\Event;
- - + +
@@ -446,12 +446,7 @@ use common\models\Event;