From b7c821ad586629c942bcb1293a1a3fd793f85202 Mon Sep 17 00:00:00 2001 From: Frits de Vries <110908371+fritsjustbetter@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:11:48 +0200 Subject: [PATCH 1/2] Removed default value for new connector (#44) --- Helper/Import/Product.php | 8 -------- etc/adminhtml/system.xml | 9 --------- 2 files changed, 17 deletions(-) diff --git a/Helper/Import/Product.php b/Helper/Import/Product.php index 9ee8813..f9d80cf 100644 --- a/Helper/Import/Product.php +++ b/Helper/Import/Product.php @@ -16,10 +16,6 @@ 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) { @@ -32,10 +28,6 @@ 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 05efd4a..4b58a3a 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -129,15 +129,6 @@ 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 - - From cf7d5f302ad8b5499ff6583fb542a6f668a105d4 Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:19:43 +0200 Subject: [PATCH 2/2] Remove the akeneo auth from the construct (#45) --- Job/ImportMetricUnits.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Job/ImportMetricUnits.php b/Job/ImportMetricUnits.php index 7c85951..36c675a 100644 --- a/Job/ImportMetricUnits.php +++ b/Job/ImportMetricUnits.php @@ -18,8 +18,8 @@ class ImportMetricUnits protected const ENABLED_CONFIG_KEY = 'enablemetricunits'; protected const CHANNEL_CONFIG_KEY = 'metric_conversion_channel'; + protected Authenticator $authenticator; protected AttributeRepositoryInterface $attributeRepository; - protected ?AkeneoPimClientInterface $akeneoClient = null; protected ScopeConfigInterface $config; public function __construct( @@ -27,17 +27,14 @@ public function __construct( AttributeRepositoryInterface $attributeRepository, ScopeConfigInterface $config ) { + $this->authenticator = $authenticator; $this->attributeRepository = $attributeRepository; $this->config = $config; - - if (($client = $authenticator->getAkeneoApiClient())) { - $this->akeneoClient = $client; - } } public function execute(OutputInterface $output = null): void { - if (! $this->akeneoClient) { + if (! $this->authenticator->getAkeneoApiClient()) { if ($output) { $output->writeln('Akeneo client not configured!'); } @@ -90,13 +87,13 @@ protected function getMetricAttributes(): ResourceCursor { $search = (new SearchBuilder())->addFilter('type', 'IN', ['pim_catalog_metric']); - return $this->akeneoClient->getAttributeApi()->all(100, ['search' => $search->getFilters()]); + return $this->authenticator->getAkeneoApiClient()->getAttributeApi()->all(100, ['search' => $search->getFilters()]); } protected function getChannelConversions(): array { $channel = $this->config->getValue(static::CONFIG_PREFIX . static::CHANNEL_CONFIG_KEY); - return $this->akeneoClient->getChannelApi()->get($channel)['conversion_units'] ?? []; + return $this->authenticator->getAkeneoApiClient()->getChannelApi()->get($channel)['conversion_units'] ?? []; } }