diff --git a/backend/views/category/index.php b/backend/views/category/index.php index dbf9a38..5f203b6 100755 --- a/backend/views/category/index.php +++ b/backend/views/category/index.php @@ -21,49 +21,27 @@

$dataProvider, + 'filterModel' => $searchModel, 'columns' => [ [ 'class' => 'yii\grid\SerialColumn' ], + 'category_id', [ - 'label' => Yii::t('product', 'Name'), + 'attribute' => 'category_name', 'content' => function($data) { /** * @var Category $data */ $op = []; - foreach($data->getParents() + foreach($data->getParents()->with('lang') ->all() as $parent) { - $op[] = $parent->category_id; + $op[] = $parent->lang->name; } - $op[] = $data->category_id; + $op[] = $data->lang->name; return implode(' → ', $op); }, ], [ 'class' => 'yii\grid\ActionColumn', - 'template' => '{view} {update} {delete}', - 'urlCreator' => function($action, $model, $key, $index) { - switch($action) { - case 'view': - return \yii\helpers\Url::to([ - 'category/view', - 'id' => $model->category_id, - ]); - break; - case 'update': - return \yii\helpers\Url::to([ - 'category/update', - 'id' => $model->category_id, - ]); - break; - case 'delete': - return \yii\helpers\Url::to([ - 'category/delete', - 'id' => $model->category_id, - ]); - break; - } - return ''; - }, ], ], 'panel' => [ diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index bf74208..ffb90cd 100755 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -68,10 +68,12 @@ $variants = $model->getVariants() ->with('lang') ->all(); + $properties = $model->getProperties(); return $this->render('view', [ 'model' => $this->findModel($id), 'categories' => $categories, 'variants' => $variants, + 'properties' => $properties, ]); } diff --git a/common/modules/product/controllers/VariantController.php b/common/modules/product/controllers/VariantController.php index 5fa2d40..8654148 100755 --- a/common/modules/product/controllers/VariantController.php +++ b/common/modules/product/controllers/VariantController.php @@ -6,7 +6,7 @@ use common\modules\product\models\ProductImage; use common\modules\product\models\ProductStock; use common\modules\product\models\ProductVariant; - use common\modules\product\models\ProductVariantListSearch; + use common\modules\product\models\ProductVariantSearch; use common\modules\product\models\Stock; use Yii; use yii\web\Controller; @@ -14,7 +14,7 @@ use yii\filters\VerbFilter; /** - * ManageController implements the CRUD actions for ProductVariant model. + * VartiantController implements the CRUD actions for ProductVariant model. */ class VariantController extends Controller { @@ -40,18 +40,16 @@ */ public function actionIndex($product_id) { - $searchModel = new ProductVariantListSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $product_id); - - if(( $product = Yii::$app->request->get('product_id') ) !== NULL) { - $product = Product::findOne($product); - } + $product = $this->findProduct($product_id); + $searchModel = new ProductVariantSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $dataProvider->query->andWhere([ 'product_id' => $product->product_id ]) + ->with('image'); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'product' => $product, - 'product_id' => $product_id, ]); } @@ -64,8 +62,11 @@ */ public function actionView($id) { + $model = $this->findModel($id); + $properties = $model->getProperties(); return $this->render('view', [ - 'model' => $this->findModel($id), + 'model' => $model, + 'properties' => $properties, ]); } @@ -76,8 +77,9 @@ */ public function actionCreate($product_id) { + $product = $this->findProduct($product_id); $model = new ProductVariant(); - $model->product_id = $product_id; + $model->product_id = $product->product_id; $model->generateLangs(); if($model->load(Yii::$app->request->post())) { $model->loadLangs(\Yii::$app->request); @@ -132,7 +134,7 @@ if($model->save() && $model->transactionStatus) { return $this->redirect([ 'index', - 'product_id' => $product_id, + 'product_id' => $product->product_id, ]); } } @@ -143,6 +145,7 @@ 'model_langs' => $model->model_langs, 'groups' => $groups, 'stocks' => [ new ProductStock() ], + 'product' => $product, ]); } @@ -157,6 +160,7 @@ */ public function actionUpdate($product_id, $id) { + $product = $this->findProduct($product_id); $model = $this->findModel($id); $model->generateLangs(); if($model->load(Yii::$app->request->post())) { @@ -222,6 +226,7 @@ 'model_langs' => $model->model_langs, 'groups' => $groups, 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ], + 'product' => $product, ]); } @@ -269,7 +274,30 @@ */ protected function findModel($id) { - if(( $model = ProductVariant::findOne($id) ) !== NULL) { + if(( $model = ProductVariant::find() + ->where([ 'product_variant_id' => $id ]) + ->with('lang') + ->one() ) !== NULL + ) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + /** + * @param int $product_id + * + * @return Product + * @throws NotFoundHttpException + */ + protected function findProduct($product_id) + { + if(( $model = Product::find() + ->with('lang') + ->where([ 'product_id' => $product_id ]) + ->one() ) !== NULL + ) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); diff --git a/common/modules/product/models/CategorySearch.php b/common/modules/product/models/CategorySearch.php index 4355ead..082a9c4 100755 --- a/common/modules/product/models/CategorySearch.php +++ b/common/modules/product/models/CategorySearch.php @@ -1,74 +1,91 @@ $query, - ]); - - $this->load($params); - - /*if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - return $dataProvider; - }*/ - - // grid filtering conditions - $query->andFilterWhere([ - 'category.category_id' => $this->category_id, - 'category.parent_id' => $this->parent_id, - 'category.product_unit_id' => $this->product_unit_id, - ]); - $query->orderBy(['category.path' => SORT_ASC, 'category.depth' => SORT_ASC, 'category.category_id' => SORT_ASC]); - - return $dataProvider; + public $category_name; + + public function behaviors() + { + return []; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'category_name' ], + 'safe', + ], + [ + [], + 'integer', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Category::find() + ->joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'sort' => false, + ]); + + $this->load($params); + + /*if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + }*/ + + // grid filtering conditions + $query->andFilterWhere([ + 'ilike', + 'category_lang.name', + $this->category_name, + ]); + + $query->orderBy([ + 'category.path' => SORT_ASC, + 'category.depth' => SORT_ASC, + 'category.category_id' => SORT_ASC, + ]); + + return $dataProvider; + } } -} diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 04b3b1e..3c382d5 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -104,15 +104,15 @@ 'model' => ProductCertificate::className(), ], 'multipleImage' => [ - 'class' => MultipleImgBehavior::className(), - 'links' => [ + 'class' => MultipleImgBehavior::className(), + 'links' => [ 'product_id' => 'product_id', ], - 'model' => ProductImage::className(), + 'model' => ProductImage::className(), 'config' => [ - 'caption' => 'image', + 'caption' => 'image', 'delete_action' => '/product/manage/delimg', - 'id' => 'product_image_id', + 'id' => 'product_image_id', ], ], [ @@ -302,14 +302,20 @@ ->viaTable('product_option', [ 'product_id' => 'product_id' ]); } + /** + * @return TaxGroup[] + */ public function getProperties() { $groups = $options = []; - foreach($this->options as $option) { + foreach($this->getOptions() + ->with('lang') + ->all() as $option) { $options[ $option->tax_group_id ][] = $option; } foreach(TaxGroup::find() ->where([ 'tax_group_id' => array_keys($options) ]) + ->with('lang') ->all() as $group) { if(!empty( $options[ $group->tax_group_id ] )) { $group->_options = $options[ $group->tax_group_id ]; diff --git a/common/modules/product/models/ProductSearch.php b/common/modules/product/models/ProductSearch.php index 57f8add..e486460 100755 --- a/common/modules/product/models/ProductSearch.php +++ b/common/modules/product/models/ProductSearch.php @@ -93,7 +93,6 @@ { $query = Product::find(); - $query->select([ 'product.*', 'COUNT(product_variant.product_variant_id) as count', @@ -123,10 +122,6 @@ 'query' => $query, ]); - if(!( $this->load($params) && $this->validate() )) { - return $dataProvider; - } - $dataProvider->setSort([ 'attributes' => [ 'product_id', @@ -147,17 +142,17 @@ ]); if(isset( $this->is_top )) { - $query->andFilterWhere([ + $query->andWhere([ 'is_top' => (bool) $this->is_top, ]); } if(isset( $this->is_new )) { - $query->andFilterWhere([ + $query->andWhere([ 'is_new' => (bool) $this->is_new, ]); } if(isset( $this->akciya )) { - $query->andFilterWhere([ + $query->andWhere([ 'akciya' => (bool) $this->akciya, ]); } diff --git a/common/modules/product/models/ProductVariantSearch.php b/common/modules/product/models/ProductVariantSearch.php index ca30c24..12be9bf 100755 --- a/common/modules/product/models/ProductVariantSearch.php +++ b/common/modules/product/models/ProductVariantSearch.php @@ -1,141 +1,141 @@ $query, - ]); - - $this->load($params); - - if (!empty($params['product_id'])) { - $this->product_id = $params['product_id']; - } - - if (!$this->validate()) { - // uncomment the following line if you do not want to return any records when validation fails - // $query->where('0=1'); - return $dataProvider; + + public $variant_name; + + public function behaviors() + { + return []; } - - $dataProvider->setSort([ - 'attributes' => [ - 'name' => [ - 'asc' => ['product_variant.name' => SORT_ASC], - 'desc' => ['product_variant.value' => SORT_DESC], - 'default' => SORT_DESC, - 'label' => 'Variant name', + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'variant_name', + 'sku', + ], + 'safe', ], - 'brand_name' => [ - 'asc' => ['brand_name.value' => SORT_ASC], - 'desc' => ['brand_name.value' => SORT_DESC], - 'default' => SORT_DESC, - 'label' => 'Brand name', + [ + [ + 'product_variant_id', + 'stock', + ], + 'integer', ], - 'category_name', - 'sku', - ] - ]); - - $query->joinWith(['product', 'product.brand', 'product.categories']); - - if (isset($this->is_top)) { - $query->andFilterWhere([ - 'product.is_top' => (bool)$this->is_top, - ]); + [ + [ + 'price', + 'price_old', + ], + 'number', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); } - if (isset($this->is_new)) { + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = ProductVariant::find() + ->joinWith('lang'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if(!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $dataProvider->setSort([ + 'attributes' => [ + 'product_variant_id', + 'sku', + 'variant_name' => [ + 'asc' => [ 'product_variant_lang.name' => SORT_ASC ], + 'desc' => [ 'product_variant_lang.name' => SORT_DESC ], + ], + 'price', + 'price_old', + 'stock', + ], + ]); + $query->andFilterWhere([ - 'product.is_new' => (bool)$this->is_new, + 'price' => $this->price, + 'price_old' => $this->price_old, + 'stock' => $this->stock, ]); - } - if (isset($this->akciya)) { + $query->andFilterWhere([ - 'product.akciya' => (bool)$this->akciya, + 'ilike', + 'product_variant_lang.name', + $this->variant_name, + ]) + ->andFilterWhere([ + 'ilike', + 'sku', + $this->sku, + ]); + + $query->groupBy([ + 'product_variant.product_variant_id', + 'product_variant_lang.name', ]); + + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'product_variant.product_id' => $this->product_id, - 'product_variant_id' => $this->product_variant_id, - ]); - - if (!empty($this->fullname)) { - $query->orFilterWhere(['like', 'product_variant.name', $this->fullname]); - $query->orFilterWhere(['ilike', 'product.name', $this->fullname]); - } - $query->andFilterWhere(['ilike', 'product.brand_name.value', $this->brand_name]); - $query->andFilterWhere(['ilike', 'product.category_name.value', $this->category_name]); - $query->andFilterWhere(['ilike', 'sku', $this->sku]); - - $query->groupBy(['product_variant_id']); - $query->orderBy(['product_variant.product_id' => SORT_ASC]); - - return $dataProvider; - } - - public static function findBySku($sku) { - /** @var ActiveQuery $query */ - $query = ProductVariant::find() - ->andFilterWhere(['sku' => $sku]); - if (($model = $query->one()) !== null) { - return $model; + + /** + * @param string $sku + * + * @return ProductVariant|null + */ + public static function findBySku($sku) + { + /** + * @var ProductVariant|null $result + */ + $result = ProductVariant::find() + ->andWhere([ 'sku' => $sku ]) + ->one(); + return $result; } - return NULL; } -} diff --git a/common/modules/product/views/manage/update.php b/common/modules/product/views/manage/update.php index 827f779..92e23a3 100755 --- a/common/modules/product/views/manage/update.php +++ b/common/modules/product/views/manage/update.php @@ -17,13 +17,13 @@ $this->title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Product', - ]) . ' ' . $model->product_id; + ]) . ' ' . $model->lang->name; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Products'), 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->product_id, + 'label' => $model->lang->name, 'url' => [ 'view', 'id' => $model->product_id, diff --git a/common/modules/product/views/manage/view.php b/common/modules/product/views/manage/view.php index 6bc195e..4e3c863 100755 --- a/common/modules/product/views/manage/view.php +++ b/common/modules/product/views/manage/view.php @@ -2,15 +2,19 @@ use common\modules\product\models\Category; use common\modules\product\models\Product; + use common\modules\product\models\ProductVariant; + use common\modules\rubrication\models\TaxGroup; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\web\View; use yii\widgets\DetailView; /** - * @var View $this - * @var Product $model - * @var Category[] $categories + * @var View $this + * @var Product $model + * @var Category[] $categories + * @var TaxGroup[] $properties + * @var ProductVariant[] $variants */ $this->title = $model->lang->name; @@ -19,6 +23,21 @@ 'url' => [ 'index' ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; + $properties_string = ''; + foreach($properties as $property) { + $property_list = ''; + foreach($property->options as $option) { + $property_list .= Html::tag('li', $option->lang->value); + } + $properties_string .= Html::tag('p', $property->lang->name) . Html::tag('ul', $property_list); + } + $variants_string = ''; + foreach($variants as $variant) { + $variants_string .= Html::a($variant->lang->name, [ + '/product/variant/view', + 'id' => $variant->product_variant_id, + ]) . '
'; + } ?>
@@ -39,6 +58,10 @@ 'method' => 'post', ], ]) ?> + $model->product_id, + ], [ 'class' => 'btn btn-info' ]) ?>

'video', + 'format' => 'html', + ], + [ + 'label' => \Yii::t('app', 'Properties'), + 'value' => $properties_string, + 'format' => 'html', + ], + [ + 'label' => \Yii::t('app', 'Variants'), + 'value' => $variants_string, 'format' => 'html', ], + 'lang.description:html', 'image.imageUrl:image', ], ]) ?> diff --git a/common/modules/product/views/variant/_form.php b/common/modules/product/views/variant/_form.php index d953378..f327383 100755 --- a/common/modules/product/views/variant/_form.php +++ b/common/modules/product/views/variant/_form.php @@ -1,6 +1,7 @@ textarea(); ?> field($model, 'imagesUpload[]') ->widget(\kartik\file\FileInput::className(), [ - 'language' => 'ru', + 'language' => 'ru', 'options' => [ 'accept' => 'image/*', 'multiple' => true, diff --git a/common/modules/product/views/variant/create.php b/common/modules/product/views/variant/create.php index 6df229a..de7b2ec 100755 --- a/common/modules/product/views/variant/create.php +++ b/common/modules/product/views/variant/create.php @@ -1,5 +1,6 @@ title = Yii::t('product', 'Create Product'); + $this->title = Yii::t('product', 'Create Variant'); $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Products'), - 'url' => [ 'index' ], + 'url' => [ '/product/manage/index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $product->lang->name, + 'url' => [ '/product/manage/view', 'id' => $product->product_id ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('product', 'Variants'), + 'url' => [ 'index', 'product_id' => $product->product_id ], ]; $this->params[ 'breadcrumbs' ][] = $this->title; ?> @@ -30,6 +40,7 @@ 'model_langs' => $model_langs, 'groups' => $groups, 'stocks' => $stocks, + 'product' => $product, ]) ?>
diff --git a/common/modules/product/views/variant/index.php b/common/modules/product/views/variant/index.php index 6907964..3fcc265 100755 --- a/common/modules/product/views/variant/index.php +++ b/common/modules/product/views/variant/index.php @@ -1,90 +1,91 @@ title = Yii::t('product', 'Variants'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['/product/manage']]; -if (!empty($product)) { - $this->params['breadcrumbs'] = [ - ['label' => Yii::t('product', 'Variants'), 'url' => ['/product/variant']], - $product->fullname + + use common\modules\product\models\Product; + use common\modules\product\models\ProductVariantSearch; + use yii\data\ActiveDataProvider; + use yii\helpers\Html; + use yii\grid\GridView; + use yii\helpers\Url; + use yii\web\View; + + /** + * @var View $this + * @var ProductVariantSearch $searchModel + * @var ActiveDataProvider $dataProvider + * @var Product $product + */ + + $this->title = Yii::t('product', 'Variants for ').$product->lang->name; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('product', 'Products'), + 'url' => [ '/product/manage/index' ], ]; -} else { - $this->params['breadcrumbs'][] = $this->title; -} + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $product->lang->name, + 'url' => [ + '/product/manage/view', + 'id' => $product->product_id, + ], + ]; + $this->params['breadcrumbs'][] = \Yii::t('product', 'Variants'); ?>
- +

title) ?>

- +

- $product_id]), ['class' => 'btn btn-success']) ?> + $product->product_id, + ]), [ 'class' => 'btn btn-success' ]) ?>

$dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], + 'filterModel' => $searchModel, + 'columns' => [ + 'product_variant_id', [ - 'attribute' => 'product_id', - 'value' => 'fullname', - 'label' => Yii::t('product', 'Name'), - 'filter' => \kartik\select2\Select2::widget([ - 'model' => $searchModel, - 'attribute' => 'product_id', -// 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\Product::find()->orderBy(['name' => 'ASC'])->all(), 'product_id', 'name'), - 'language' => 'ru', - 'options' => [ - 'placeholder' => Yii::t('product', 'Select product'), - 'multiple' => false, - ], - 'pluginOptions' => [ - 'allowClear' => true - ], - ]), + 'attribute' => 'variant_name', + 'value' => 'lang.name', ], 'sku', 'price', 'price_old', 'stock', + 'image.imageUrl:image', [ - 'class' => 'yii\grid\ActionColumn', - 'buttons' => [ - 'view' => function ($url, $model) - { - return Html::a ( - '', - Url::to(['view','product_id'=> $model->product_id, 'id' => $model->product_variant_id]), - [ - 'title' => "Просмотр", - ] - ); + 'class' => 'yii\grid\ActionColumn', + 'buttons' => [ + 'view' => function($url, $model) { + return Html::a('', Url::to([ + 'view', + 'product_id' => $model->product_id, + 'id' => $model->product_variant_id, + ]), [ + 'title' => \Yii::t('app', "Просмотр"), + ]); }, - 'update' => function ($url, $model) - { - return Html::a ( - '', - Url::to(['update','product_id'=> $model->product_id, 'id' => $model->product_variant_id]), - [ - 'title' => "Редактировать", - ] - ); + 'update' => function($url, $model) { + return Html::a('', Url::to([ + 'update', + 'product_id' => $model->product_id, + 'id' => $model->product_variant_id, + ]), [ + 'title' => \Yii::t('app', "Редактировать"), + ]); }, - 'delete' => function ($url, $model) - { - - return Html::a('', Url::to(['delete','product_id'=> $model->product_id, 'id' => $model->product_variant_id]), [ - 'title' => Yii::t('yii', 'Delete'), + 'delete' => function($url, $model) { + + return Html::a('', Url::to([ + 'delete', + 'product_id' => $model->product_id, + 'id' => $model->product_variant_id, + ]), [ + 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), - 'data-method' => 'post', + 'data-method' => 'post', ]); - + }, ], ], diff --git a/common/modules/product/views/variant/update.php b/common/modules/product/views/variant/update.php index aa0a70a..2abda8a 100755 --- a/common/modules/product/views/variant/update.php +++ b/common/modules/product/views/variant/update.php @@ -1,5 +1,6 @@ title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Product', - ]) . ' ' . $model->product_variant_id; + ]) . ' ' . $model->lang->name; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Products'), - 'url' => [ 'index' ], + 'url' => [ '/product/manage/index' ], ]; $this->params[ 'breadcrumbs' ][] = [ - 'label' => $model->product->product_id, + 'label' => $model->product->lang->name, 'url' => [ - 'view', + '/product/manage/view', 'id' => $model->product->product_id, ], ]; $this->params[ 'breadcrumbs' ][] = [ 'label' => Yii::t('product', 'Variants'), 'url' => Url::to([ - '/product/variant', + 'index', 'product_id' => $model->product->product_id, ]), ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('product', $model->lang->name), + 'url' => Url::to([ + 'view', + 'id' => $model->product_variant_id, + ]), + ]; $this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update'); ?>
@@ -47,6 +56,7 @@ 'model_langs' => $model_langs, 'groups' => $groups, 'stocks' => $stocks, + 'product' => $product, ]) ?>
diff --git a/common/modules/product/views/variant/view.php b/common/modules/product/views/variant/view.php index fc40bfb..175fcd1 100755 --- a/common/modules/product/views/variant/view.php +++ b/common/modules/product/views/variant/view.php @@ -1,38 +1,88 @@ title = $model->product_variant_id; -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->product->lang->name, 'url' => ['view', 'id' => $model->product->product_id]]; -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => ['/product/variant?product_id='. $model->product->product_id]]; -$this->params['breadcrumbs'][] = $this->title; + + use common\modules\product\models\ProductVariant; + use common\modules\rubrication\models\TaxGroup; + use yii\helpers\Html; + use yii\web\View; + use yii\widgets\DetailView; + + /** + * @var View $this + * @var ProductVariant $model + * @var TaxGroup[] $properties + */ + + $this->title = $model->lang->name; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('product', 'Products'), + 'url' => [ 'index' ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $model->product->lang->name, + 'url' => [ + 'view', + 'id' => $model->product->product_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => Yii::t('product', 'Variants'), + 'url' => [ '/product/variant?product_id=' . $model->product->product_id ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; + $properties_string = ''; + foreach($properties as $property) { + $options_string = ''; + foreach($property->options as $option) { + $options_string .= Html::tag('li', $option->lang->value); + } + $properties_string .= Html::tag('p', $property->lang->name).Html::tag('ul', $options_string); + } ?>
- +

title) ?>

- +

- $model->product_variant_id], ['class' => 'btn btn-primary']) ?> - $model->product_variant_id], [ + $model->product_variant_id, + ], [ 'class' => 'btn btn-primary' ]) ?> + $model->product_variant_id, + ], [ 'class' => 'btn btn-danger', - 'data' => [ + 'data' => [ 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), - 'method' => 'post', + 'method' => 'post', ], ]) ?>

- + $model, + 'model' => $model, 'attributes' => [ - 'product_id', - 'fullname', - 'image.imageUrl:image' + 'product_variant_id', + 'lang.name', + 'sku', + 'price', + 'price_old', + 'stock', + 'productUnit.lang.name', + [ + 'attribute' => 'product_id', + 'value' => Html::a($model->product->fullName, [ + '/product/manage/view', + 'id' => $model->product_id, + ]), + 'format' => 'html', + ], + 'image.imageUrl:image', + [ + 'label' => \Yii::t('app', 'Properties'), + 'value' => $properties_string, + 'format' => 'html', + ] ], ]) ?> -- libgit2 0.21.4