Commit 55371b6cb506f378abeb5c255b3fb2cbaea09027

Authored by Alexey Boroda
1 parent 391c98b4

-Get all children fix

common/components/artboxtree/ArtboxTreeBehavior.php
... ... @@ -7,6 +7,7 @@ use yii\base\Exception;
7 7 use yii\base\NotSupportedException;
8 8 use yii\db\ActiveRecord;
9 9 use yii\db\Expression;
  10 +use yii\helpers\VarDumper;
10 11  
11 12 class ArtboxTreeBehavior extends Behavior {
12 13  
... ...
common/modules/product/models/Category.php
... ... @@ -297,9 +297,21 @@ class Category extends \yii\db\ActiveRecord
297 297  
298 298 public function getChildrenByDepth($depth)
299 299 {
300   - return $this->getAllChildren($depth)->where([
301   - 'depth' => $depth,
302   - ])->asArray()->select(['category_id']);
  300 +// VarDumper::dump($this->getAllChildren($depth)
  301 +//
  302 +// ->where([
  303 +// 'depth' => $depth,
  304 +// 'parent_id' => $this->getChildrenAL()
  305 +// ])->asArray()->select(['category_id'])->createCommand()->rawSql, 10, true);
  306 +//
  307 +
  308 +
  309 + return $this->getAllChildren($depth)
  310 +
  311 + ->where([
  312 + 'depth' => $depth,
  313 + 'parent_id' => $this->getChildrenAL()->select('category_id')->column()
  314 + ])->asArray()->select(['category_id']);
303 315 }
304 316  
305 317 public function setTaxGroup($value)
... ...
frontend/controllers/CatalogController.php
... ... @@ -141,7 +141,6 @@ class CatalogController extends \yii\web\Controller
141 141 ],
142 142 ]);
143 143  
144   -
145 144 $products = Product::find()->joinWith('categories')
146 145 ->where([
147 146 'category.category_id' => $category->getChildrenByDepth(2)->column(),
... ...
frontend/views/layouts/main.php
... ... @@ -86,8 +86,8 @@ $brands = Category::find()
86 86 </div>
87 87 </li>
88 88 <li><a href="<?php echo Url::to([
89   - 'product/index',
90   - 'id' => 19,
  89 + 'catalog/category',
  90 + 'category' => 'brendy-oboev',
91 91 ]); ?>">Обои</a></li>
92 92 <li><a href=" <?= Url::to(['catalog/category','category' => 'brendy-tekstilya']) ?>">Текстиль</a></li>
93 93 <?php foreach ($main_menu as $page) { ?>
... ...