diff --git a/common/behaviors/DefaultVariantBehavior.php b/common/behaviors/DefaultVariantBehavior.php
index ce5be67..1f92c76 100755
--- a/common/behaviors/DefaultVariantBehavior.php
+++ b/common/behaviors/DefaultVariantBehavior.php
@@ -1,6 +1,7 @@
true,
])->one();
+
+
+ $image = ProductImage::find()->where([
+ 'product_id' => $this->owner->product_id
+ ])->one();
+
+// $image->product_variant_id = $defaultVariant->product_variant_id;
+// $image->save();
+
+
/**
* Add a new stock record
*/
diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php
index 30fc16e..9ed8bdd 100755
--- a/common/modules/product/models/Import.php
+++ b/common/modules/product/models/Import.php
@@ -199,11 +199,11 @@ class Import extends Model {
}
// 1 Группа (категория)
$catalog_names = explode(',',$data[0]);
- if (empty ($catalog_names))
- {
- $result_items[] = "Не указана категория (строка $j)";
- continue;
- }
+// if (empty ($catalog_names))
+// {
+// $result_items[] = "Не указана категория (строка $j)";
+// continue;
+// }
// 2 Размер (кастомное поле для Баккары)
$product_size = $data[1];
@@ -265,10 +265,16 @@ class Import extends Model {
$product_image = explode ('=', $data[14]);
$product_image = @$product_image[3];
- if ( ($_product = Product::find()->filterWhere(['ilike', 'name', trim($product_name)])->one()) === null ) {
+ if ( ($_product = Product::find()->where(['name' => trim($product_name)])->one()) === null ) {
$_product = new Product();
}
-
+
+ /**
+ * @todo somewhere here detach default product variant behavior if current importing product have varant
+ */
+ if(isset($data[13])) {
+ $_product->detachBehavior('defaultVariant');
+ }
$is_new_product = empty($_product->product_id);
$category_id = [];
@@ -308,8 +314,8 @@ class Import extends Model {
$_product->is_top = $product_top;
$_product->akciya = $product_akciya;
$_product->is_new = $product_new;
- $_product->size = $product_size;
- $_product->material = $product_material;
+// $_product->size = $product_size;
+// $_product->material = $product_material;
if (!$_product->save()) {
$result_items[] = 'Product #'. $_product->name .' not saved' . " (строка $j)";
@@ -321,7 +327,7 @@ class Import extends Model {
$source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($foto);
if (file_exists($source_image)) {
- if (($productImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $foto])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null) {
+ if (($productImage = ProductImage::find()->andWhere(['image' => $foto])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null) {
copy($source_image, Yii::getAlias('@productsDir') . "/" . $foto);
$productImage = new ProductImage();
$productImage->product_id = $_product->product_id;
@@ -348,7 +354,7 @@ class Import extends Model {
$mod_cost = isset($product_cost) ? floatval($product_cost) : 0;
$mod_old_cost = floatval($product_cost_old);
// Check product variant
- if ( ($_productVariant = ProductVariant::find()->andFilterWhere(['ilike', 'sku', $mod_art])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null ) {
+ if ( ($_productVariant = ProductVariant::find()->andWhere(['sku' => $mod_art])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null ) {
$_productVariant = new ProductVariant();
$_productVariant->product_id = $_product->product_id;
}
@@ -378,7 +384,7 @@ class Import extends Model {
if ($mod_image) {
$source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($mod_image);
if (file_exists($source_image)) {
- if (($variantImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) {
+ if (($variantImage = ProductImage::find()->andWhere(['image' => $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) {
copy($source_image, Yii::getAlias('@productsDir') . "/" . $mod_image);
$variantImage = new ProductImage();
$variantImage->product_id = $_product->product_id;
diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php
index ba732b6..f3344c3 100755
--- a/common/modules/product/models/Product.php
+++ b/common/modules/product/models/Product.php
@@ -70,9 +70,7 @@
[
'class' => FilterBehavior::className(),
],
- [
- 'class' => DefaultVariantBehavior::className(),
- ],
+ 'defaultVariant' => DefaultVariantBehavior::className(),
[
'class' => Slug::className(),
'in_attribute' => 'name',
@@ -196,7 +194,18 @@
public function getImageUrl()
{
$image = empty( $this->variant ) ? NULL : $this->variant->image;
- return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png';
+ if(!empty( $image )) {
+ return $image->imageUrl;
+ } else {
+ $image = $this->getImage()->andWhere([
+ 'product_variant_id' => NULL,
+ ])->one();
+ if(!empty($image)) {
+ return $image->imageUrl;
+ }
+ }
+ return null;
+// return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png';
}
/**
diff --git a/common/modules/product/views/manage/import-process.php b/common/modules/product/views/manage/import-process.php
index af24fce..ad343dc 100755
--- a/common/modules/product/views/manage/import-process.php
+++ b/common/modules/product/views/manage/import-process.php
@@ -2,14 +2,8 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
-
+ $method = Yii::$app->request->baseUrl .'/product/manage/'. $method;
$this->registerJs("
-
-");
-?>
-
-
+");
+?>
Импорт = $method == 'prices' ? 'цен' : 'данных'?> товаров
diff --git a/common/modules/product/views/manage/index.php b/common/modules/product/views/manage/index.php
index 8f3008e..a71284d 100755
--- a/common/modules/product/views/manage/index.php
+++ b/common/modules/product/views/manage/index.php
@@ -27,6 +27,58 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{items} {view} {akciya} {update} {delete}',
+ 'buttons' => [
+ // 'is_top' => function ($url, $model) {
+ // return Html::a(' ', $url, [
+ // 'title' => Yii::t('product', ($model->is_top ? 'Set not is top' : 'Set is top')),
+ // ]);
+ // },
+ // 'is_new' => function ($url, $model) {
+ // return Html::a(' ', $url, [
+ // 'title' => Yii::t('product', ($model->is_new ? 'Set not is new' : 'Set is new')),
+ // ]);
+ // },
+ 'akciya' => function ($url, $model) {
+ return Html::a(' ', $url, [
+ 'title' => Yii::t('product', ($model->akciya ? 'Отметить как не акционный' : 'Отметить как акционный')),
+ ]);
+ },
+ 'items' => function ($url, $model) {
+ return Html::a(' ', $url, [
+ 'title' => Yii::t('product', 'Variants'),
+ ]);
+ },
+
+ ],
+ 'urlCreator' => function ($action, $model, $key, $index) {
+ switch ($action) {
+ case 'items':
+ return \yii\helpers\Url::to(['/product/variant', 'product_id' => $model->product_id]);
+ break;
+ case 'is_top':
+ return \yii\helpers\Url::to(['manage/is_top', 'id' => $model->product_id]);
+ break;
+ case 'is_new':
+ return \yii\helpers\Url::to(['manage/is_new', 'id' => $model->product_id]);
+ break;
+ case 'akciya':
+ return \yii\helpers\Url::to(['manage/akciya', 'id' => $model->product_id]);
+ break;
+ case 'view':
+ return \yii\helpers\Url::to(['manage/view', 'id' => $model->product_id]);
+ break;
+ case 'update':
+ return \yii\helpers\Url::to(['manage/update', 'id' => $model->product_id]);
+ break;
+ case 'delete':
+ return \yii\helpers\Url::to(['manage/delete', 'id' => $model->product_id]);
+ break;
+ }
+ }
+ ],
'name',
// [
// 'label' => Yii::t('product', 'Brand'),
@@ -84,58 +136,6 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'variant_stock',
'value' => 'variant.stock_caption',
],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{items} {view} {akciya} {update} {delete}',
- 'buttons' => [
-// 'is_top' => function ($url, $model) {
-// return Html::a(' ', $url, [
-// 'title' => Yii::t('product', ($model->is_top ? 'Set not is top' : 'Set is top')),
-// ]);
-// },
-// 'is_new' => function ($url, $model) {
-// return Html::a(' ', $url, [
-// 'title' => Yii::t('product', ($model->is_new ? 'Set not is new' : 'Set is new')),
-// ]);
-// },
- 'akciya' => function ($url, $model) {
- return Html::a(' ', $url, [
- 'title' => Yii::t('product', ($model->akciya ? 'Отметить как не акционный' : 'Отметить как акционный')),
- ]);
- },
- 'items' => function ($url, $model) {
- return Html::a(' ', $url, [
- 'title' => Yii::t('product', 'Variants'),
- ]);
- },
-
- ],
- 'urlCreator' => function ($action, $model, $key, $index) {
- switch ($action) {
- case 'items':
- return \yii\helpers\Url::to(['/product/variant', 'product_id' => $model->product_id]);
- break;
- case 'is_top':
- return \yii\helpers\Url::to(['manage/is_top', 'id' => $model->product_id]);
- break;
- case 'is_new':
- return \yii\helpers\Url::to(['manage/is_new', 'id' => $model->product_id]);
- break;
- case 'akciya':
- return \yii\helpers\Url::to(['manage/akciya', 'id' => $model->product_id]);
- break;
- case 'view':
- return \yii\helpers\Url::to(['manage/view', 'id' => $model->product_id]);
- break;
- case 'update':
- return \yii\helpers\Url::to(['manage/update', 'id' => $model->product_id]);
- break;
- case 'delete':
- return \yii\helpers\Url::to(['manage/delete', 'id' => $model->product_id]);
- break;
- }
- }
- ],
],
]); ?>
diff --git a/frontend/controllers/CatalogController.php b/frontend/controllers/CatalogController.php
index 6da039e..2ee03f9 100755
--- a/frontend/controllers/CatalogController.php
+++ b/frontend/controllers/CatalogController.php
@@ -186,25 +186,30 @@ class CatalogController extends \yii\web\Controller
public function actionProduct($product, $variant)
{
-
$product = Product::find()
->joinWith([
'variants' => function($query) {
$query->indexBy('sku');
},
- 'options.group'
], true, 'INNER JOIN')
->where([
'product.alias' => $product,
'product_variant.sku' => $variant,
- ])->with('category.parent')->one();
+ ])->with([
+ 'category.parent',
+ 'options.group',
+ ])->one();
$attributes = [];
- foreach($product->options as $option) {
- if(!$option->group->is_menu) continue;
- $attributes[$option->group->name][] = $option->value;
+ if(!empty($product->options)) {
+ foreach($product->options as $option) {
+ if(!$option->group->is_menu) {
+ continue;
+ }
+ $attributes[ $option->group->name ][] = $option->value;
+ }
}
-
+
$variant = $product->variants[$variant];
$variants = $product->variants;
return $this->render('view', [
diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php
index ec71adb..4e017ad 100755
--- a/frontend/views/catalog/products.php
+++ b/frontend/views/catalog/products.php
@@ -20,7 +20,9 @@ $this->params['breadcrumbs'][] = $this->title;
?>
-
+
Стильные элитные обои для вашего дома.
-
Продумывая дизайн своей квартиры, мы непременно тщательно выбираем «одежду» для стен — красивые модные обои.
-
+
+
Продумывая дизайн своей квартиры, мы непременно тщательно выбираем «одежду» для стен — красивые модные обои.
+
+
diff --git a/frontend/views/catalog/view.php b/frontend/views/catalog/view.php
index b33a74c..c407321 100755
--- a/frontend/views/catalog/view.php
+++ b/frontend/views/catalog/view.php
@@ -59,9 +59,13 @@ $this->params['breadcrumbs'][] = $this->title;
Артикул: sku; ?>
- $options) { ?>
+ $options) { ?>
:
-
+
diff --git a/frontend/views/category/brand.php b/frontend/views/category/brand.php
index e305880..3dc86a7 100755
--- a/frontend/views/category/brand.php
+++ b/frontend/views/category/brand.php
@@ -35,7 +35,11 @@ $this->params[ 'breadcrumbs' ][] = $this->title;
h1; ?>
-
seo_text; ?>
-
+
+
\ No newline at end of file
diff --git a/frontend/views/category/collection.php b/frontend/views/category/collection.php
index fea051d..732c2c4 100755
--- a/frontend/views/category/collection.php
+++ b/frontend/views/category/collection.php
@@ -64,9 +64,12 @@ $this->params['breadcrumbs'][] = $this->title;
diff --git a/frontend/views/category/index.php b/frontend/views/category/index.php
index cbec089..4608896 100755
--- a/frontend/views/category/index.php
+++ b/frontend/views/category/index.php
@@ -24,6 +24,10 @@ echo ListView::widget([
h1; ?>
-
seo_text; ?>
-
+
+
diff --git a/frontend/views/discount/discount.php b/frontend/views/discount/discount.php
index 852a6d1..4c9acc0 100755
--- a/frontend/views/discount/discount.php
+++ b/frontend/views/discount/discount.php
@@ -27,7 +27,7 @@ $this->params['breadcrumbs'][] = $this->title;
])?>">
getImageUrl(), 'category_thumb'); ?>
-
variant->price; ?> €
+
variant->price; ?> €
name; ?>
category->name; ?>
@@ -41,9 +41,10 @@ $this->params['breadcrumbs'][] = $this->title;
Стильные элитные обои для вашего дома
-
Продумывая дизайн своей квартиры, мы непременно тщательно выбираем "одежду" для стен - красивые модные обои.
-
fdsfsdf
-
+
+
Продумывая дизайн своей квартиры, мы непременно тщательно выбираем "одежду" для стен - красивые модные обои.
+
+
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index 9e7b78f..217fd41 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -1,154 +1,184 @@
where([
- 'in_top_menu' => true,
-])->orderBy([
- 'sort_order' => SORT_ASC,
-])->all();
-
-$main_menu = Page::find()->where([
- 'in_menu' => true,
-])->orderBy([
- 'sort_order' => SORT_ASC,
-])->all();
-
-$this->registerMetaTag([
- 'name' => 'robots',
- 'content' => 'noindex,nofollow',
-]);
-
-AppAsset::register($this);
-
-$brands = Category::find()
- ->where([
- 'parent_id' => 0,
- ])->all();
+ /**
+ * @var Category[] $brands_menu
+ * @var \yii\web\View $this
+ * @var string $content
+ * @var Page[] $top_menu
+ * @var Page[] $main_menu
+ */
+
+ use common\models\Page;
+ use common\modules\product\models\Category;
+ use frontend\assets\AppAsset;
+ use yii\helpers\Html;
+ use yii\helpers\Url;
+ use yii\widgets\Breadcrumbs;
+
+ $top_menu = Page::find()
+ ->where([
+ 'in_top_menu' => true,
+ ])
+ ->orderBy([
+ 'sort_order' => SORT_ASC,
+ ])
+ ->all();
+
+ $main_menu = Page::find()
+ ->where([
+ 'in_menu' => true,
+ ])
+ ->orderBy([
+ 'sort_order' => SORT_ASC,
+ ])
+ ->all();
+
+ $this->registerMetaTag([
+ 'name' => 'robots',
+ 'content' => 'noindex,nofollow',
+ ]);
+
+ AppAsset::register($this);
+
+ $brands = Category::find()
+ ->where([
+ 'parent_id' => 0,
+ ])
+ ->all();
?>
beginPage(); ?>
-
-
-
-
-
-
- = Html::csrfMetaTags(); ?>
-
= Html::encode($this->title); ?>
- head(); ?>
-
-
-beginBody(); ?>
-
-
-
-
-
-
-
- 'div',
- 'options' => [
- 'class' => 'nav_up',
- ],
- 'itemTemplate' => '{link} - ',
- 'activeItemTemplate' => '{link} ',
- 'links' => isset( $this->params[ 'breadcrumbs' ] ) ? $this->params[ 'breadcrumbs' ] : [],
- ]);
- ?>
-
-= $content ?>
-
-
-
-
-
-
© 2006 - 2015 Шоу-рум “BACCARA HOME”
+
+