Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Mar 21, 2024
1 parent 0be476d commit d0cb4bb
Showing 1 changed file with 48 additions and 34 deletions.
82 changes: 48 additions & 34 deletions src/console/controllers/SkeeksSuppliersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,28 +1524,34 @@ private function _updatePropertiesForProduct(ShopCmsContentElement $model, array
{
$enumSxId = (int)ArrayHelper::getValue($valueObject, "id");
$enumSxValue = (string)ArrayHelper::getValue($valueObject, "value");

/**
* @var $enum CmsContentPropertyEnum
*/
$enum = CmsContentPropertyEnum::find()->andWhere(['sx_id' => $enumSxId])->one();
//$enum = $property->getEnums()->andWhere(['sx_id' => $enumSxId])->one();
if (!$enum) {
$enum = new CmsContentPropertyEnum();
$enum->property_id = $property->id;
$enum->value = $enumSxValue;
$enum->sx_id = $enumSxId;
if (!$enum->save()) {
throw new Exception(print_r($enum->errors, true));
}
} else {
if ($enum->property_id != $property->id) {
$enum->property_id = $property->id;
$enum->update(false, ['property_id']);
//if ($enumSxValue) {
/**
* @var $enum CmsContentPropertyEnum
*/
$enum = CmsContentPropertyEnum::find()->andWhere(['sx_id' => $enumSxId])->one();
//$enum = $property->getEnums()->andWhere(['sx_id' => $enumSxId])->one();
if (!$enum) {
$enum = new CmsContentPropertyEnum();
$enum->property_id = $property->id;
$enum->value = $enumSxValue;
$enum->sx_id = $enumSxId;
if (!$enum->save()) {
throw new Exception(print_r($enum->errors, true));
}
} else {
if ($enum->property_id != $property->id) {
$enum->property_id = $property->id;
$enum->update(false, ['property_id']);
}
}
}

$enumIds[] = $enum->id;
//} else {
// echo '1111';
// var_dump($valueObject);die;
//}


$enumIds[] = $enum->id;
}

$rpmModel->{$property->code} = $enumIds;
Expand All @@ -1555,24 +1561,32 @@ private function _updatePropertiesForProduct(ShopCmsContentElement $model, array
$enumSxId = (int)ArrayHelper::getValue($value, "id");
$enumSxValue = (string)ArrayHelper::getValue($value, "value");

//$enum = $property->getEnums()->andWhere(['sx_id' => $enumSxId])->one();
$enum = CmsContentPropertyEnum::find()->andWhere(['sx_id' => $enumSxId])->one();
if (!$enum) {
$enum = new CmsContentPropertyEnum();
$enum->property_id = $property->id;
$enum->value = $enumSxValue;
$enum->sx_id = $enumSxId;
if (!$enum->save()) {
throw new Exception(print_r($enum->errors, true) . print_r($enum->toArray(), true));
if ($enumSxValue) {
//$enum = $property->getEnums()->andWhere(['sx_id' => $enumSxId])->one();
$enum = CmsContentPropertyEnum::find()->andWhere(['sx_id' => $enumSxId])->one();
if (!$enum) {
$enum = new CmsContentPropertyEnum();
$enum->property_id = $property->id;
$enum->value = $enumSxValue;
$enum->sx_id = $enumSxId;
if (!$enum->save()) {
throw new Exception(print_r($enum->errors, true) . print_r($enum->toArray(), true));
}
} else {
if ($enum->property_id != $property->id) {
$enum->property_id = $property->id;
$enum->update(false, ['property_id']);
}
}

$rpmModel->{$property->code} = $enum->id;
} else {
if ($enum->property_id != $property->id) {
$enum->property_id = $property->id;
$enum->update(false, ['property_id']);
}
/*print_r($property->toArray());die;
echo '2222';
print_r($value);die;*/
}

$rpmModel->{$property->code} = $enum->id;

} else {
$rpmModel->{$property->code} = "";
}
Expand Down

0 comments on commit d0cb4bb

Please sign in to comment.