From 5cfd99bcbbceac8864058401c64f9c073f530913 Mon Sep 17 00:00:00 2001 From: preciousdaleramirez Date: Thu, 4 May 2023 12:15:24 +0800 Subject: [PATCH] Fixed a bug where updating an existing Commerce Product triggers validation. --- CHANGELOG.md | 1 + src/elements/CommerceProduct.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 888441a3..9a6725e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed several bugs related to empty and non-existent feed values and the “Set Empty Values” feed setting. ([#1271](https://github.com/craftcms/feed-me/pull/1271)) - Fixed a bug where that prevented importing data as Commerce Variants. ([#464](https://github.com/craftcms/feed-me/issues/464), [#1168](https://github.com/craftcms/feed-me/issues/1168)) - Fixed an XSS vulnerability. +- Fixed a bug where updating an existing Commerce Product triggers validation. ([#1034](https://github.com/craftcms/feed-me/issues/1034)) ## 4.6.1.1 - 2023-03-24 diff --git a/src/elements/CommerceProduct.php b/src/elements/CommerceProduct.php index 00e4ed88..55a4eeba 100644 --- a/src/elements/CommerceProduct.php +++ b/src/elements/CommerceProduct.php @@ -147,7 +147,13 @@ public function save($element, $settings) { $this->beforeSave($element, $settings); - if (!Craft::$app->getElements()->saveElement($this->element, true, true, Hash::get($this->feed, 'updateSearchIndexes'))) { + $runValidation = true; + + if ($element->id !== null) { + $runValidation = false; + } + + if (!Craft::$app->getElements()->saveElement($this->element, $runValidation, true, Hash::get($this->feed, 'updateSearchIndexes'))) { $errors = [$this->element->getErrors()]; if ($this->element->getErrors()) {