diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php
index 130506c..91feb11 100755
--- a/common/modules/product/controllers/ManageController.php
+++ b/common/modules/product/controllers/ManageController.php
@@ -40,54 +40,12 @@ class ManageController extends Controller
];
}
- public function actionTest() {
- return;
- foreach(Product::find()->all() as $product) {
- if (!$product->variant) {
- $product->save();
- $variantModel = new ProductVariant();
- $variantModel->product_id = $product->product_id;
- $variantModel->name = 'test-'. uniqid();
- $variantModel->sku = $variantModel->name;
- $variantModel->price = rand(5, 200000);
- $variantModel->price_old = rand(0, 5) > 3 ? $variantModel->price* (1+rand(0, 10) / 10) : $variantModel->price;
- $variantModel->product_unit_id = rand(1, 5);
- $variantModel->stock = rand(0, 50);
- $variantModel->save();
- }
- }
-
- return;
-
- $categories = Category::find()->where(['depth' => 2])->all();
- $cats_ids = [];
- foreach($categories as $cat) {
- $cats_ids[] = $cat->category_id;
- }
-
- $brands = ProductHelper::getBrands()->all();
- $brands_ids = [];
- foreach($brands as $brand) {
- $brands_ids[] = $brand->brand_id;
- }
-
- for($i=1;$i<=1000;$i++) {
- $uniqid = uniqid();
- $model = new Product();
- $model->name = 'Test '. $uniqid;
- $model->brand_id = $brands_ids[array_rand($brands_ids, 1)];
- $model->categories = [$cats_ids[array_rand($cats_ids, 1)]];
- $model->save();
-
- $variantModel = new ProductVariant();
- $variantModel->product_id = $model->product_id;
- $variantModel->name = 'test-'. $uniqid;
- $variantModel->sku = $variantModel->name;
- $variantModel->price = rand(5, 200000);
- $variantModel->price_old = rand(0, 5) > 3 ? $variantModel->price* (1+rand(0, 10) / 10) : $variantModel->price;
- $variantModel->product_unit_id = rand(1, 5);
- $variantModel->save();
+ public function actionDev() {
+ foreach (ProductVariant::find()->where(['>', 'price_old', 0])->all() as $item) {
+ if ($item->price >= $item->price_old || $item->price == 0)
+ print $item->price .' | '. $item->price_old ."
\n";
}
+ print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~';
}
/**
diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php
index 044260c..0867687 100755
--- a/common/modules/product/models/ProductVariant.php
+++ b/common/modules/product/models/ProductVariant.php
@@ -34,7 +34,7 @@ class ProductVariant extends \yii\db\ActiveRecord
public $translit;
public $translit_rubric;
private $data;
- public $stocks = [];
+ public $stocks;
/** @var array $_images */
// public $imagesUpload = [];
@@ -171,7 +171,7 @@ class ProductVariant extends \yii\db\ActiveRecord
public function afterSave($insert, $changedAttributes)
{
- if (!empty($this->stocks)) {
+ if (!is_null($this->stocks)) {
ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]);
$values = [];
foreach ($this->stocks as $id => $quantity) {
diff --git a/common/modules/product/models/import.php b/common/modules/product/models/import.php
index be0f528..a3c3a7a 100644
--- a/common/modules/product/models/import.php
+++ b/common/modules/product/models/import.php
@@ -92,7 +92,7 @@ class Import extends Model {
$product_title = @$data[5];
if (empty ($modification_code)) {
- CONTINUE;
+ continue;
}
// товары в пути
if (empty ($city_name))
@@ -104,10 +104,10 @@ class Import extends Model {
$this->output[] = 'Товар '. $product_title . ' в пути';
- CONTINUE;
+ continue;
}
- if ( ($productVariant = ProductVariant::find()->filterWhere(['ilike', 'sku', trim($modification_code)])->one()) === null ) {
+ if ( ($productVariant = ProductVariant::find()->filterWhere(['sku' => trim($modification_code)])->one()) === null ) {
// 'Нет даной модификации в базе';
$this->saveNotFoundRecord (
[$modification_code, $product_title],
@@ -116,7 +116,7 @@ class Import extends Model {
$this->output[] = 'Для товара '. $product_title . ' не найдено соотвествие';
- CONTINUE;
+ continue;
}
$quantity = 0;
@@ -134,8 +134,14 @@ class Import extends Model {
$quantity = $quantity + $count;
}
- $productVariant->price = $price;
- $productVariant->price_old = $price_promo;
+ if ($price_promo) {
+ $productVariant->price_old = $price;
+ $productVariant->price = $price_promo;
+ } else {
+ $productVariant->price = $price;
+ $productVariant->price_old = $price_promo;
+ }
+
$productVariant->stock = $quantity;
$productVariant->save();
@@ -155,6 +161,7 @@ class Import extends Model {
if ($result['end']) {
unlink(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFilePrices'));
+ $this->output[] = 'Импорт цен успешно завершен!';
}
return $result;
@@ -205,7 +212,7 @@ class Import extends Model {
if (empty ($catalog_name))
{
$result_items[] = "Не указана категория (строка $j)";
- CONTINUE;
+ continue;
}
// 2 Бренд
@@ -213,7 +220,7 @@ class Import extends Model {
if (empty ($brand_name))
{
$result_items[] = "Не указан бренд (строка $j)";
- CONTINUE;
+ continue;
}
// 3 Название товара
@@ -221,7 +228,7 @@ class Import extends Model {
if (empty ($product_name))
{
$result_items[] = "Не указано наименование товара (строка $j)";
- CONTINUE;
+ continue;
}
// 4 Описание Укр
@@ -242,11 +249,14 @@ class Import extends Model {
// 9 Год
$years = explode (',', $data[8]);
- // 10 Цена старая
- $product_cost_old = $data[10];
+ // 11 Цена акция
+ $product_cost_old = floatval($data[10]);
- // 11 Цена
- $product_cost = $data[9];
+ // 10 Цена
+ if ($product_cost_old) {
+ $product_cost_old = floatval($data[9]);
+ $product_cost = floatval($data[10]);
+ }
// 12 Акция
$product_akciya = (bool)$data[11];
diff --git a/frontend/controllers/LoginController.php b/frontend/controllers/LoginController.php
index 05f3a33..0304395 100755
--- a/frontend/controllers/LoginController.php
+++ b/frontend/controllers/LoginController.php
@@ -7,8 +7,6 @@ use yii\web\Controller;
use frontend\models\LoginForm;
use common\models\Customer;
-use common\widgets\Mailer;
-
class LoginController extends Controller
{
//public $layout='layout';
@@ -36,15 +34,10 @@ class LoginController extends Controller
}
public function actionForgot(){
+
$model = new Customer;
- if(!empty($_POST['Customer']['username'])){
- if($user = Customer::find()->where(['username'=>$_POST['Customer']['username']])->one())
- Mailer::widget(
- ['type' => 'password',
- 'subject'=> 'Ваш пароль',
- 'email' => $user->username,
- 'params' => $user,
- ]);
+ if(!empty($_POST['User']['username'])){
+ if($user = Customer::find()->where(['username'=>$_POST['User']['username']])->one())
$user->sendMsg();
Yii::$app->getSession()->setFlash('success', 'На указанный Вами эмейл отправленно письмо с паролем!');
return $this->refresh();
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php
index c5c3e2b..f608feb 100755
--- a/frontend/controllers/SiteController.php
+++ b/frontend/controllers/SiteController.php
@@ -189,12 +189,5 @@ class SiteController extends Controller
}
- public function actionSms()
- {
-
- $resp = Yii::$app->smssender->send('+380633930736','test Rukzak');
- var_dump($resp);
-
- }
}
\ No newline at end of file
diff --git a/frontend/models/ProductFrontendSearch.php b/frontend/models/ProductFrontendSearch.php
index 5f966e0..b9867b7 100755
--- a/frontend/models/ProductFrontendSearch.php
+++ b/frontend/models/ProductFrontendSearch.php
@@ -76,7 +76,7 @@ class ProductFrontendSearch extends Product {
'asc' => [ProductVariant::tableName() .'.price' => SORT_ASC],
'desc' => [ProductVariant::tableName() .'.price' => SORT_DESC],
'default' => SORT_DESC,
- 'label' => 'цене',
+ 'label' => 'по цене',
],
],
]
--
libgit2 0.21.4