Skip to content

Commit

Permalink
Revert "Removed default value for new connector (#44)"
Browse files Browse the repository at this point in the history
This reverts commit b7c821a.
  • Loading branch information
VincentBean committed Oct 2, 2024
1 parent cf7d5f3 commit 2aaf330
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Helper/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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]);
}

Expand Down
9 changes: 9 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Set the value on the default store for required attributes that are scopable or localizable. (Default no)</comment>
</field>
<field id="defaultlanguage" translate="label" type="text" sortOrder="155" showInDefault="1" showInWebsite="0"
showInStore="0">
<label>Default language for admin channel</label>
<comment>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'
</comment>
<depends>
<field id="akeneo_connector/justbetter/defaultstorevalues">1</field>
</depends>
</field>
<group id="slack" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="0"
showInStore="0">
<label>Slack Akeneo import notifications</label>
Expand Down

0 comments on commit 2aaf330

Please sign in to comment.