From ac8ab861ee81bcc8b2f4fb4d393eaedc9227fb4a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 22 Jul 2016 18:54:48 +0300 Subject: [PATCH] 20.07.16 --- backend/views/page/_form.php | 1 + common/modules/product/CatalogUrlManager.php | 62 ++++++++++++++++++++------------------------------------------ console/migrations/m160722_150101_remove_product_option_option_fkey.php | 19 +++++++++++++++++++ console/migrations/m160722_150611_remove_product_variant_option_id.php | 27 +++++++++++++++++++++++++++ frontend/config/main.php | 24 +++++------------------- frontend/controllers/CatalogController.php | 34 ++++++++-------------------------- frontend/views/articles/show.php | 2 +- frontend/views/catalog/brand.php | 91 ------------------------------------------------------------------------------------------- frontend/views/catalog/brands.php | 4 ++-- frontend/widgets/Seo.php | 2 +- 10 files changed, 84 insertions(+), 182 deletions(-) create mode 100644 console/migrations/m160722_150101_remove_product_option_option_fkey.php create mode 100644 console/migrations/m160722_150611_remove_product_variant_option_id.php diff --git a/backend/views/page/_form.php b/backend/views/page/_form.php index e3167b8..feaee5d 100755 --- a/backend/views/page/_form.php +++ b/backend/views/page/_form.php @@ -15,6 +15,7 @@ use mihaildev\elfinder\ElFinder; field($model, 'title')->textInput(['maxlength' => true]) ?> + field($model, 'translit')->textInput(['maxlength' => true]) ?> field($model, 'body')->widget(CKEditor::className(), [ diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index ac9af89..0466ade 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -49,6 +49,7 @@ class CatalogUrlManager implements UrlRuleInterface { if (strpos($paths[2], 'filters:') === 0) { $this->parseFilter($paths[2], $params); + } else if(strpos($paths[2], 'filter:') === 0){ $this->parseOldFilter($paths[2], $params); @@ -84,21 +85,6 @@ class CatalogUrlManager implements UrlRuleInterface { $params = [ 'product' => $product, ]; - } elseif ($paths[0] == 'brands') { - if (empty($paths[1]) || $paths[1] == 'index') { - $route = 'catalog/brands'; - } elseif (($brand = BrandSearch::findByAlias($paths[1]))) { - $route = 'catalog/brand'; - $params['brand'] = $brand; - if (!empty($paths[2])) { - // Filter - if (strpos($paths[2], 'filters:') === 0) { - $this->parseFilter($paths[2], $params); - } - } - } else { - // @todo redirect or return FALSE - } } return [$route, $params]; @@ -112,6 +98,7 @@ class CatalogUrlManager implements UrlRuleInterface { */ public function createUrl($manager, $route, $params) { + if (!in_array($route, $this->route_map)) { return false; } @@ -150,25 +137,28 @@ class CatalogUrlManager implements UrlRuleInterface { $url .= '?' . $query; } - 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; + +// 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; } } @@ -185,18 +175,6 @@ class CatalogUrlManager implements UrlRuleInterface { $filter[] = $key .'='. implode(':', $values); break; -// case 'options': -// foreach($values as $group => &$value_items) { -// foreach($value_items as &$value_item) { -// $value_item = $this->option_value_encode($value_item); -// if (empty($value_item)) { -// unset($value_item); -// } -// } -// $filter[] = $this->option_prefix. $group .'='. implode(',', $value_items); -// } -// break; - default: foreach($values as &$value) { $value = $this->option_value_encode($value); diff --git a/console/migrations/m160722_150101_remove_product_option_option_fkey.php b/console/migrations/m160722_150101_remove_product_option_option_fkey.php new file mode 100644 index 0000000..9f60d86 --- /dev/null +++ b/console/migrations/m160722_150101_remove_product_option_option_fkey.php @@ -0,0 +1,19 @@ +dropForeignKey('product_option_option_fkey', '{{%product_option}}'); + + } + + public function down() + { + $this->addForeignKey('product_option_option_fkey', 'product_option', 'option_id', 'tax_option', 'tax_option_id', 'NO ACTION', 'NO ACTION'); + + } + +} diff --git a/console/migrations/m160722_150611_remove_product_variant_option_id.php b/console/migrations/m160722_150611_remove_product_variant_option_id.php new file mode 100644 index 0000000..babf023 --- /dev/null +++ b/console/migrations/m160722_150611_remove_product_variant_option_id.php @@ -0,0 +1,27 @@ +dropForeignKey('product_variant_option_id', '{{%product_variant_option}}'); + } + + public function down() + { + $this->addForeignKey('product_variant_option_id', 'product_variant_option', 'option_variant_id', 'tax_option', 'tax_option_id', 'NO ACTION', 'NO ACTION'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/config/main.php b/frontend/config/main.php index e6c89e3..fa5cc32 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -58,6 +58,7 @@ return [ ], ], 'components' => [ + 'authManager' => [ 'class' => 'yii\rbac\DbManager', ], @@ -120,7 +121,7 @@ return [ 'route_map' => [ 'catalog' => 'catalog/category', 'product' => 'catalog/product', - 'brands' => 'catalog/brands', + ] ], 'priceparam.xml' => 'site/priceparam', @@ -134,31 +135,16 @@ return [ // 'products/' => 'products/index', // 'products//-' => 'products/show', 'news/-' => 'news/show', - //'brends/' => 'brends/show', - 'brends' => 'brends/index', + 'brands' => 'catalog/brands', + 'brands/' => 'catalog/brand', 'blog' => 'articles/index', 'blog/-' => 'articles/show', 'event' => 'event/index', - 'event/-' => 'event/show', + 'event/-' => 'event/show', '///' => '//', '//' => '/', '/admin' => 'admin/default/index', '/admin/users' => 'admin/users/index', - 'admin' => 'admin/menu/index', - 'admin/users' => 'admin/users/index', - 'admin/users/save' => 'admin/users/save', - 'admin/users/delete' => 'admin/users/delete', - 'admin/menu' => 'admin/menu/index', - 'admin/menu/save' => 'admin/menu/save', - 'admin/menu/delete' => 'admin/menu/delete', - 'admin/text' => 'admin/text/index', - 'admin/text/save' => 'admin/text/save', - 'admin/text/delete' => 'admin/text/delete', - 'admin/catalog' => 'admin/catalog/index', - 'admin/catalog/save' => 'admin/catalog/save', - 'admin/catalog/delete' => 'admin/catalog/delete', - - 'thumbs/' => 'site/thumb', ], 'class' => 'common\components\urlManager\LangUrlManager', diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php index 457644f..cd36d01 100755 --- a/frontend/controllers/CatalogController.php +++ b/frontend/controllers/CatalogController.php @@ -78,6 +78,12 @@ class CatalogController extends \yii\web\Controller // } + if ( !empty($filter['prices']) ) { + $params['prices'] = $filter['prices']; + } + + + foreach($optionsList as $optionList){ if(isset($filter[$optionList])){ @@ -87,10 +93,6 @@ class CatalogController extends \yii\web\Controller } - if ( !empty($filter['prices']) ) { - $params['prices'] = $filter['prices']; - } - $productModel = new ProductFrontendSearch(); //$productQuery = $productModel->getSearchQuery($category, $params); $productProvider = $productModel->search($category, $params); @@ -175,31 +177,12 @@ class CatalogController extends \yii\web\Controller public function actionBrand($brand) { - $filter = Yii::$app->request->get('filter', []); + $brand = BrandSearch::findByAlias($brand); $params = [ - 'brand_id' => $brand->brand_id, + 'brands' => $brand->brand_id, ]; - if ( !empty($filter['prices']) ) { - $params['prices'] = $filter['prices']; - } - - if ( !empty($filter['special']) ) { - if (!is_array($filter['special'])) { - $filter['special'] = [$filter['special']]; - } - if (in_array('new', $filter['special'])) { - $params['special']['is_new'] = true; - } - if (in_array('top', $filter['special'])) { - $params['special']['is_top'] = true; - } - if (in_array('promo', $filter['special'])) { - $params['special']['akciya'] = true; - } - } - $productModel = new ProductFrontendSearch(); $productProvider = $productModel->search(null, $params); @@ -210,7 +193,6 @@ class CatalogController extends \yii\web\Controller 'productProvider' => $productProvider, 'brand' => $brand, 'priceLimits' => $priceLimits, - 'filter' => $filter, ]); } diff --git a/frontend/views/articles/show.php b/frontend/views/articles/show.php index 4a7765b..b391f17 100755 --- a/frontend/views/articles/show.php +++ b/frontend/views/articles/show.php @@ -11,7 +11,7 @@ $this->registerMetaTag(['name' => 'description', 'content' => $news->meta_descri