Commit 50808d34efe3070d1f1edd8603e960c7314d2665
Merge remote-tracking branch 'origin/master'
Showing
1 changed file
with
73 additions
and
23 deletions
Show diff stats
console/SiteMapController.php
| ... | ... | @@ -47,6 +47,26 @@ |
| 47 | 47 | ->innerJoinWith('enabledVariants.lang'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + public function getProducts() | |
| 51 | + { | |
| 52 | + $products = Product::find() | |
| 53 | + ->innerJoinWith('variant') | |
| 54 | + ->innerJoinWith('brand.lang')->with('lang') | |
| 55 | + ->where([ | |
| 56 | + '!=', | |
| 57 | + 'product_variant.price', | |
| 58 | + 0 | |
| 59 | + ]) | |
| 60 | + ->andWhere([ | |
| 61 | + '!=', | |
| 62 | + 'product_variant.stock', | |
| 63 | + 0 | |
| 64 | + ]) | |
| 65 | + ->all(); | |
| 66 | + | |
| 67 | + return $products; | |
| 68 | + } | |
| 69 | + | |
| 50 | 70 | public function getSeoLinks() |
| 51 | 71 | { |
| 52 | 72 | return Seo::find() |
| ... | ... | @@ -221,10 +241,13 @@ |
| 221 | 241 | } |
| 222 | 242 | } |
| 223 | 243 | |
| 244 | + $this->stdout('Add static' . PHP_EOL, Console::FG_BLUE); | |
| 224 | 245 | foreach ($this->getAddStatic() as $page) { |
| 225 | 246 | $this->createRow($page, 1, 'Daily'); |
| 226 | 247 | } |
| 227 | - | |
| 248 | + | |
| 249 | + $this->stdout('Add pages' . PHP_EOL, Console::FG_BLUE); | |
| 250 | + | |
| 228 | 251 | foreach ($this->getStaticPages() as $page) { |
| 229 | 252 | $url = $urlManager->createAbsoluteUrl( |
| 230 | 253 | [ |
| ... | ... | @@ -234,7 +257,9 @@ |
| 234 | 257 | ); |
| 235 | 258 | $this->createRow($url, 0.5); |
| 236 | 259 | } |
| 237 | - | |
| 260 | + | |
| 261 | + $this->stdout('Add categories' . PHP_EOL, Console::FG_BLUE); | |
| 262 | + | |
| 238 | 263 | foreach ($this->getCategories() as $category) { |
| 239 | 264 | $url = $urlManager->createAbsoluteUrl( |
| 240 | 265 | [ |
| ... | ... | @@ -244,28 +269,49 @@ |
| 244 | 269 | ); |
| 245 | 270 | $this->createRow($url, 0.9, 'Daily'); |
| 246 | 271 | } |
| 247 | - foreach ($this->getVariants() | |
| 248 | - ->each(1000) as $row) { | |
| 272 | + | |
| 273 | +// foreach ($this->getVariants() | |
| 274 | +// ->each(1000) as $row) { | |
| 275 | +// /** | |
| 276 | +// * @var Product $row | |
| 277 | +// */ | |
| 278 | +// if(!empty($row->enabledVariants)) { | |
| 279 | +// $variant = $row->enabledVariants[0]; | |
| 280 | +// } | |
| 281 | +// if(!empty($variant)) { | |
| 282 | +// if (!preg_match("@^[a-zA-Z\d]+$@i", $variant->sku)) { | |
| 283 | +// continue; | |
| 284 | +// } | |
| 285 | +// $url = $urlManager->createAbsoluteUrl( | |
| 286 | +// [ | |
| 287 | +// 'catalog/product', | |
| 288 | +// 'product' => $row->lang->alias, | |
| 289 | +// ] | |
| 290 | +// ); | |
| 291 | +// $this->createRow($url, 0.7, 'Daily'); | |
| 292 | +// } | |
| 293 | +// } | |
| 294 | + /** | |
| 295 | + * New products generation | |
| 296 | + */ | |
| 297 | + | |
| 298 | + $this->stdout('Add products' . PHP_EOL, Console::FG_BLUE); | |
| 299 | + | |
| 300 | + foreach ($this->getProducts() as $product) { | |
| 249 | 301 | /** |
| 250 | - * @var Product $row | |
| 302 | + * @var Product $product | |
| 251 | 303 | */ |
| 252 | - if(!empty($row->enabledVariants)) { | |
| 253 | - $variant = $row->enabledVariants[0]; | |
| 254 | - } | |
| 255 | - if(!empty($variant)) { | |
| 256 | - if (!preg_match("@^[a-zA-Z\d]+$@i", $variant->sku)) { | |
| 257 | - continue; | |
| 258 | - } | |
| 259 | - $url = $urlManager->createAbsoluteUrl( | |
| 260 | - [ | |
| 261 | - 'catalog/product', | |
| 262 | - 'product' => $row->lang->alias, | |
| 263 | - ] | |
| 264 | - ); | |
| 265 | - $this->createRow($url, 0.7, 'Daily'); | |
| 266 | - } | |
| 304 | + $url = $urlManager->createAbsoluteUrl( | |
| 305 | + [ | |
| 306 | + 'catalog/product', | |
| 307 | + 'product' => $product->lang->alias, | |
| 308 | + ] | |
| 309 | + ); | |
| 310 | + $this->createRow($url, 0.7, 'Daily'); | |
| 267 | 311 | } |
| 268 | - | |
| 312 | + | |
| 313 | + $this->stdout('Add brands' . PHP_EOL, Console::FG_BLUE); | |
| 314 | + | |
| 269 | 315 | foreach ($this->getBrands() as $brand) { |
| 270 | 316 | |
| 271 | 317 | $url = $urlManager->createAbsoluteUrl( |
| ... | ... | @@ -277,7 +323,9 @@ |
| 277 | 323 | $this->createRow($url, 0.5); |
| 278 | 324 | |
| 279 | 325 | } |
| 280 | - | |
| 326 | + | |
| 327 | + $this->stdout('Add filters' . PHP_EOL, Console::FG_BLUE); | |
| 328 | + | |
| 281 | 329 | foreach ($this->getCategoriesWithFilters() as $category) { |
| 282 | 330 | foreach ($category->taxGroups as $group) { |
| 283 | 331 | if (in_array( |
| ... | ... | @@ -306,7 +354,9 @@ |
| 306 | 354 | |
| 307 | 355 | } |
| 308 | 356 | } |
| 309 | - | |
| 357 | + | |
| 358 | + $this->stdout('Add seo links' . PHP_EOL, Console::FG_BLUE); | |
| 359 | + | |
| 310 | 360 | foreach ($this->getSeoLinks() as $link) { |
| 311 | 361 | $url = Yii::$app->urlManager->baseUrl . $link->url; |
| 312 | 362 | $this->createRow($url, 0.7); | ... | ... |