From 2aaf33078f4a7eb33fe02ee6526c9d3db2f2d76d Mon Sep 17 00:00:00 2001 From: Vincent Boon Date: Wed, 2 Oct 2024 13:39:22 +0200 Subject: [PATCH] Revert "Removed default value for new connector (#44)" This reverts commit b7c821ad586629c942bcb1293a1a3fd793f85202. --- Helper/Import/Product.php | 8 ++++++++ etc/adminhtml/system.xml | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/Helper/Import/Product.php b/Helper/Import/Product.php index f9d80cf..9ee8813 100644 --- a/Helper/Import/Product.php +++ b/Helper/Import/Product.php @@ -16,6 +16,10 @@ protected function getColumnsFromResult(array $result, array $keys = []): array return $mappedResult; } + $adminChannel = $this->scopeConfig->getValue('akeneo_connector/akeneo_api/admin_channel'); + + $defaultLanguage = $this->scopeConfig->getValue('akeneo_connector/justbetter/defaultlanguage'); + $requiredAttributes = $this->getRequiredAttributes(); foreach ($requiredAttributes as $requiredAttribute) { @@ -28,6 +32,10 @@ protected function getColumnsFromResult(array $result, array $keys = []): array continue; } + if (!array_key_exists($requiredAttribute.'-'.$defaultLanguage.'-'.$adminChannel, $mappedResult) && $defaultLanguage) { + $mappedResult[$requiredAttribute.'-'.$defaultLanguage.'-'.$adminChannel] = $this->getFirstValue($result['values'][$requiredAttribute]); + } + $mappedResult[$requiredAttribute] = $this->getFirstValue($result['values'][$requiredAttribute]); } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 4b58a3a..05efd4a 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -129,6 +129,15 @@ Magento\Config\Model\Config\Source\Yesno Set the value on the default store for required attributes that are scopable or localizable. (Default no) + + + If a value of the admin channel is missing, then this setting can be used to map a certain value as your definitive fallback value for a required attribute for example 'nl_NL' + + + 1 + +