Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Removed default value for new connector (#44)" #47

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading