Commit 8d70cfe3c75b9976a497cf2501e546bb9400aca1

Authored by Alexey Boroda
2 parents f2d1c773 d5c87d48

Merge remote-tracking branch 'origin/master'

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