Commit 3ad639d1d3dee3822fa1c5f9f740ff86ffc738f7

Authored by Karnovsky A
2 parents 28b5756e 02a42412

Merge branch 'master' of gitlab.artweb.com.ua:root/new_rukzachok

.htaccess
... ... @@ -14,7 +14,12 @@ AddDefaultCharset utf-8
14 14 # deal with admin first
15 15  
16 16  
17   -
  17 + Redirect 301 /Kak_vibrat_ryuksak /
  18 + Redirect 301 /products/ryukzaki /catalog/ryukzaki
  19 + Redirect 301 /products/koshel_ki /catalog/koshelki
  20 + Redirect 301 /products/nesessery​ /catalog/nesessery
  21 + Redirect 301 /products/sumki /catalog/sumki
  22 + Redirect 301 /products/germochehly /catalog/germocehly
18 23  
19 24 RewriteRule ^storage/(.*)?$ /storage/$1 [L,PT]
20 25  
... ... @@ -85,7 +90,6 @@ AddDefaultCharset utf-8
85 90  
86 91  
87 92  
88   -
89 93 # RewriteCond %{HTTP_HOST} ^([^www].*)$
90 94 # RewriteRule ^(.*)$ http://www.%1/$1 [R=301]
91 95  
... ... @@ -137,7 +141,7 @@ RewriteRule ^(.*)$ $1.gz [QSA,L]
137 141 </IfModule>
138 142 # Cache-Control
139 143 <ifModule mod_headers.c>
140   - # 30 дней
  144 +# 30 дней
141 145 <filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
142 146 Header set Cache-Control "max-age=2592000, public"
143 147 </filesMatch>
... ...
common/modules/product/models/Import.php
... ... @@ -16,6 +16,7 @@ use common\modules\product\models\Product;
16 16 use common\modules\product\models\ProductVariant;
17 17 use common\modules\product\models\RemoteProducts;
18 18 use yii\base\Model;
  19 +use yii\helpers\ArrayHelper;
19 20  
20 21 class Import extends Model {
21 22 public $file;
... ... @@ -119,7 +120,7 @@ class Import extends Model {
119 120 }
120 121  
121 122  
122   - $quantity = 0;
  123 +
123 124  
124 125 // ===== Set stock ====
125 126 if ( $city_name ) {
... ... @@ -130,10 +131,29 @@ class Import extends Model {
130 131 $stock->save();
131 132 }
132 133  
133   - $productVariant->stocks[$stock->stock_id] = $count;
134   - print_r($productVariant);
135   - die();
136   - $quantity = $quantity + $count;
  134 + $productStock = ProductStock::find()->where(['product_variant_id' => $productVariant->product_variant_id, 'stock_id' => $stock->stock_id])->one();
  135 + if(!$productStock instanceof ProductStock) {
  136 + $productStock = new ProductStock;
  137 + $productStock->product_variant_id = $productVariant->product_variant_id;
  138 + $productStock->stock_id = $stock->stock_id;
  139 + $productStock->product_id = $productVariant->product_id;
  140 + }
  141 + $productStock->quantity = $count;
  142 + $productStock->save();
  143 +
  144 + $productStocks = ProductStock::find()->where(['product_variant_id' => $productVariant->product_variant_id])->andWhere(['<>', 'stock_id', $stock->stock_id])->all();
  145 +
  146 + $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count;
  147 + } else {
  148 +
  149 + $productStocks = ProductStock::find()->where(['product_variant_id' => $productVariant->product_variant_id])->all();
  150 +
  151 + if($productStocks instanceof ProductStock){
  152 + $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count;
  153 + } else {
  154 + $quantity = 0;
  155 + }
  156 +
137 157 }
138 158  
139 159 if ($price_promo) {
... ...
common/modules/product/models/ProductVariant.php
... ... @@ -172,14 +172,12 @@ class ProductVariant extends \yii\db\ActiveRecord
172 172 public function afterSave($insert, $changedAttributes)
173 173 {
174 174 if (!is_null($this->stocks)) {
175   - ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]);
  175 + //ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]);
176 176 $values = [];
177 177 foreach ($this->stocks as $id => $quantity) {
178   - $values[] = [$this->product_id, $this->product_variant_id, $id, $quantity];
179   - }
180   - if ($values) {
181   - self::getDb()->createCommand()
182   - ->batchInsert(ProductStock::tableName(), ['product_id', 'product_variant_id', 'stock_id', 'quantity'], $values)->execute();
  178 + $productStock = ProductStock::find()->where(['product_variant_id' => $this->product_variant_id, 'stock_id' => $id])->one();
  179 + $productStock->quantity = $quantity;
  180 + $productStock->save();
183 181 }
184 182 }
185 183 parent::afterSave($insert, $changedAttributes);
... ...
common/widgets/Mailer.php
... ... @@ -24,14 +24,24 @@ class Mailer extends Widget{
24 24 $mail = new \PHPMailer();
25 25  
26 26 $mail->IsSMTP();
27   -
  27 + $mail->SMTPOptions = array(
  28 + 'ssl' => array(
  29 + 'verify_peer' => false,
  30 + 'verify_peer_name' => false,
  31 + 'allow_self_signed' => true
  32 + )
  33 + );
  34 + $mail->Host = "195.248.225.139";
  35 + $mail->SMTPDebug = true;
  36 + $mail->SMTPAuth = 0;
  37 + $mail->Port = 25;
28 38 $mail->CharSet = 'UTF-8';
29   - $mail->Username = "adwords@artweb.ua";
30   - $mail->Password = "eks,ybcm5hfp";
31   - $mail->SetFrom('dockdep@gmail.com');
  39 + $mail->Username = "";
  40 + $mail->Password = "";
  41 + $mail->SetFrom('Rukzachok.com.ua@gmail.com');
32 42 $mail->Subject = $this->subject;
33 43 $mail->MsgHTML($this->render($this->type, ['params' => $this->params]));
34   - $address = "dockdep@gmail.com";
  44 + $address = "Rukzachok.com.ua@gmail.com";
35 45 $mail->AddAddress($address);
36 46 $mail->AddAddress($this->email);
37 47 if(!$mail->send()) {
... ...
frontend/config/main.php
... ... @@ -111,6 +111,7 @@ return [
111 111 'admin/catalog/save' => 'admin/catalog/save',
112 112 'admin/catalog/delete' => 'admin/catalog/delete',
113 113  
  114 +
114 115 'thumbs/<path:.*>' => 'site/thumb',
115 116 ],
116 117 'class' => 'common\components\urlManager\LangUrlManager',
... ...
frontend/views/catalog/product.php
... ... @@ -113,7 +113,9 @@ $this-&gt;registerJs (&quot;
113 113 data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
114 114 data-imageoriginal="<?= $variant->imageUrl ?>"
115 115 title="<?= $product->fullname ?>">
116   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?>
  116 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', ['alt' => $product->category->categoryName->value . ' ' .
  117 + $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
  118 + $product->fullname])?>
117 119 </a>
118 120 </li>
119 121 <?php endforeach; ?>
... ... @@ -129,7 +131,7 @@ $this-&gt;registerJs (&quot;
129 131 <span class="cost"><span id='cost'>0</span> <span class="valute">грн.</span></span>
130 132 </div>
131 133 <input type='hidden' id='product_id'/>
132   - <a href="#" rel='product' class="link_buy fl">В Корзину</a>
  134 + <a href="#" rel='product' class="link_buy fl">Купить</a>
133 135 <div class="both"></div>
134 136 </div>
135 137  
... ... @@ -146,7 +148,8 @@ $this-&gt;registerJs (&quot;
146 148 <?php endif?>
147 149 </ul>
148 150 </div>
149   -
  151 + <br>
  152 + <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
150 153 </div>
151 154 <?php /*
152 155 <div class="product_service">
... ... @@ -193,13 +196,17 @@ $this-&gt;registerJs (&quot;
193 196 <div class="content">
194 197 <div class="pic">
195 198 <center>
196   - <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'product_view',['id'=>'pic'])?></a>
  199 + <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'product_view',['id'=>'pic', 'alt' => $product->category->categoryName->value . ' ' .
  200 + $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
  201 + $product->fullname])?></a>
197 202 </center>
198 203 </div>
199 204 <ul class="product_colors">
200 205 <?php foreach ($product->images as $image): ?>
201 206 <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
202   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2')?>
  207 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2',['alt' => $product->category->categoryName->value . ' ' .
  208 + $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
  209 + $product->fullname])?>
203 210 </a></li>
204 211 <?php endforeach; ?>
205 212 </ul>
... ...
frontend/views/catalog/product_item.php
... ... @@ -6,7 +6,9 @@ use yii\helpers\Url;
6 6 <div class="boxitem">
7 7 <div class="pixbox">
8 8 <a href="<?= Url::to(['catalog/product', 'product' => $product,'#' => 'm' .$product->enabledVariants[0]->product_variant_id]) ?>">
9   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'list')?>
  9 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[0]->imageUrl, 'list',['alt' => $product->category->categoryName->value . ' ' .
  10 + $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
  11 + $product->fullname])?>
10 12 </a>
11 13 </div>
12 14 <?php if(!empty($product->is_top) || !empty($product->is_new) || !empty($product->akciya)) :?>
... ... @@ -61,7 +63,9 @@ use yii\helpers\Url;
61 63 'catalog/product',
62 64 'product' => $product,
63 65 '#' => 'm' . $variant->product_variant_id]) ?>">
64   - <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?>
  66 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant',['alt' => $product->category->categoryName->value . ' ' .
  67 + $product->fullname, 'title' => $product->category->categoryName->value . ' ' .
  68 + $product->fullname])?>
65 69 </a>
66 70 </li>
67 71 <?php endif; ?>
... ...
frontend/views/catalog/products.php
... ... @@ -9,7 +9,7 @@ use yii\web\View;
9 9 use common\modules\product\helpers\ProductHelper;
10 10 use frontend\widgets\Seo;
11 11 //$this->title = $category->categoryName->value;
12   -//$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : "Купить " . substr($category->name, 0, -2) . " в Украине недорого |" . $category->name . " доставка в Киев, Харьков, Днепропетровск, Одесса - Rukzachok.com.ua";
  12 +$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : '';
13 13 $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name;
14 14 $this->params['seo']['seo_text'] = $category->seo_text;
15 15 $this->params['seo']['description'] = $category->meta_desc;
... ...
frontend/views/layouts/main.php
... ... @@ -95,6 +95,7 @@ $this-&gt;registerJsFile (Yii::$app-&gt;request-&gt;baseUrl . &#39;/js/fix_height.js&#39;, [&#39;posi
95 95 ga('create', 'UA-75674711-1', 'auto');
96 96 ga('send', 'pageview');
97 97 </script>
  98 + <meta name="google-site-verification" content="niSpd01ftupUt3pFCfQkh2zoezuPuUGblNOSGs-iRWo" />
98 99 </head>
99 100 <body>
100 101 <!-- Google Tag Manager -->
... ...
frontend/views/products/show.php
... ... @@ -115,7 +115,7 @@ use yii\widgets\Breadcrumbs;
115 115 <span class="cost"><span id='cost'>0</span> <span class="valute">грн.</span></span>
116 116 </div>
117 117 <input type='hidden' id='product_id'/>
118   - <a href="#" rel='product' class="link_buy fl">В Корзину</a>
  118 + <a href="#" rel='product' class="link_buy fl">Купить</a>
119 119 <div class="both"></div>
120 120 </div>
121 121  
... ...
frontend/widgets/Seo.php
... ... @@ -81,47 +81,47 @@ class Seo extends Widget
81 81 // return $filter_row;
82 82 // }
83 83  
84   - if (!empty($title)) {
85   - return $title;
86   - }
  84 + if(!empty($filter)) {
87 85  
88   - $array = [
89   - 'category' => $this->category_name
90   - ];
  86 + $array = [
  87 + 'category' => $this->category_name
  88 + ];
91 89  
92 90  
93   - if (isset($filter['brands']) && count($filter['brands']) == 1 )
94   - {
95   - $model = Brand::find()->where(['alias' => $filter['brands'][0]])->one();
  91 + if (isset($filter['brands']) && count($filter['brands']) == 1) {
  92 + $model = Brand::find()->where(['alias' => $filter['brands'][0]])->one();
96 93  
97   - $array['brand'] = $model->name;
98   - }
  94 + $array['brand'] = $model->name;
  95 + }
99 96  
100   - if ( isset($filter['options']["pol"]) && count($filter['options']["pol"]) == 1)
101   - {
  97 + if (isset($filter['options']["pol"]) && count($filter['options']["pol"]) == 1) {
102 98  
103   - $model = TaxOption::find()->where(['alias' => $filter['options']["pol"]])->one();
104   - $array['sex'] = $model->value->value;
  99 + $model = TaxOption::find()->where(['alias' => $filter['options']["pol"]])->one();
  100 + $array['sex'] = $model->value->value;
105 101  
106 102  
107   - }
  103 + }
108 104  
109   - if (isset($filter['options']["naznacenie"]) && count($filter['options']["naznacenie"]) == 1){
  105 + if (isset($filter['options']["naznacenie"]) && count($filter['options']["naznacenie"]) == 1) {
110 106  
111   - $model = TaxOption::find()->where(['alias' => $filter['options']["naznacenie"]])->one();
112   - $array['naz'] = $model->value->value;
  107 + $model = TaxOption::find()->where(['alias' => $filter['options']["naznacenie"]])->one();
  108 + $array['naz'] = $model->value->value;
113 109  
114   - }
  110 + }
115 111  
116   - if (isset($filter['options']["god"]) && count($filter['options']["god"]) == 1){
117   - $model = TaxOption::find()->where(['alias' => $filter['options']["god"]])->one();
118   - $array['year'] = $model->value->value;
  112 + if (isset($filter['options']["god"]) && count($filter['options']["god"]) == 1) {
119 113  
  114 + $model = TaxOption::find()->where(['alias' => $filter['options']["god"]])->one();
  115 + $array['year'] = $model->value->value;
  116 +
  117 + }
  118 + return $this->getTitleString($array);
  119 +
  120 + } else if (!empty($title)) {
  121 + return $title;
  122 + } else {
  123 + return $this->project_name;
120 124 }
121   - return $this->getTitleString($array);
122   -// else {
123   -// return $this->project_name;
124   -// }
125 125  
126 126 break;
127 127 case self::DESCRIPTION:
... ...