diff --git a/backend/controllers/CategoryController.php b/backend/controllers/CategoryController.php
index 45e7ffb..6050f58 100644
--- a/backend/controllers/CategoryController.php
+++ b/backend/controllers/CategoryController.php
@@ -90,7 +90,7 @@ class CategoryController extends Controller
}
return $this->render('create', [
'model' => $model,
- 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
+ 'categories' => ArtboxTreeHelper::treeMap(Category::find()->with('categoryName')->getTree(), 'category_id', 'categoryName.value', '.')
]);
}
}
@@ -110,7 +110,7 @@ class CategoryController extends Controller
} else {
return $this->render('update', [
'model' => $model,
- 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.')
+ 'categories' => ArtboxTreeHelper::treeMap(Category::find()->with('categoryName')->getTree(), 'category_id', 'categoryName.value', '.')
]);
}
}
diff --git a/common/components/artboxtree/ArtboxTreeBehavior.php b/common/components/artboxtree/ArtboxTreeBehavior.php
index 0a20864..73a057f 100644
--- a/common/components/artboxtree/ArtboxTreeBehavior.php
+++ b/common/components/artboxtree/ArtboxTreeBehavior.php
@@ -89,19 +89,20 @@ class ArtboxTreeBehavior extends Behavior {
* get all-level children items
* use MP-method
*/
- public function getAllChildren($depth = null, $where = []) {
- return $this->getAllChildrenMP($depth)->where($where);
+ public function getAllChildren($depth = null, $where = [], $with = null) {
+ return $this->getAllChildrenMP($depth, $where, $with);
}
/*
* get all-level children items
* use MP-method
*/
- public function getAllChildrenTree($depth = null, $where = []) {
- return $this->buildTree($this->getAllChildrenMP($depth, $where)->all(), $this->owner->getAttribute($this->keyNameId));
+ public function getAllChildrenTree($depth = null, $where = [], $with = null) {
+ $query = $this->getAllChildrenMP($depth, $where, $with);
+ return $this->buildTree($query->all(), $this->owner->getAttribute($this->keyNameId));
}
- protected function buildTree(array $data, $parentId = 0) {
+ public function buildTree(array $data, $parentId = 0) {
$result = [];
foreach ($data as $key => $element) {
if ($element->getAttribute($this->keyNameParentId) == $parentId) {
@@ -205,7 +206,7 @@ class ArtboxTreeBehavior extends Behavior {
}
- public function getAllChildrenMP($depth = null)
+ public function getAllChildrenMP($depth = null, $where = [], $with = null)
{
$tableName = $this->owner->tableName();
$path = $this->owner->getAttribute($this->keyNamePath);
@@ -220,6 +221,13 @@ class ArtboxTreeBehavior extends Behavior {
$orderBy["{$tableName}.[[{$this->keyNameDepth}]]"] = SORT_ASC;
$orderBy["{$tableName}.[[{$this->keyNameId}]]"] = SORT_ASC;
+ if ($where) {
+ $query->andWhere($where);
+ }
+ if ($with) {
+ $query->with($with);
+ }
+
$query
->andWhere($this->groupWhere())
->addOrderBy($orderBy);
diff --git a/common/components/artboxtree/ArtboxTreeQueryTrait.php b/common/components/artboxtree/ArtboxTreeQueryTrait.php
index caf5a90..635812b 100644
--- a/common/components/artboxtree/ArtboxTreeQueryTrait.php
+++ b/common/components/artboxtree/ArtboxTreeQueryTrait.php
@@ -23,13 +23,15 @@ trait ArtboxTreeQueryTrait {
return self::$model;
}
- public function getTree($group = null) {
+ public function getTree($group = null, $with = null) {
$model = $this->getModel();
if ($group !== null) {
- $data = $this->andWhere([$model->keyNameGroup => $group])->all();
- } else {
- $data = $this->all();
+ $this->andWhere([$model->keyNameGroup => $group]);
}
+ if ($with) {
+ $this->with($with);
+ }
+ $data = $this->all();
if (empty($data))
return [];
@@ -53,8 +55,8 @@ trait ArtboxTreeQueryTrait {
/**
* @param int $group
*/
- public function rebuildMP($group) {
- $tree = $this->getTree($group);
+ public function rebuildMP($group, $with = null) {
+ $tree = $this->getTree($group, $with);
$this->_recursiveRebuild($tree);
}
diff --git a/common/config/main.php b/common/config/main.php
index 025fb4a..0ce7f94 100644
--- a/common/config/main.php
+++ b/common/config/main.php
@@ -81,14 +81,17 @@ return [
'entity1' => [
'model' => '\common\modules\product\models\Product',
'label' => 'Product',
- 'listField' => 'fullname',
+ 'listField' => 'name',
+ 'searchField' => 'name',
'key' => 'product_id',
'linked_key' => 'product_id',
],
'entity2' => [
'model' => '\common\modules\product\models\Category',
'label' => 'Category',
- 'listField' => 'name',
+ 'listField' => 'categoryName.value',
+ 'searchField' => 'category_name.value',
+ 'searchJoin' => 'categoryName',
'key' => 'category_id',
'linked_key' => 'category_id',
'hierarchy' => [
diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php
index 3ce35cb..3b51135 100644
--- a/common/modules/product/helpers/ProductHelper.php
+++ b/common/modules/product/helpers/ProductHelper.php
@@ -8,10 +8,10 @@ use yii\base\Object;
class ProductHelper extends Object {
public static function getCategories() {
- return Category::find()->getTree();
+ return Category::find()->with('categoryName')->getTree();
}
public static function getBrands() {
- return Brand::find();
+ return Brand::find()->with('brandName');
}
}
\ No newline at end of file
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php
index 68e9d0e..b11857b 100644
--- a/common/modules/product/models/Brand.php
+++ b/common/modules/product/models/Brand.php
@@ -111,6 +111,7 @@ class Brand extends \yii\db\ActiveRecord
}
public function getName() {
+ return $this->brandName->value;
$value = $this->getBrandName()->one();
return empty($value) ? $this->_getValue('name') : $value->value;
}
diff --git a/common/modules/product/models/BrandSearch.php b/common/modules/product/models/BrandSearch.php
index 0fb516f..1bcb3b3 100644
--- a/common/modules/product/models/BrandSearch.php
+++ b/common/modules/product/models/BrandSearch.php
@@ -41,7 +41,7 @@ class BrandSearch extends Brand
*/
public function search($params)
{
- $query = Brand::find();
+ $query = Brand::find()->with('brandName');
// add conditions that should always apply here
diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php
index dacecae..e5ba63d 100644
--- a/common/modules/product/models/Category.php
+++ b/common/modules/product/models/Category.php
@@ -87,6 +87,7 @@ class Category extends \yii\db\ActiveRecord
[['alias', 'name'], 'string', 'max' => 250],
[['populary'], 'boolean'],
[['group_to_category'], 'safe'],
+ [['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']],
// [['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'],
// [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']],
];
@@ -160,8 +161,9 @@ class Category extends \yii\db\ActiveRecord
return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']);
}
- public function getName() {
- $value = $this->getCategoryName()->one();
- return empty($value) ? $this->_getValue('name') : $value->value;
- }
+// public function getName() {
+//// return $this->getCategoryName();
+// $value = $this->getCategoryName()->one();
+// return empty($value) ? $this->_getValue('name') : $value->value;
+// }
}
diff --git a/common/modules/product/models/CategoryQuery.php b/common/modules/product/models/CategoryQuery.php
index 069d8e7..5ccb07d 100644
--- a/common/modules/product/models/CategoryQuery.php
+++ b/common/modules/product/models/CategoryQuery.php
@@ -34,15 +34,4 @@ class CategoryQuery extends \yii\db\ActiveQuery
{
return parent::one($db);
}
-
- /**
- * Select category by alias
- * @param $slug
- * @return $this
- */
- public function byAlias($alias)
- {
- $this->andFilterWhere(['alias' => $alias]);
- return $this;
- }
}
diff --git a/common/modules/product/models/CategorySearch.php b/common/modules/product/models/CategorySearch.php
index ae60343..1155ea2 100644
--- a/common/modules/product/models/CategorySearch.php
+++ b/common/modules/product/models/CategorySearch.php
@@ -55,7 +55,7 @@ class CategorySearch extends Category
*/
public function search($params)
{
- $query = Category::find();
+ $query = Category::find()->with('categoryName');
// add conditions that should always apply here
@@ -88,8 +88,9 @@ class CategorySearch extends Category
public static function findByAlias($alias) {
/** @var CategoryQuery $query */
- $query = Category::find();
- $query->byAlias($alias);
+ $query = Category::find()
+ ->with('categoryName')
+ ->andFilterWhere(['alias' => $alias]);
if (($model = $query->one()) !== null) {
return $model;
} else {
diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php
index 96ce8ee..f09eeed 100644
--- a/common/modules/product/models/Product.php
+++ b/common/modules/product/models/Product.php
@@ -22,7 +22,7 @@ use yii\db\ActiveQuery;
*/
class Product extends \yii\db\ActiveRecord
{
- /** @var array $variants */
+ /** @var array $_variants */
public $_variants = [];
/** @var array $_images */
diff --git a/common/modules/product/widgets/brandsCarouselWidget.php b/common/modules/product/widgets/brandsCarouselWidget.php
index 02e4a5e..f047e2f 100644
--- a/common/modules/product/widgets/brandsCarouselWidget.php
+++ b/common/modules/product/widgets/brandsCarouselWidget.php
@@ -13,7 +13,7 @@ class brandsCarouselWidget extends Widget {
}
public function run() {
- $brands = Brand::find()->all();
+ $brands = Brand::find()->with('brandName')->all();
return $this->render('brandsCarousel', [
'brands' => $brands,
]);
diff --git a/common/modules/product/widgets/catalogSubmenuWidget.php b/common/modules/product/widgets/catalogSubmenuWidget.php
index a3cb377..feade10 100644
--- a/common/modules/product/widgets/catalogSubmenuWidget.php
+++ b/common/modules/product/widgets/catalogSubmenuWidget.php
@@ -15,12 +15,22 @@ class catalogSubmenuWidget extends Widget {
}
public function run() {
+ /** @var Category $rootCategory */
$rootCategory = Category::findOne($this->root_id);
+
+ $categories = $rootCategory->getAllChildren(2, [], 'categoryName')->all();
+ $populary = [];
+ foreach($categories as $category) {
+ if ($category->populary) {
+ $populary[] = $category;
+ }
+ }
+
return $this->render('submenu', [
'rootCategory' => $rootCategory,
'rootClass' => $this->rootClass,
- 'populary' => $rootCategory->getAllChildren(2, ['populary' => true])->all(),
- 'items' => $rootCategory->getAllChildrenTree(2)
+ 'populary' => $populary,
+ 'items' => $rootCategory->buildTree($categories, $rootCategory->category_id)
]);
}
}
\ No newline at end of file
diff --git a/common/modules/product/widgets/views/submenu.php b/common/modules/product/widgets/views/submenu.php
index 7b2397b..b879e2a 100644
--- a/common/modules/product/widgets/views/submenu.php
+++ b/common/modules/product/widgets/views/submenu.php
@@ -1,5 +1,5 @@
@@ -24,7 +24,7 @@
- = $item['item']->name?>
+ = $item['item']->categoryName->value?>
@@ -34,17 +34,17 @@
image)) :?>

-
![<?= $_item['item']->name?>](<?= $_item['item']->image?>)
+
-
= $_item['item']->name?>
+
= $_item['item']->categoryName->value?>
-
+
diff --git a/common/modules/relation/controllers/ManageController.php b/common/modules/relation/controllers/ManageController.php
index 2b797e4..23ee671 100644
--- a/common/modules/relation/controllers/ManageController.php
+++ b/common/modules/relation/controllers/ManageController.php
@@ -4,8 +4,12 @@ namespace common\modules\relation\controllers;
use common\modules\rubrication\models\TaxOption;
use yii\base\Exception;
+use yii\db\ActiveQuery;
+use yii\helpers\ArrayHelper;
+use yii\web\Response;
use yii\data\ActiveDataProvider;
use yii\db\ActiveRecord;
+use yii\filters\ContentNegotiator;
use yii\web\Controller;
use Yii;
use common\modules\relation\relationHelper;
@@ -18,6 +22,20 @@ use yii\web\NotFoundHttpException;
*/
class ManageController extends Controller
{
+ public function behaviors()
+ {
+ return [
+ /*'bootstrap' => [
+ 'class' => ContentNegotiator::className(),
+ 'only' => ['autocomplete'],
+ 'formats' => [ 'application/json' => Response::FORMAT_JSON],
+ 'languages' => [
+ 'ru',
+ ],
+ ],*/
+ ];
+ }
+
/**
* Renders the relations view
* @return string
@@ -66,14 +84,6 @@ class ManageController extends Controller
$model = new $relation['via']['model'];
- $query1 = $relation['entity1']['model']::find();
- if (!empty($relation['entity1']['where']))
- $query1->where($relation['entity1']['where']);
-
- $query2 = $relation['entity2']['model']::find();
- if (!empty($relation['entity2']['where']))
- $query2->where($relation['entity2']['where']);
-
if ($model->load(Yii::$app->request->post())) {
$model->save();
return $this->redirect(['pars', 'relation' => $relation_key]);
@@ -81,8 +91,8 @@ class ManageController extends Controller
} else {
return $this->render('create', [
'model' => $model,
- 'items1' => $query1->all(),
- 'items2' => $query2->all(),
+// 'items1' => $query1->limit(100)->all(),
+// 'items2' => $query2->asArray()->all(),
'relation_key' => $relation_key,
'relation' => $relation,
]);
@@ -103,14 +113,6 @@ class ManageController extends Controller
$model = $this->findModel($relation_key, $id1, $id2);
- $query1 = $relation['entity1']['model']::find();
- if (!empty($relation['entity1']['where']))
- $query1->where($relation['entity1']['where']);
-
- $query2 = $relation['entity2']['model']::find();
- if (!empty($relation['entity2']['where']))
- $query2->where($relation['entity2']['where']);
-
if ($model->load(Yii::$app->request->post())) {
$connection = Yii::$app->getDb();
$transaction = $connection->beginTransaction();
@@ -137,8 +139,8 @@ class ManageController extends Controller
} else {
return $this->render('update', [
'model' => $model,
- 'items1' => $query1->all(),
- 'items2' => $query2->all(),
+ 'value1' => $model->entity1->getAttribute($relation['entity1']['listField']),
+ 'value2' => $model->entity2->getAttribute($relation['entity2']['listField']),
'relation_key' => $relation_key,
'relation' => $relation,
]);
@@ -178,6 +180,28 @@ class ManageController extends Controller
return $this->redirect(['pars', 'relation' => $relation_key]);
}
+ public function actionAutocomplete() {
+ $relation_key = Yii::$app->request->get('relation_key');
+ $entity = Yii::$app->request->get('entity');
+ $term = Yii::$app->request->get('term');
+ $relation_key = strtolower($relation_key);
+ $relation = relationHelper::getRelation($relation_key);
+
+ /** @var ActiveQuery $query */
+ $query = $relation[$entity]['model']::find();
+
+ if (!empty($relation[$entity]['searchJoin'])) {
+ $query->innerJoinWith($relation[$entity]['searchJoin']);
+ }
+ if (!empty($relation[$entity]['where'])) {
+ $query->where($relation[$entity]['where']);
+ }
+ $query->where(['ilike', $relation[$entity]['searchField'], $term]);
+
+ print json_encode(ArrayHelper::map($query->limit(50)->all(), $relation[$entity]['key'], $relation[$entity]['listField']));
+ exit;
+ }
+
/**
* Finds the based model for relation on its primaries keys value.
* If the model is not found, a 404 HTTP exception will be thrown.
diff --git a/common/modules/relation/views/manage/_form.php b/common/modules/relation/views/manage/_form.php
index 0c047f0..4a92db8 100644
--- a/common/modules/relation/views/manage/_form.php
+++ b/common/modules/relation/views/manage/_form.php
@@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
+use yii\jui\AutoComplete;
/* @var $this yii\web\View */
/* @var $model common\modules\rubrication\models\TaxGroup */
@@ -13,19 +14,40 @@ use yii\helpers\ArrayHelper;
- = $form->field($model, $relation['entity1']['linked_key'])->dropDownList(
- ArrayHelper::map($items1, $relation['entity1']['key'], $relation['entity1']['listField']),
- [
- 'prompt' => Yii::t('relation', 'Select value'),
+ = $form->field($model, $relation['entity1']['linked_key'])->widget(
+ AutoComplete::className(), [
+// 'model' => \common\modules\relation\models\Relation::className(),
+ 'clientOptions' => [
+ 'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity1']),
+ 'dataType' => 'json',
+ 'autoFill' => true,
+ 'minLength' => '2',
+ ],
+ 'options' => [
+ 'value' => empty($value1) ? '' : $value1,
+ 'class'=>'form-control',
+ 'placeholder' => $relation['entity1']['label']
]
- ) ?>
-
- = $form->field($model, $relation['entity2']['linked_key'])->dropDownList(
- ArrayHelper::map($items2, $relation['entity2']['key'], $relation['entity2']['listField']),
- [
- 'prompt' => Yii::t('relation', 'Select value'),
+ ]);
+ ?>
+
+ = $form->field($model, $relation['entity2']['linked_key'])->widget(
+ AutoComplete::className(), [
+// 'model' => \common\modules\relation\models\Relation::className(),
+ 'clientOptions' => [
+ 'source' => \yii\helpers\Url::to(['manage/autocomplete/', 'relation_key' => $relation_key, 'entity' => 'entity2']),
+ 'dataType' => 'json',
+ 'autoFill' => true,
+ 'minLength' => '2',
+ 'allowClear' => true,
+ ],
+ 'options' => [
+ 'value' => empty($value2) ? '' : $value2,
+ 'class'=>'form-control',
+ 'placeholder' => $relation['entity2']['label']
]
- ) ?>
+ ]);
+ ?>
= Html::submitButton($model->isNewRecord ? Yii::t('relation', 'Create') : Yii::t('relation', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/common/modules/relation/views/manage/create.php b/common/modules/relation/views/manage/create.php
index 743430c..863f0f7 100644
--- a/common/modules/relation/views/manage/create.php
+++ b/common/modules/relation/views/manage/create.php
@@ -2,7 +2,6 @@
use yii\helpers\Html;
-
/* @var $this yii\web\View */
$this->title = Yii::t('relation', $relation['name']);
@@ -16,8 +15,6 @@ $this->params['breadcrumbs'][] = $this->title;
= $this->render('_form', [
'model' => $model,
- 'items1' => $items1,
- 'items2' => $items2,
'relation_key' => $relation_key,
'relation' => $relation,
]) ?>
diff --git a/common/modules/relation/views/manage/update.php b/common/modules/relation/views/manage/update.php
index 743430c..10b28f0 100644
--- a/common/modules/relation/views/manage/update.php
+++ b/common/modules/relation/views/manage/update.php
@@ -16,8 +16,8 @@ $this->params['breadcrumbs'][] = $this->title;
= $this->render('_form', [
'model' => $model,
- 'items1' => $items1,
- 'items2' => $items2,
+ 'value1' => $value1,
+ 'value2' => $value2,
'relation_key' => $relation_key,
'relation' => $relation,
]) ?>
diff --git a/common/modules/rubrication/models/TaxOption.php b/common/modules/rubrication/models/TaxOption.php
index 52a36b4..45d7f3a 100644
--- a/common/modules/rubrication/models/TaxOption.php
+++ b/common/modules/rubrication/models/TaxOption.php
@@ -166,7 +166,7 @@ class TaxOption extends \yii\db\ActiveRecord
public function getValueRenderFlash()
{
$valueClass = $this->getValueModelName();
- $value = $this->getValue()->one();
+ $value = $this->value;
if ($valueClass && method_exists($valueClass, 'getValueRenderFlash')) {
return $valueClass::getValueRenderFlash($value);
} elseif(!empty($value)) {
@@ -181,7 +181,7 @@ class TaxOption extends \yii\db\ActiveRecord
public function getValueRenderHTML()
{
$valueClass = $this->getValueModelName();
- $value = $this->getValue()->one();
+ $value = $this->value;
if ($valueClass && method_exists($valueClass, 'getValueRenderHTML')) {
return $valueClass::getValueRenderHTML($value);
} else {
@@ -219,7 +219,7 @@ class TaxOption extends \yii\db\ActiveRecord
// }
private function getValueModelName() {
- $group = $this->getTaxGroup()->one();
+ $group = $this->taxGroup;
$valueClass = '\common\modules\rubrication\models\TaxValue'. ucfirst($group->module);
return class_exists($valueClass) ? $valueClass : FALSE;
}
diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php
index e3dc6b3..7fdb041 100644
--- a/frontend/controllers/CatalogController.php
+++ b/frontend/controllers/CatalogController.php
@@ -12,6 +12,7 @@ use common\modules\product\models\ProductSearch;
use common\modules\product\models\ProductVariant;
use common\modules\rubrication\models\TaxGroup;
use common\modules\rubrication\models\TaxOption;
+use common\modules\rubrication\models\TaxValueString;
use yii\data\ActiveDataProvider;
use yii\data\Pagination;
use yii\data\Sort;
@@ -64,6 +65,7 @@ class CatalogController extends \yii\web\Controller
$all_count = $query->count();
$brandsQuery = Brand::find()
+ ->innerJoinWith('brandName')
->innerJoinWith('products')
->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id')
->where([
@@ -71,7 +73,7 @@ class CatalogController extends \yii\web\Controller
])
->groupBy(Brand::tableName() .'.brand_id');
$brands = $brandsQuery->all();
- $brands_count = $brandsQuery->count();
+ $brands_count = count($brands); // $brandsQuery->count();
$optionsQuery = TaxOption::find()
->select([
@@ -80,6 +82,7 @@ class CatalogController extends \yii\web\Controller
])
->innerJoin(ProductOption::tableName(), ProductOption::tableName() .'.option_id='. TaxOption::tableName() .'.tax_option_id')
->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. ProductOption::tableName() .'.product_id')
+ ->innerJoinWith('group')
->where([
ProductCategory::tableName() .'.category_id' => $category->category_id
])
@@ -133,12 +136,12 @@ class CatalogController extends \yii\web\Controller
foreach($options_alias as &$option_alias) {
$option_alias = "'". $option_alias ."'";
}
- $group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one();
+ /*$group = TaxGroup::find()->where(['like', 'alias', $group_alias])->one();
if (!$group) {
continue;
- }
- $query->andWhere(Product::tableName() .'.product_id IN (SELECT product_id AS products FROM product_option INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id WHERE tax_option.alias IN ('. implode(',', $options_alias) .'))');
+ }*/
}
+ $query->andWhere(Product::tableName() .'.product_id IN (SELECT product_id AS products FROM product_option INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id WHERE tax_option.alias IN ('. implode(',', $options_alias) .'))');
}
if (($_brands = \Yii::$app->request->get('brand')) != false && is_array($_brands) && count($_brands) > 0) {
@@ -152,12 +155,17 @@ class CatalogController extends \yii\web\Controller
}
}
- $count = $query->count();
+ $query->with('variant');
+ $query->with('brand');
+ $query->with('categories');
+ $query->with('image');
+ $count = $query->count();
$pages = new Pagination(['totalCount' => $count, 'pageSize' => $per_page]);
$query->offset($pages->offset)
->orderBy($sort->orders)
->limit($pages->limit);
+
$products = $query->all();
return $this->render(
diff --git a/frontend/views/catalog/categories.php b/frontend/views/catalog/categories.php
index 84406f7..4989978 100644
--- a/frontend/views/catalog/categories.php
+++ b/frontend/views/catalog/categories.php
@@ -14,7 +14,7 @@ $this->params['breadcrumbs'][] = $this->title;
- getAllChildrenTree(2) as $category) :?>
+ getAllChildrenTree(2, [], 'categoryName') as $category) :?>
image)) :?>
diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php
index 4a7c749..231cd33 100644
--- a/frontend/views/catalog/products.php
+++ b/frontend/views/catalog/products.php
@@ -2,11 +2,11 @@
/** @var $this \yii\web\View */
/** @var $dataProvider \yii\data\ActiveDataProvider */
-$this->title = $category->name;
+$this->title = $category->categoryName->value;
foreach($category->getParents()->all() as $parent) {
- $this->params['breadcrumbs'][] = ['label' => $parent->name, 'url' => ['catalog/category', 'alias' => $parent->alias]];
+ $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'alias' => $parent->alias]];
}
-$this->params['breadcrumbs'][] = $category->name;
+$this->params['breadcrumbs'][] = $category->categoryName->value;
?>