Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Mar 19, 2024
1 parent b294705 commit 2f4b219
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/console/controllers/SkeeksSuppliersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SkeeksSuppliersController extends Controller
/**
* @var int
*/
public $is_stop_on_error = 1;
public $is_stop_on_error = 0;

/**
* @var int
Expand Down Expand Up @@ -98,6 +98,10 @@ public function init()
if (!\Yii::$app->cms->cmsSite->shopSite->catalogMainCmsTree) {
throw new Exception("Магазин не настроен, нет корневого раздела для товаров.");
}

\Yii::$app->skeeks->site->shopSite->required_collection_fields = [];
\Yii::$app->skeeks->site->shopSite->required_brand_fields = [];
\Yii::$app->skeeks->site->shopSite->required_product_fields = [];

return parent::init();
}
Expand Down Expand Up @@ -1080,7 +1084,7 @@ private function _updateCollection($apiData = [], ShopCollection $model = null)
$model->setImageIds($imgIds);
}

if ($model->save()) {
if ($model->save(false)) {

} else {
throw new Exception("Ошибка создания коллекции: ".print_r($model->errors, true));
Expand Down Expand Up @@ -1227,7 +1231,7 @@ private function _updateProduct($apiData = [], ShopCmsContentElement $model = nu
throw new Exception("Ошибка обновления товара {$model->id}: ".print_r($model->errors, true) . print_r($apiData, true));
}

if (!$shopProduct->save()) {
if (!$shopProduct->save(false)) {
throw new Exception("Ошибка обновления товара {$model->id}: ".print_r($shopProduct->errors, true) . print_r($apiData, true));
}

Expand Down Expand Up @@ -1341,7 +1345,7 @@ private function _updateProduct($apiData = [], ShopCmsContentElement $model = nu

$shopProduct->id = $model->id;

if (!$shopProduct->save()) {
if (!$shopProduct->save(false)) {
throw new Exception("Ошибка создания товара: ".print_r($shopProduct->errors, true) . print_r($shopProduct->toArray(), true));
}

Expand Down Expand Up @@ -1593,6 +1597,7 @@ private function _updateStore($apiData = [], ShopStore $model = null)
$model->address = trim((string)ArrayHelper::getValue($apiData, "address"));
$model->latitude = (float)ArrayHelper::getValue($apiData, "latitude");
$model->longitude = (float)ArrayHelper::getValue($apiData, "longitude");
$model->is_supplier = 1;

if ($image = $this->_addImage(ArrayHelper::getValue($apiData, "image"))) {
$model->cms_image_id = $image->id;
Expand All @@ -1611,6 +1616,7 @@ private function _updateStore($apiData = [], ShopStore $model = null)

$model->sx_id = (int)ArrayHelper::getValue($apiData, "id");

$model->is_supplier = 1;
$model->name = trim((string)ArrayHelper::getValue($apiData, "name"));
$model->address = trim((string)ArrayHelper::getValue($apiData, "address"));
$model->latitude = (float)ArrayHelper::getValue($apiData, "latitude");
Expand Down

0 comments on commit 2f4b219

Please sign in to comment.