From 95a475a05c51dfa300ff52cc47b26b464c4c77b8 Mon Sep 17 00:00:00 2001 From: preciousdaleramirez Date: Tue, 30 May 2023 19:26:57 +0800 Subject: [PATCH 1/2] Fixed a bug where variant attributes are not respecting the parseTwig setting. --- CHANGELOG.md | 5 +++++ src/elements/CommerceProduct.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f1a63e4..48ef12cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release Notes for Feed Me +## Unreleased + +- Fixed a bug where variant attributes are not respecting the parseTwig setting. ([#1035](https://github.com/craftcms/feed-me/issues/1035)) +- Fixed a bug where the date format option template import is missing for Post Date and Expiry Date. ([#602](https://github.com/craftcms/feed-me/issues/602)) + ## 5.1.3.1 - 2023-05-02 - Fixed a bug where custom fields would not import on PostgreSQL. diff --git a/src/elements/CommerceProduct.php b/src/elements/CommerceProduct.php index 246024e8..6d325bd9 100644 --- a/src/elements/CommerceProduct.php +++ b/src/elements/CommerceProduct.php @@ -154,6 +154,8 @@ public function save($element, $settings): bool { $this->beforeSave($element, $settings); + + if (!Craft::$app->getElements()->saveElement($this->element, true, true, Hash::get($this->feed, 'updateSearchIndexes'))) { $errors = [$this->element->getErrors()]; @@ -395,6 +397,8 @@ private function _parseVariants($event): void } } + $parseTwig = Plugin::$plugin->service->getConfig('parseTwig', $feed['id']); + foreach ($variantData as $variantContent) { $attributeData = []; $fieldData = []; @@ -404,7 +408,7 @@ private function _parseVariants($event): void if (Hash::get($fieldInfo, 'attribute')) { $attributeValue = DataHelper::fetchValue(Hash::get($fieldInfo, 'data'), $fieldInfo, $this->feed); - $attributeData[$fieldHandle] = $attributeValue; + $attributeData[$fieldHandle] = $parseTwig ? DataHelper::parseFieldDataForElement($attributeValue, $this->element) : $attributeValue; } } From ce5e4e1c9d0fd3c24fd8d6af480e6d52573e3fab Mon Sep 17 00:00:00 2001 From: preciousdaleramirez Date: Tue, 30 May 2023 19:30:11 +0800 Subject: [PATCH 2/2] clean up --- CHANGELOG.md | 1 - src/elements/CommerceProduct.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ef12cb..a39ae05f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ ## Unreleased - Fixed a bug where variant attributes are not respecting the parseTwig setting. ([#1035](https://github.com/craftcms/feed-me/issues/1035)) -- Fixed a bug where the date format option template import is missing for Post Date and Expiry Date. ([#602](https://github.com/craftcms/feed-me/issues/602)) ## 5.1.3.1 - 2023-05-02 diff --git a/src/elements/CommerceProduct.php b/src/elements/CommerceProduct.php index 6d325bd9..b342186f 100644 --- a/src/elements/CommerceProduct.php +++ b/src/elements/CommerceProduct.php @@ -154,8 +154,6 @@ public function save($element, $settings): bool { $this->beforeSave($element, $settings); - - if (!Craft::$app->getElements()->saveElement($this->element, true, true, Hash::get($this->feed, 'updateSearchIndexes'))) { $errors = [$this->element->getErrors()];