Commit e136edc84f5d5a467eb006c888745462a6db4c86

Authored by Karnovsky A
1 parent e201a91e

---

common/components/artboxtree/ArtboxTreeQueryTrait.php
... ... @@ -31,7 +31,11 @@ trait ArtboxTreeQueryTrait {
31 31 if ($with) {
32 32 $this->with($with);
33 33 }
34   - $data = $this->all();
  34 + $this->orderBy([$model->keyNameDepth => SORT_ASC]);
  35 + $data = [];
  36 + foreach($this->all() as $item) {
  37 + $data[$item->{$model->keyNameId}] = $item;
  38 + }
35 39 if (empty($data))
36 40 return [];
37 41  
... ... @@ -61,7 +65,7 @@ trait ArtboxTreeQueryTrait {
61 65 $this->_recursiveRebuild($tree);
62 66 }
63 67  
64   - protected function buildTree(array $data, $parentId = 0) {
  68 + /*protected function buildTree(array $data, $parentId = 0) {
65 69 $model = $this->getModel();
66 70  
67 71 $result = [];
... ... @@ -75,6 +79,28 @@ trait ArtboxTreeQueryTrait {
75 79 }
76 80 }
77 81 return $result;
  82 + }*/
  83 +
  84 + protected function buildTree(array $data, $parentId = 0) {
  85 + $model = $this->getModel();
  86 +
  87 + $result = [];
  88 + foreach ($data as $element) {
  89 +
  90 + if ($element->{$model->keyNameDepth} == 0) {
  91 + $result[$element->{$model->keyNameId}]['item'] = $element;
  92 + $result[$element->{$model->keyNameId}]['children'] = [];
  93 + continue;
  94 + }
  95 + $parents = explode(",", trim($element->{$model->keyNamePath}, '{}'));
  96 + $node = &$result[$parents[0]];
  97 + for($i=1;$i<$element->{$model->keyNameDepth};$i++) {
  98 + $node = &$node['children'][$parents[$i]];
  99 + }
  100 +
  101 + $node['children'][$element->{$model->keyNameId}]['item'] = $element;
  102 + }
  103 + return $result;
78 104 }
79 105  
80 106 public function normalizeTreeData(array $data, $parentId = null)
... ...
common/config/bootstrap.php
... ... @@ -5,3 +5,6 @@ Yii::setAlias(&#39;@backend&#39;, dirname(dirname(__DIR__)) . &#39;/backend&#39;);
5 5 Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
6 6 Yii::setAlias('@storage', dirname(dirname(__DIR__)) . '/storage');
7 7 Yii::setAlias('storage', dirname(dirname(__DIR__)) . '/storage');
  8 +Yii::setAlias('@imagesDir', dirname(dirname(__DIR__)) . '/frontend/web/images');
  9 +Yii::setAlias('@imagesUrl', '/images');
  10 +
... ...
common/modules/product/controllers/ManageController.php
... ... @@ -164,9 +164,9 @@ class ManageController extends Controller
164 164 $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload');
165 165  
166 166 if ($model->save()) {
167   - foreach ($model->images as $image) {
168   - $image->delete();
169   - }
  167 +// foreach ($model->images as $image) {
  168 +// $image->delete();
  169 +// }
170 170  
171 171 if ( ($images = $model->imagesUpload()) !== FALSE) {
172 172 foreach ($images as $image) {
... ... @@ -214,6 +214,26 @@ class ManageController extends Controller
214 214 exit;
215 215 }
216 216  
  217 + public function actionIs_top($id) {
  218 + $model = $this->findModel($id);
  219 +
  220 + $model->is_top = intval(empty($model->is_top));
  221 +
  222 + $model->save(false, ['is_top']);
  223 +
  224 + return $this->redirect(['index']);
  225 + }
  226 +
  227 + public function actionIs_new($id) {
  228 + $model = $this->findModel($id);
  229 +
  230 + $model->is_new = intval(empty($model->is_new));
  231 +
  232 + $model->save(false, ['is_new']);
  233 +
  234 + return $this->redirect(['index']);
  235 + }
  236 +
217 237 public function actionImport() {
218 238 $searchModel = new RemoteProductsSearch();
219 239 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
... ...
common/modules/product/helpers/ProductHelper.php
... ... @@ -5,6 +5,7 @@ namespace common\modules\product\helpers;
5 5 use common\modules\product\models\Brand;
6 6 use common\modules\product\models\Category;
7 7 use common\modules\product\models\Product;
  8 +use common\modules\product\models\ProductVariant;
8 9 use yii\base\Object;
9 10 use Yii;
10 11  
... ... @@ -73,4 +74,15 @@ class ProductHelper extends Object {
73 74 }
74 75 return $last_products;
75 76 }
  77 +
  78 + public static function getSpecialProducts($type, $count, $sort = null) {
  79 + $data = [$type => true];
  80 + return Product::find()
  81 +// ->joinWith('variants')
  82 + ->where($data)
  83 +// ->andWhere(['!=', ProductVariant::tableName() .'.stock', 0])
  84 + ->limit($count)
  85 + /*->orderBy($sort)*/
  86 + ->all();
  87 + }
76 88 }
77 89 \ No newline at end of file
... ...
common/modules/product/models/Product.php
... ... @@ -203,26 +203,28 @@ class Product extends \yii\db\ActiveRecord
203 203 //
204 204 // }
205 205  
206   - $todel = [];
207   - foreach ($this->variants ? : [] as $_variant) {
208   - $todel[$_variant->product_variant_id] = $_variant->product_variant_id;
209   - }
210   - foreach ($this->_variants as $_variant) {
211   - if (!is_array($_variant)) {
212   - return;
  206 + if (!empty($this->_variants)) {
  207 + $todel = [];
  208 + foreach ($this->variants ?: [] as $_variant) {
  209 + $todel[$_variant->product_variant_id] = $_variant->product_variant_id;
213 210 }
214   - if (!empty($_variant['product_variant_id'])) {
215   - unset($todel[$_variant['product_variant_id']]);
216   - $model = ProductVariant::findOne($_variant['product_variant_id']);
217   - } else {
218   - $model = new ProductVariant();
  211 + foreach ($this->_variants as $_variant) {
  212 + if (!is_array($_variant)) {
  213 + return;
  214 + }
  215 + if (!empty($_variant['product_variant_id'])) {
  216 + unset($todel[$_variant['product_variant_id']]);
  217 + $model = ProductVariant::findOne($_variant['product_variant_id']);
  218 + } else {
  219 + $model = new ProductVariant();
  220 + }
  221 + $_variant['product_id'] = $this->product_id;
  222 + $model->load(['ProductVariant' => $_variant]);
  223 + $model->save();
  224 + }
  225 + if (!empty($todel)) {
  226 + ProductVariant::deleteAll(['product_variant_id' => $todel]);
219 227 }
220   - $_variant['product_id'] = $this->product_id;
221   - $model->load(['ProductVariant' => $_variant]);
222   - $model->save();
223   - }
224   - if (!empty($todel)) {
225   - ProductVariant::deleteAll(['product_variant_id' => $todel]);
226 228 }
227 229 }
228 230  
... ... @@ -254,6 +256,12 @@ class Product extends \yii\db\ActiveRecord
254 256 }
255 257 }
256 258  
  259 + public function getImageUrl()
  260 + {
  261 + $image = empty($this->variant) ? null : $this->variant->image;
  262 + return !empty($image) ? $image->imageUrl : '/images/no_photo.png';
  263 + }
  264 +
257 265 public function getImagesHTML() {
258 266 $op = [];
259 267 if ($this->images) {
... ...
common/modules/product/models/ProductImage.php
... ... @@ -110,7 +110,6 @@ class ProductImage extends \yii\db\ActiveRecord
110 110 return isset($this->image) ? '/images/products/'. $this->image : '/images/no_photo.png';
111 111 }
112 112  
113   -
114 113 /**
115 114 * Process upload of image
116 115 *
... ...
common/modules/product/models/ProductSearch.php
... ... @@ -48,41 +48,54 @@ class ProductSearch extends Product
48 48 {
49 49 $query = Product::find();
50 50  
51   - // add conditions that should always apply here
  51 + $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames', 'variant']);
  52 +
  53 + $query->groupBy(['product.product_id']);
  54 + $query->orderBy('product.product_id', 'DESC');
52 55  
53 56 $dataProvider = new ActiveDataProvider([
54 57 'query' => $query,
55 58 ]);
56 59  
57   - $this->load($params);
58   -
59   - if (!$this->validate()) {
60   - // uncomment the following line if you do not want to return any records when validation fails
61   - // $query->where('0=1');
  60 + if ( !($this->load($params) && $this->validate()) ) {
62 61 return $dataProvider;
63 62 }
64 63  
65 64 $dataProvider->setSort([
66 65 'attributes' => [
67 66 'name',
68   - 'brand_name',
69   - 'category_name'
  67 + 'brand_name' => [
  68 + 'asc' => ['brand_name.value' => SORT_ASC],
  69 + 'desc' => ['brand_name.value' => SORT_DESC],
  70 + 'default' => SORT_DESC,
  71 + 'label' => 'Brand name',
  72 + ],
  73 + 'category_name',
  74 + 'variant_sku',
70 75 ]
71 76 ]);
72 77  
73   - $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames']);
  78 + if (isset($this->is_top)) {
  79 + $query->andFilterWhere([
  80 + 'is_top' => (bool)$this->is_top,
  81 + ]);
  82 + }
  83 + if (isset($this->is_new)) {
  84 + $query->andFilterWhere([
  85 + 'is_new' => (bool)$this->is_new,
  86 + ]);
  87 + }
74 88  
75   - // grid filtering conditions
76 89 $query->andFilterWhere([
77   - 'tax_brand_id' => $this->tax_brand_id,
78   - 'product_id' => $this->product_id,
79   - 'is_top' => (bool)$this->is_top,
80   - 'is_new' => (bool)$this->is_new,
  90 + 'product.brand_id' => $this->brand_id,
  91 + 'product.product_id' => $this->product_id,
  92 + 'product_category.category_id' => $this->category_id
81 93 ]);
82 94  
83   - $query->andFilterWhere(['ilike', 'name', $this->name]);
  95 + $query->andFilterWhere(['ilike', 'product.name', $this->name]);
84 96 $query->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]);
85 97 $query->andFilterWhere(['ilike', 'category_name.value', $this->category_name]);
  98 + $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]);
86 99  
87 100 return $dataProvider;
88 101 }
... ...
common/modules/product/models/ProductVariant.php
... ... @@ -87,6 +87,20 @@ class ProductVariant extends \yii\db\ActiveRecord
87 87 }
88 88  
89 89 /**
  90 + * @return \yii\db\ActiveQuery
  91 + */
  92 + public function getImage()
  93 + {
  94 + return $this->hasOne(ProductImage::className(), ['product_variant_id' => 'product_variant_id']);
  95 + }
  96 +
  97 + public function getImageUrl()
  98 + {
  99 + // return a default image placeholder if your source image is not found
  100 + return !empty($this->image) ? $this->image->imageUrl : '/images/no_photo.png';
  101 + }
  102 +
  103 + /**
90 104 * @inheritdoc
91 105 * @return ProductVariantQuery the active query used by this AR class.
92 106 */
... ...
common/modules/product/views/manage/index.php
... ... @@ -2,6 +2,11 @@
2 2  
3 3 use yii\helpers\Html;
4 4 use yii\grid\GridView;
  5 +use kartik\select2\Select2;
  6 +use yii\helpers\ArrayHelper;
  7 +use common\modules\product\helpers\ProductHelper;
  8 +use common\components\artboxtree\ArtboxTreeHelper;
  9 +
5 10 /* @var $this yii\web\View */
6 11 /* @var $searchModel common\modules\product\models\ProductSearch */
7 12 /* @var $dataProvider yii\data\ActiveDataProvider */
... ... @@ -22,25 +27,66 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
22 27 'filterModel' => $searchModel,
23 28 'columns' => [
24 29 ['class' => 'yii\grid\SerialColumn'],
25   -// 'product_id',
26 30 'name',
27 31 [
28 32 'label' => Yii::t('product', 'Brand'),
29 33 'attribute' => 'brand_name',
30 34 'value' => 'brand.name',
  35 + 'format' => 'raw',
  36 + 'filter' => Select2::widget([
  37 + 'model' => $searchModel,
  38 + 'attribute' => 'brand_id',
  39 + 'data' => ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),
  40 + 'language' => 'ru',
  41 + 'options' => [
  42 + 'placeholder' => Yii::t('product', 'Select brand'),
  43 + 'multiple' => false,
  44 + ],
  45 + 'pluginOptions' => [
  46 + 'allowClear' => true
  47 + ],
  48 + ])
31 49 ],
32 50 [
33 51 'label' => Yii::t('product', 'Category'),
34 52 'attribute' => 'category_name',
35   - 'value' => 'category.name',
  53 + 'value' => function($model) {
  54 + $categories = [];
  55 + foreach ($model->categories as $category) {
  56 + $categories[] = $category->name;
  57 + }
  58 + return implode(", ", $categories);
  59 + },
  60 + 'format' => 'raw',
  61 + 'filter' => Select2::widget([
  62 + 'model' => $searchModel,
  63 + 'attribute' => 'category_id',
  64 + 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),
  65 + 'language' => 'ru',
  66 + 'options' => [
  67 + 'placeholder' => Yii::t('product', 'Select category'),
  68 + 'multiple' => false,
  69 + ],
  70 + 'pluginOptions' => [
  71 + 'allowClear' => true
  72 + ],
  73 + ])
  74 + ],
  75 + [
  76 + 'label' => Yii::t('product', 'SKU'),
  77 + 'attribute' => 'variant_sku',
  78 + 'value' => 'variant.sku',
36 79 ],
37 80 'variant.price',
38   - 'variant.stock_caption',
39   -
40   -
  81 + 'variant.price_old',
  82 + [
  83 + 'label' => Yii::t('product', 'Stock'),
  84 + 'attribute' => 'variant_stock',
  85 + 'value' => 'variant.stock_caption',
  86 + ],
41 87 [
42 88 'class' => 'yii\grid\ActionColumn',
43   - 'template' => '{view} {is_top} {is_new} {update} {delete}',
  89 + 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}',
44 90 'buttons' => [
45 91 'is_top' => function ($url, $model) {
46 92 return Html::a('<span class="glyphicon glyphicon-star' . ($model->is_top ? '' : '-empty') . '"></span>', $url, [
... ... @@ -52,15 +98,32 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
52 98 'title' => Yii::t('product', ($model->is_new ? 'Set not is new' : 'Set is new')),
53 99 ]);
54 100 },
  101 + 'akciya' => function ($url, $model) {
  102 + return Html::a('<span class="glyphicon glyphicon-tag' . ($model->akciya ? 's' : '') . '"></span>', $url, [
  103 + 'title' => Yii::t('product', ($model->akciya ? 'Set not is promotion' : 'Set is promotion')),
  104 + ]);
  105 + },
  106 + 'items' => function ($url, $model) {
  107 + return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [
  108 + 'title' => Yii::t('product', 'Variants'),
  109 + ]);
  110 + },
  111 +
55 112 ],
56 113 'urlCreator' => function ($action, $model, $key, $index) {
57 114 switch ($action) {
  115 + case 'items':
  116 + return \yii\helpers\Url::to(['/product/variant', 'product_id' => $model->product_id]);
  117 + break;
58 118 case 'is_top':
59 119 return \yii\helpers\Url::to(['manage/is_top', 'id' => $model->product_id]);
60 120 break;
61 121 case 'is_new':
62 122 return \yii\helpers\Url::to(['manage/is_new', 'id' => $model->product_id]);
63 123 break;
  124 + case 'akciya':
  125 + return \yii\helpers\Url::to(['manage/akciya', 'id' => $model->product_id]);
  126 + break;
64 127 case 'view':
65 128 return \yii\helpers\Url::to(['/catalog/product', 'id' => $model->product_id, ['target' => '_blank']]);
66 129 break;
... ...
common/modules/product/widgets/specialProducts.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +namespace common\modules\product\widgets;
  4 +
  5 +use common\modules\product\helpers\ProductHelper;
  6 +use common\modules\product\models\Category;
  7 +use common\modules\product\models\Product;
  8 +use common\modules\product\models\ProductVariant;
  9 +use yii\base\Widget;
  10 +use Yii;
  11 +
  12 +class specialProducts extends Widget {
  13 + public $type = 'is_new';
  14 +
  15 + public $count = 4;
  16 +
  17 + public $sort = 'default';
  18 +
  19 + public $title;
  20 +
  21 + public $classs;
  22 +
  23 + public function init()
  24 + {
  25 + parent::init(); // TODO: Change the autogenerated stub
  26 + }
  27 +
  28 + public function run() {
  29 + $products = ProductHelper::getSpecialProducts($this->type, $this->count, $this->sort);
  30 +
  31 + if (!$this->title) {
  32 + switch($this->type) {
  33 + case 'is_top':
  34 + $this->title = Yii::t('product', 'Top products');
  35 + break;
  36 + case 'is_new':
  37 + $this->title = Yii::t('product', 'New products');
  38 + break;
  39 + }
  40 + }
  41 +
  42 + return $this->render('products_block', [
  43 + 'title' => $this->title,
  44 + 'class' => $this->classs ? $this->classs : $this->type,
  45 + 'products' => $products,
  46 + ]);
  47 + }
  48 +}
0 49 \ No newline at end of file
... ...
common/modules/product/widgets/views/product_smart.php 0 โ†’ 100644
  1 +<?php
  2 +/** @var \common\modules\product\models\Product $product */
  3 +use yii\helpers\Url;
  4 +?>
  5 +<div class="item">
  6 + <div class="boxitem">
  7 + <div class="pixbox">
  8 + <a href="<?= Url::to([
  9 + 'catalog/product',
  10 + 'product' => $product,
  11 + '#' => 'm' .$product->enabledVariants[0]->product_variant_id])
  12 + ?>">
  13 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'list')?>
  14 + </a>
  15 + </div>
  16 + <?php if(!empty($product->is_top) || !empty($product->is_new) || !empty($product->akciya)) :?>
  17 + <ul class="product-special">
  18 + <?php if(!empty($product->is_top)) :?>
  19 + <li class="top"><div>top</div></li>
  20 + <?php endif?>
  21 + <?php if(!empty($product->is_new)) :?>
  22 + <li class="new"><div>new</div></li>
  23 + <?php endif?>
  24 + <?php if(!empty($product->akciya)) :?>
  25 + <li class="promo"><div>promo</div></li>
  26 + <?php endif?>
  27 + </ul>
  28 + <?php endif?>
  29 + <a href="<?= Url::to([
  30 + 'catalog/product',
  31 + 'product' => $product])
  32 + ?>" class="name"><?= $product->name ?>
  33 + </a>
  34 +
  35 + <div class="cost-block">
  36 + <p class="cost">
  37 + <?php if ($product->enabledVariants[0]->price_old != 0 && $product->enabledVariants[0]->price_old != $product->enabledVariants[0]->price) :?>
  38 + <strike><span id="old_cost"><?= $product->enabledVariants[0]->price_old ?></span> ะณั€ะฝ.</strike>&nbsp;
  39 + <?php endif?>
  40 + <?= $product->enabledVariants[0]->price?> <span>ะณั€ะฝ.</span></p>
  41 + </div>
  42 + </div>
  43 +
  44 + <a href="<?= Url::to([
  45 + 'catalog/product',
  46 + 'product' => $product,
  47 + '#' => 'm' .$product->enabledVariants[0]->product_variant_id])
  48 + ?>" class="link_buy">ะšัƒะฟะธั‚ัŒ</a>
  49 +
  50 + <div class="mycarousel">
  51 + <ul class="jcarousel jcarousel-skin-tango">
  52 + <?php foreach ($product->enabledVariants as $variant) : ?>
  53 + <li>
  54 + <a href="<?= Url::to([
  55 + 'catalog/product',
  56 + 'product' => $product,
  57 + '#' => 'm' . $variant->product_variant_id]) ?>">
  58 + <?= \common\components\artboximage\ArtboxImageHelper::getImage((!empty($variant->image) && !empty($variant->image->imageUrl) ? $variant->image->imageUrl : '/images/no_photo.png'), 'product_variant')?>
  59 + </a>
  60 + </li>
  61 + <?php endforeach; ?>
  62 + </ul>
  63 + </div>
  64 +</div>
0 65 \ No newline at end of file
... ...
common/modules/product/widgets/views/products_block.php 0 โ†’ 100644
  1 +<?php
  2 +use yii\web\View;
  3 +?>
  4 +<?php if(!empty($products)) :?>
  5 +<div class="<?= $class?>">
  6 + <div class="content">
  7 + <div class="title"><?= $title?></div>
  8 + <div class="<?= $class?>_cont">
  9 + <?php /** @var \common\modules\product\models\Product $product */?>
  10 + <?php foreach($products as $product) :?>
  11 + <div class="item" data-id="<?= $product->product_id?>">
  12 + <?php if ($product->is_new) :?>
  13 + <div class="new">ะะพะฒะธะฝะบะฐ</div>
  14 + <?php endif?>
  15 + <?php if ($product->is_top) :?>
  16 + <div class="top">Toะฟ</div>
  17 + <?php endif?>
  18 + <a href="#" class="item_link">
  19 + <div class="pic">
  20 + <?php if (empty($product->image)) :?>
  21 + <img src="/images/no_photo.png">
  22 + <?php else :?>
  23 + <?= ArtboxImageHelper::getImage($product->image->imageUrl, 'product_list')?>
  24 + <?php endif?>
  25 + </div>
  26 + <div class="title_item"><?= $product->name?></div>
  27 + </a>
  28 + <?php if ($product->brand) :?>
  29 + <div class="brand">ะ‘ั€ะตะฝะด: <span><?= $product->brand->name?></span></div>
  30 + <?php endif?>
  31 + <div class="type"><?= implode(', ', $product->categoriesNames)?></div>
  32 + <div class="price"><?= $product->variant ? $product->variant->price : 0?> <span>ะณั€ะฝ.</span></div>
  33 + <button class="basket_add_but">ะฒ ะบะพั€ะทะธะฝัƒ</button>
  34 + <a href="#" class="compare_add_but"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
  35 + </div>
  36 + <?php endforeach?>
  37 + <div style="clear:both;"></div>
  38 + </div>
  39 + </div>
  40 +</div>
  41 +<?php endif?>
0 42 \ No newline at end of file
... ...
composer.json
... ... @@ -41,7 +41,9 @@
41 41 "kartik-v/yii2-widget-fileinput": "@dev",
42 42 "maxmirazh33/yii2-uploadable-cropable-image": "*",
43 43 "iutbay/yii2-imagecache": "*",
44   - "yurkinx/yii2-image": "dev-master"
  44 + "yurkinx/yii2-image": "dev-master",
  45 + "mongosoft/yii2-upload-behavior": "*",
  46 + "cics/yii2-video-embed-widget": "dev-master"
45 47 },
46 48 "require-dev": {
47 49 "yiisoft/yii2-codeception": "*",
... ...
console/controllers/ImportController.php
... ... @@ -2,8 +2,8 @@
2 2  
3 3 namespace console\controllers;
4 4  
5   -use common\modules\product\models\Brand;
6   -use common\modules\product\models\BrandName;
  5 +//use common\modules\product\models\Brand;
  6 +//use common\modules\product\models\BrandName;
7 7 use common\modules\product\models\Product;
8 8 use common\modules\product\models\ProductVariant;
9 9 use common\modules\product\models\RemoteProducts;
... ... @@ -27,7 +27,7 @@ class ImportController extends Controller {
27 27 public function goClear() {
28 28 foreach(Product::find()->all() as $product) {
29 29 if (empty($product->variant)) {
30   - if (!$product->delete()) {
  30 + if (FALSE && !$product->delete()) {
31 31 $this->stdout("#$product->product_id '$product->name'\n");
32 32 exit;
33 33 } else {
... ... @@ -40,7 +40,7 @@ class ImportController extends Controller {
40 40 public function goGo() {
41 41 $new_products = $linked_products = 0;
42 42 foreach(RemoteProducts::find()->all() as $product) {
43   - $product->Brand = trim($product->Brand);
  43 +// $product->Brand = trim($product->Brand);
44 44 if (empty($product->remoteCategory) || empty($product->remoteCategory->category)) {
45 45 continue;
46 46 }
... ... @@ -52,16 +52,16 @@ class ImportController extends Controller {
52 52  
53 53 $_product = Product::findOne($product->product->product_id);
54 54  
55   - $brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one();
  55 +// $brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one();
56 56  
57 57 if (
58 58 $_product->name != $product->Name ||
59   - $_product->categories[0]->category_id != $product->remoteCategory->category->category_id ||
60   - ($product->Brand && $brand !== null && $_product->brand_id != $brand->brand_id)
  59 + $_product->categories[0]->category_id != $product->remoteCategory->category->category_id
  60 + /*|| ($product->Brand && $brand !== null && $_product->brand_id != $brand->brand_id)*/
61 61 ) {
62 62 $_product->name = $product->Name;
63 63 $_product->categories = [$product->remoteCategory->category->category_id];
64   - if ( $product->Brand ) {
  64 + /*if ( $product->Brand ) {
65 65 if ( $brand !== null ) {
66 66 $_product->brand_id = $brand->brand_id;
67 67 } else {
... ... @@ -72,21 +72,27 @@ class ImportController extends Controller {
72 72 $brand->save();
73 73 $_product->brand_id = $brand->brand_id;
74 74 }
75   - }
  75 + }*/
76 76 $_product->save();
77 77 }
78 78  
  79 + $price = floatval($product->Price);
  80 + $price_old = floatval($product->Price_old);
  81 + $stock = (bool)$product->In_stock ? NULL : 0;
  82 +
79 83 if (
80   - $_productVariant->price != floatval($product->Price) ||
81   - $_productVariant->price_old != floatval($product->Price_old) ||
82   - (!empty($product->Article) && $_productVariant->sku != $product->Article)
  84 + $_productVariant->price != $price ||
  85 + $_productVariant->price_old != $price_old ||
  86 + (!empty($product->Article) && $_productVariant->sku != $product->Article) ||
  87 + $_productVariant->stock !== $stock
83 88 ) {
84 89 $_productVariant->price = floatval($product->Price);
85 90 $_productVariant->price_old = floatval($product->Price_old);
86 91 $_productVariant->sku = empty($product->Article) ? uniqid('gds_') : $product->Article;
87   - if (!$_productVariant->price) {
88   - $_productVariant->stock = 0;
89   - }
  92 + $_productVariant->stock = $stock;
  93 +// if (!$_productVariant->price) {
  94 +// $_productVariant->stock = 0;
  95 +// }
90 96 $_productVariant->save();
91 97 }
92 98 }
... ... @@ -98,7 +104,7 @@ class ImportController extends Controller {
98 104 $_product->name = $product->Name;
99 105 $_product->categories = [$product->remoteCategory->category->category_id];
100 106  
101   - if ( $product->Brand ) {
  107 + /*if ( $product->Brand ) {
102 108 if ( ($brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one()) !== null ) {
103 109 $_product->brand_id = $brand->brand_id;
104 110 } else {
... ... @@ -108,7 +114,7 @@ class ImportController extends Controller {
108 114 $brand->save();
109 115 $_product->brand_id = $brand->brand_id;
110 116 }
111   - }
  117 + }*/
112 118 $_productVariant->price = floatval($product->Price);
113 119 $_productVariant->price_old = floatval($product->Price_old);
114 120 $_productVariant->sku = empty($product->Article) ? uniqid('gds_') : $product->Article;
... ... @@ -125,7 +131,7 @@ class ImportController extends Controller {
125 131  
126 132 }
127 133 }
128   - $product->delete();
  134 +// $product->delete();
129 135 }
130 136  
131 137 // $this->goStat();
... ...
frontend/views/catalog/product.php
... ... @@ -29,8 +29,8 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $product-&gt;name .&#39; #&#39;. $product-&gt;variant-&gt;sku;
29 29 <?= ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb')?>
30 30 </a>
31 31 <?php endforeach?>
32   - </div>
33 32 <?php endif?>
  33 + </div>
34 34 <div class="product_service">
35 35 <ul>
36 36 <li class="item1"><a id="add_to_bookmarks" href="#">ะ”ะพะฑะฐะฒะธั‚ัŒ ะฒ ะทะฐะบะปะฐะดะบะธ</a>
... ...
frontend/views/catalog/product_item.php
... ... @@ -7,20 +7,20 @@ use common\components\artboximage\ArtboxImageHelper;
7 7 <div class="top">Toะฟ</div>-->
8 8 <a href="<?= \yii\helpers\Url::to(['catalog/product', 'product' => $product])?>" class="item_link">
9 9 <div class="pic">
10   - <?php if (empty($product->image)) :?>
11   - <img src="/images/no_photo.png">
12   - <?php else :?>
13   - <?= ArtboxImageHelper::getImage($product->image->imageUrl, 'product_list')?>
14   - <?php endif?>
  10 + <?php if (empty($product->image)) :?>
  11 + <img src="/images/no_photo.png">
  12 + <?php else :?>
  13 + <?= ArtboxImageHelper::getImage($product->image->imageUrl, 'product_list')?>
  14 + <?php endif?>
15 15 </div>
16 16 <div class="title_item"><?= $product->name?></div></a>
17 17 <?php if (!empty($product->brand)) :?>
18   - <div class="brand">ะ‘ั€ะตะฝะด: <span><?= $product->brand->name?></span></div>
  18 + <div class="brand">ะ‘ั€ะตะฝะด: <span><?= $product->brand->name?></span></div>
19 19 <?php endif?>
20 20 <div class="type"><?= implode(', ', $product->categoriesNames)?></div>
21 21 <?php if($product->variant) :?>
22   - <div class="price"><?= $product->variant->price?> <span>ะณั€ะฝ.</span></div>
23   - <button class="basket_add_but" data-id="<?= $product->variant->product_variant_id?>">ะฒ ะบะพั€ะทะธะฝัƒ</button>
  22 + <div class="price"><?= $product->variant->price?> <span>ะณั€ะฝ.</span></div>
  23 + <button class="basket_add_but" data-id="<?= $product->variant->product_variant_id?>">ะฒ ะบะพั€ะทะธะฝัƒ</button>
24 24 <?php endif?>
25 25 <a href="#" class="compare_add_but" data-id="<?= $product->product_id?>"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
26 26 <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt="">
... ...
frontend/views/catalog/product_smart.php
... ... @@ -15,7 +15,7 @@ use common\components\artboximage\ArtboxImageHelper;
15 15 </div>
16 16 <div class="title_item"><?= $product->name?></div></a>
17 17 <?php if ($product->brand) :?>
18   - <div class="brand">ะ‘ั€ะตะฝะด: <span><?= $product->brand->name?></span></div>
  18 + <div class="brand">ะ‘ั€ะตะฝะด: <span><?= $product->brand->name?></span></div>
19 19 <?php endif?>
20 20 <div class="type"><?= implode(', ', $product->categoriesNames)?></div>
21 21 <?php if($product->variant) :?>
... ...
frontend/views/site/index.php
... ... @@ -14,59 +14,11 @@ $this-&gt;title = &#39;My Yii Application&#39;;
14 14  
15 15 <!-- end gallery -->
16 16  
17   -
18   -
19   -<div class="novelty">
20   - <div class="content">
21   - <div class="title">ะะพะฒะธะฝะบะธ</div>
22   - <div class="novelty_cont">
23   - <div class="item" data-id="1">
24   - <div class="new">ะะพะฒะธะฝะบะฐ</div>
25   - <div class="top">Toะฟ</div>
26   - <a href="#" class="item_link"><div class="pic"><img src="images/items/01.jpg"></div>
27   - <div class="title_item">ะจั‚ัƒะบะฐั‚ัƒั€ะบะฐ ะณะธะฟัะพะฒะฐั ะšะฝะฐัƒั„ ะ ะพั‚ะฑะฐะฝะด 30 ะบะณ ะฑะตะปะฐั</div></a>
28   - <div class="brand">ะ‘ั€ะตะฝะด: <span>Knauf</span></div>
29   - <div class="type">ะจั‚ัƒะบะฐั‚ัƒั€ะบะธ</div>
30   - <div class="price">102.05 <span>ะณั€ะฝ.</span></div>
31   - <button class="basket_add_but">ะฒ ะบะพั€ะทะธะฝัƒ</button>
32   - <a href="#" class="compare_add_but"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
33   - </div>
34   - <div class="item" data-id="12">
35   - <div class="new">ะะพะฒะธะฝะบะฐ</div>
36   - <a href="#" class="item_link"><div class="pic"><img src="images/items/02.jpg"></div>
37   - <div class="title_item">Ceresit CR 65 ะณะธะดั€ะพะธะทะพะปัั†ะธะพะฝะฝะฐั ัะผะตััŒ, 25ะบะณ</div></a>
38   - <div class="brand">ะ‘ั€ะตะฝะด: <span>Ceresit</span></div>
39   - <div class="type">ะ“ะธะดั€ะพะธะทะพะปัั†ะธั</div>
40   - <div class="price">187.00 <span>ะณั€ะฝ.</span></div>
41   - <button class="basket_add_but">ะฒ ะบะพั€ะทะธะฝัƒ</button>
42   - <a href="#" class="compare_add_but"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
43   - </div>
44   - <div class="item" data-id="13">
45   - <div class="new">ะะพะฒะธะฝะบะฐ</div>
46   - <div class="top">Toะฟ</div>
47   - <a href="#" class="item_link"><div class="pic"><img src="images/items/03.jpg"></div>
48   - <div class="title_item">Ruukki ะœะตั‚ะฐะปะปะพั‡ะตั€ะตะฟะธั†ะฐ Monterrey Standard 0,5ะผะผ, ะŸะญ ะณะปัะฝะตั†</div></a>
49   - <div class="brand">ะ‘ั€ะตะฝะด: <a href="#">Rukki</a></div>
50   - <div class="type">ะœะตั‚ะฐะปะปะพั‡ะตั€ะตะฟะธั†ะฐ</div>
51   - <div class="price">168.40 <span>ะณั€ะฝ.</span></div>
52   - <button class="basket_add_but">ะฒ ะบะพั€ะทะธะฝัƒ</button>
53   - <a href="#" class="compare_add_but"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
54   - </div>
55   - <div class="item" data-id="14">
56   - <div class="new">ะะพะฒะธะฝะบะฐ</div>
57   - <div class="top">Toะฟ</div>
58   - <a href="#" class="item_link"><div class="pic"><img src="images/items/04.jpg"></div>
59   - <div class="title_item">ะะฒะตะฝัŽ ะŸะปะธั‚ะบะฐ ั‚ั€ะพั‚ัƒะฐั€ะฝะฐั ะ‘ั€ัƒัั‡ะฐั‚ะบะฐ, 200x100x40, ะฒะธัˆะฝั</div></a>
60   - <div class="brand">ะ‘ั€ะตะฝะด: <a href="#">ะะฒะตะฝัŽ</a></div>
61   - <div class="type">ะขั€ะพั‚ัƒะฐั€ะฝะฐั ะฟะปะธั‚ะบะฐ</div>
62   - <div class="price">120.00 <span>ะณั€ะฝ.</span></div>
63   - <button class="basket_add_but">ะฒ ะบะพั€ะทะธะฝัƒ</button>
64   - <a href="#" class="compare_add_but"><span>ะดะพะฑะฐะฒะธั‚ัŒ ะบ ัั€ะฐะฒะฝะตะฝะธัŽ</span></a>
65   - </div>
66   - <div style="clear:both;"></div>
67   - </div>
68   - </div>
69   -</div>
  17 +<?= \common\modules\product\widgets\specialProducts::widget([
  18 + 'type' => 'is_new',
  19 + 'title' => 'ะะพะฒะธะฝะบะธ',
  20 + 'classs' => 'novelty'
  21 +])?>
70 22  
71 23 <div class="why_us">
72 24 <div class="content">
... ...
frontend/web/images/no_photo.png

23.4 KB | W: | H:

9.21 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin