Commit 8d70cfe3c75b9976a497cf2501e546bb9400aca1
Merge remote-tracking branch 'origin/master'
Showing
3 changed files
with
49 additions
and
18 deletions
Show diff stats
console/SiteMapController.php
@@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
4 | 4 | ||
5 | use artweb\artbox\ecommerce\models\Brand; | 5 | use artweb\artbox\ecommerce\models\Brand; |
6 | use artweb\artbox\ecommerce\models\ProductVariant; | 6 | use artweb\artbox\ecommerce\models\ProductVariant; |
7 | + use artweb\artbox\language\components\LanguageUrlManager; | ||
8 | + use artweb\artbox\language\models\Language; | ||
7 | use artweb\artbox\seo\models\Seo; | 9 | use artweb\artbox\seo\models\Seo; |
8 | use artweb\artbox\ecommerce\models\Category; | 10 | use artweb\artbox\ecommerce\models\Category; |
9 | use Yii; | 11 | use Yii; |
@@ -27,9 +29,14 @@ | @@ -27,9 +29,14 @@ | ||
27 | public function getAddStatic() | 29 | public function getAddStatic() |
28 | { | 30 | { |
29 | return [ | 31 | return [ |
30 | - 'https://extremstyle.ua/ru', | 32 | + Yii::$app->urlManager->baseUrl.'/ru', |
31 | ]; | 33 | ]; |
32 | } | 34 | } |
35 | + | ||
36 | + | ||
37 | + public function getHost(){ | ||
38 | + return Yii::$app->urlManager->baseUrl.'/ru'; | ||
39 | + } | ||
33 | 40 | ||
34 | public function getVariants() | 41 | public function getVariants() |
35 | { | 42 | { |
@@ -68,6 +75,7 @@ | @@ -68,6 +75,7 @@ | ||
68 | ->joinWith('taxGroups.lang') | 75 | ->joinWith('taxGroups.lang') |
69 | ->with('taxGroups.taxOptions.lang') | 76 | ->with('taxGroups.taxOptions.lang') |
70 | ->where(['!=', 'tax_group.meta_robots', 'noindex,nofollow' ]) | 77 | ->where(['!=', 'tax_group.meta_robots', 'noindex,nofollow' ]) |
78 | + ->where(['tax_group.is_filter'=>true ]) | ||
71 | ->all(); | 79 | ->all(); |
72 | } | 80 | } |
73 | 81 | ||
@@ -121,18 +129,31 @@ | @@ -121,18 +129,31 @@ | ||
121 | 129 | ||
122 | public function actionProcess() | 130 | public function actionProcess() |
123 | { | 131 | { |
132 | + | ||
133 | + Language::setCurrent('ru'); | ||
134 | + | ||
135 | + | ||
124 | $config = ArrayHelper::merge( | 136 | $config = ArrayHelper::merge( |
125 | require( \Yii::getAlias('@frontend/config/') . 'main.php' ), | 137 | require( \Yii::getAlias('@frontend/config/') . 'main.php' ), |
126 | - require( \Yii::getAlias('@common/config/') . 'main.php' ) | 138 | + require( \Yii::getAlias('@common/config/') . 'main.php' ), |
139 | + ['components'=>['urlManager'=>['hostInfo'=>'https://extremstyle.ua']]] | ||
127 | ); | 140 | ); |
128 | - | ||
129 | - Yii::$app->urlManager->addRules($config[ 'components' ][ 'urlManager' ][ 'rules' ]); | 141 | + |
142 | + if(isset($config['components']['urlManager']['class'])){ | ||
143 | + unset($config['components']['urlManager']['class']); | ||
144 | + } | ||
145 | + //Yii::$app->urlManager = new LanguageUrlManager($config['components']['urlManager']); | ||
146 | + | ||
147 | + $urlManager = new LanguageUrlManager($config['components']['urlManager']); | ||
148 | + | ||
130 | $this->mainMap = '<?xml version="1.0" encoding="UTF-8"?>'; | 149 | $this->mainMap = '<?xml version="1.0" encoding="UTF-8"?>'; |
131 | $this->mainMap .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; | 150 | $this->mainMap .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; |
132 | $this->fileName = 'sitemap' . $this->mapNumber . '.xml'; | 151 | $this->fileName = 'sitemap' . $this->mapNumber . '.xml'; |
133 | setlocale(LC_ALL, 'ru_RU.CP1251'); | 152 | setlocale(LC_ALL, 'ru_RU.CP1251'); |
134 | $this->handle = fopen(Yii::getAlias('@frontend') . '/web' . '/' . $this->fileName, "w"); | 153 | $this->handle = fopen(Yii::getAlias('@frontend') . '/web' . '/' . $this->fileName, "w"); |
135 | - | 154 | + |
155 | + | ||
156 | + | ||
136 | $this->content = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; | 157 | $this->content = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; |
137 | 158 | ||
138 | foreach ($this->getAddStatic() as $page) { | 159 | foreach ($this->getAddStatic() as $page) { |
@@ -140,7 +161,7 @@ | @@ -140,7 +161,7 @@ | ||
140 | } | 161 | } |
141 | 162 | ||
142 | foreach ($this->getStaticPages() as $page) { | 163 | foreach ($this->getStaticPages() as $page) { |
143 | - $url = Url::to( | 164 | + $url = $urlManager->createAbsoluteUrl( |
144 | [ | 165 | [ |
145 | 'site/page', | 166 | 'site/page', |
146 | 'slug' => $page->lang->alias, | 167 | 'slug' => $page->lang->alias, |
@@ -150,7 +171,7 @@ | @@ -150,7 +171,7 @@ | ||
150 | } | 171 | } |
151 | 172 | ||
152 | foreach ($this->getCategories() as $category) { | 173 | foreach ($this->getCategories() as $category) { |
153 | - $url = Url::to( | 174 | + $url = $urlManager->createAbsoluteUrl( |
154 | [ | 175 | [ |
155 | 'catalog/category', | 176 | 'catalog/category', |
156 | 'category' => $category->lang->alias, | 177 | 'category' => $category->lang->alias, |
@@ -164,7 +185,7 @@ | @@ -164,7 +185,7 @@ | ||
164 | if(!preg_match("@^[a-zA-Z\d]+$@i", $row->sku)) { | 185 | if(!preg_match("@^[a-zA-Z\d]+$@i", $row->sku)) { |
165 | continue; | 186 | continue; |
166 | } | 187 | } |
167 | - $url = Url::to( | 188 | + $url = $urlManager->createAbsoluteUrl( |
168 | [ | 189 | [ |
169 | 'catalog/product', | 190 | 'catalog/product', |
170 | 'product' => $row->product->lang->alias, | 191 | 'product' => $row->product->lang->alias, |
@@ -177,7 +198,7 @@ | @@ -177,7 +198,7 @@ | ||
177 | 198 | ||
178 | foreach ($this->getBrands() as $brand) { | 199 | foreach ($this->getBrands() as $brand) { |
179 | 200 | ||
180 | - $url = Url::to( | 201 | + $url = $urlManager->createAbsoluteUrl( |
181 | [ | 202 | [ |
182 | 'brand/view', | 203 | 'brand/view', |
183 | 'slug' => $brand->lang->alias, | 204 | 'slug' => $brand->lang->alias, |
@@ -190,7 +211,7 @@ | @@ -190,7 +211,7 @@ | ||
190 | foreach ($this->getCategoriesWithFilters() as $category) { | 211 | foreach ($this->getCategoriesWithFilters() as $category) { |
191 | foreach ($category->taxGroups as $group) { | 212 | foreach ($category->taxGroups as $group) { |
192 | foreach ($group->taxOptions as $option) { | 213 | foreach ($group->taxOptions as $option) { |
193 | - $url = Url::to( | 214 | + $url = $urlManager->createAbsoluteUrl( |
194 | [ | 215 | [ |
195 | 'catalog/category', | 216 | 'catalog/category', |
196 | 'category' => $category, | 217 | 'category' => $category, |
@@ -215,7 +236,7 @@ | @@ -215,7 +236,7 @@ | ||
215 | fclose($this->handle); | 236 | fclose($this->handle); |
216 | 237 | ||
217 | $this->mainMap .= '<sitemap>'. | 238 | $this->mainMap .= '<sitemap>'. |
218 | - '<loc>https://extremstyle.ua/ru/' . $this->fileName . '</loc>'. | 239 | + '<loc>'.$this->getHost(). $this->fileName . '</loc>'. |
219 | '<lastmod>' . date('Y-m-d') . '</lastmod>'. | 240 | '<lastmod>' . date('Y-m-d') . '</lastmod>'. |
220 | '</sitemap>'. | 241 | '</sitemap>'. |
221 | '</sitemapindex>'; | 242 | '</sitemapindex>'; |
models/Category.php
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | * @todo Write doc for ArtboxTreeBehavior | 19 | * @todo Write doc for ArtboxTreeBehavior |
20 | * @property integer $id | 20 | * @property integer $id |
21 | * @property integer $sort | 21 | * @property integer $sort |
22 | + * @property integer $sort2 | ||
22 | * @property integer $remote_id | 23 | * @property integer $remote_id |
23 | * @property integer $parent_id | 24 | * @property integer $parent_id |
24 | * @property string $path | 25 | * @property string $path |
@@ -68,7 +69,7 @@ | @@ -68,7 +69,7 @@ | ||
68 | return [ | 69 | return [ |
69 | 'artboxtree' => [ | 70 | 'artboxtree' => [ |
70 | 'class' => ArtboxTreeBehavior::className(), | 71 | 'class' => ArtboxTreeBehavior::className(), |
71 | - 'keyNameGroup' => NULL, | 72 | + 'keyNameGroup' => null, |
72 | 'keyNamePath' => 'path', | 73 | 'keyNamePath' => 'path', |
73 | ], | 74 | ], |
74 | 'language' => [ | 75 | 'language' => [ |
@@ -110,6 +111,7 @@ | @@ -110,6 +111,7 @@ | ||
110 | 'depth', | 111 | 'depth', |
111 | 'product_unit_id', | 112 | 'product_unit_id', |
112 | 'sort', | 113 | 'sort', |
114 | + 'sort2', | ||
113 | ], | 115 | ], |
114 | 'integer', | 116 | 'integer', |
115 | ], | 117 | ], |
@@ -138,6 +140,7 @@ | @@ -138,6 +140,7 @@ | ||
138 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | 140 | 'product_unit_id' => Yii::t('product', 'Product Unit ID'), |
139 | 'remote_id' => Yii::t('product', 'Remote ID'), | 141 | 'remote_id' => Yii::t('product', 'Remote ID'), |
140 | 'sort' => Yii::t('product', 'Порядок вывода'), | 142 | 'sort' => Yii::t('product', 'Порядок вывода'), |
143 | + 'sort2' => Yii::t('product', 'Порядок вывода на главной'), | ||
141 | ]; | 144 | ]; |
142 | } | 145 | } |
143 | 146 | ||
@@ -212,7 +215,7 @@ | @@ -212,7 +215,7 @@ | ||
212 | { | 215 | { |
213 | if (parent::beforeSave($insert)) { | 216 | if (parent::beforeSave($insert)) { |
214 | 217 | ||
215 | - if (empty($this->parent_id)) { | 218 | + if (empty( $this->parent_id )) { |
216 | $this->parent_id = 0; | 219 | $this->parent_id = 0; |
217 | } | 220 | } |
218 | 221 |
views/category/_form.php
@@ -39,10 +39,14 @@ | @@ -39,10 +39,14 @@ | ||
39 | ) | 39 | ) |
40 | ->label(Yii::t('product', 'Parent category')) ?> | 40 | ->label(Yii::t('product', 'Parent category')) ?> |
41 | 41 | ||
42 | - <?php | ||
43 | - echo $form->field($model, 'sort'); | ||
44 | - ?> | ||
45 | - | 42 | + <?php |
43 | + echo $form->field($model, 'sort'); | ||
44 | + ?> | ||
45 | + | ||
46 | + <?php | ||
47 | + echo $form->field($model, 'sort2'); | ||
48 | + ?> | ||
49 | + | ||
46 | <?= $form->field($model, 'image') | 50 | <?= $form->field($model, 'image') |
47 | ->widget( | 51 | ->widget( |
48 | \kartik\file\FileInput::className(), | 52 | \kartik\file\FileInput::className(), |
@@ -85,7 +89,10 @@ | @@ -85,7 +89,10 @@ | ||
85 | 'gif', | 89 | 'gif', |
86 | 'png', | 90 | 'png', |
87 | ], | 91 | ], |
88 | - 'initialPreview' => !empty( $model->getImageUrl(1, false) ) ? ArtboxImageHelper::getImage( | 92 | + 'initialPreview' => !empty( $model->getImageUrl( |
93 | + 1, | ||
94 | + false | ||
95 | + ) ) ? ArtboxImageHelper::getImage( | ||
89 | $model->getImageUrl(1, false), | 96 | $model->getImageUrl(1, false), |
90 | 'list' | 97 | 'list' |
91 | ) : '', | 98 | ) : '', |