From 596333bc0a956fbd02d63793a90aae62fa92920e Mon Sep 17 00:00:00 2001 From: Claudio Ferraro Date: Fri, 13 Sep 2024 15:45:48 +0200 Subject: [PATCH 1/3] Improve code to PhpStan level 4 + Akeneo Connector version constraint --- Block/Adminhtml/Akeneo/Edit.php | 2 +- Block/Adminhtml/Akeneo/Edit/Tab/Main.php | 38 +++++++------------ Block/Adminhtml/Akeneo/Grid.php | 7 +++- .../System/Config/Form/Field/TaxIdMapping.php | 6 +-- Console/Command/ImportMetricUnits.php | 8 +++- Console/Command/SetNotVisible.php | 4 +- .../Adminhtml/{akeneo => Akeneo}/Delete.php | 0 .../Adminhtml/{akeneo => Akeneo}/Edit.php | 0 .../{akeneo => Akeneo}/ExportCsv.php | 2 + .../{akeneo => Akeneo}/ExportExcel.php | 2 + .../Adminhtml/{akeneo => Akeneo}/Index.php | 0 .../{akeneo => Akeneo}/MassDelete.php | 0 .../{akeneo => Akeneo}/MassStatus.php | 0 .../{akeneo => Akeneo}/NewAction.php | 0 .../Adminhtml/{akeneo => Akeneo}/Save.php | 17 ++++++--- Helper/Import/Product.php | 9 +++-- Job/ImportMetricUnits.php | 11 ++++-- Job/RunSlackMessage.php | 31 ++++++++------- Plugin/CheckWebsiteAssociation.php | 2 - Plugin/Helper/Import/Product.php | 2 +- Plugin/SetTaxClassId.php | 5 ++- composer.json | 3 +- phpstan.neon | 2 +- 23 files changed, 84 insertions(+), 67 deletions(-) rename Controller/Adminhtml/{akeneo => Akeneo}/Delete.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/Edit.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/ExportCsv.php (92%) rename Controller/Adminhtml/{akeneo => Akeneo}/ExportExcel.php (92%) rename Controller/Adminhtml/{akeneo => Akeneo}/Index.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/MassDelete.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/MassStatus.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/NewAction.php (100%) rename Controller/Adminhtml/{akeneo => Akeneo}/Save.php (75%) diff --git a/Block/Adminhtml/Akeneo/Edit.php b/Block/Adminhtml/Akeneo/Edit.php index e3c744f..ac32640 100755 --- a/Block/Adminhtml/Akeneo/Edit.php +++ b/Block/Adminhtml/Akeneo/Edit.php @@ -50,7 +50,7 @@ protected function _construct(): void /** * Retrieve text for header element depending on loaded post */ - public function getHeaderText(): Phrase + public function getHeaderText(): Phrase|string { if ($this->coreRegistry->registry('akeneo')->getId()) { return __("Edit Akeneo '%1'", $this->escapeHtml($this->coreRegistry->registry('akeneo')->getTitle())); diff --git a/Block/Adminhtml/Akeneo/Edit/Tab/Main.php b/Block/Adminhtml/Akeneo/Edit/Tab/Main.php index fe275a0..0c3b036 100755 --- a/Block/Adminhtml/Akeneo/Edit/Tab/Main.php +++ b/Block/Adminhtml/Akeneo/Edit/Tab/Main.php @@ -3,7 +3,9 @@ namespace JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo\Edit\Tab; use IntlDateFormatter; +use JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo\Grid; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Store\Model\System\Store; use Magento\Framework\Data\FormFactory; @@ -31,7 +33,6 @@ public function __construct( /** * Prepare form * - * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @throws LocalizedException */ @@ -39,8 +40,6 @@ protected function _prepareForm(): static { $model = $this->_coreRegistry->registry('akeneo'); - $isElementDisabled = false; - $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('page_'); @@ -59,8 +58,8 @@ protected function _prepareForm(): static 'title' => __('Type'), 'name' => 'import', 'required' => true, - 'options' => \JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo\Grid::getOptionArray0(), - 'disabled' => $isElementDisabled + 'options' => Grid::getOptionArray0(), + 'disabled' => false ] ); @@ -72,7 +71,7 @@ protected function _prepareForm(): static 'label' => __('Code'), 'title' => __('Code'), 'required' => true, - 'disabled' => $isElementDisabled + 'disabled' => false ] ); @@ -84,7 +83,7 @@ protected function _prepareForm(): static 'label' => __('Magento Entity ID'), 'title' => __('Magento Entity ID'), 'required' => true, - 'disabled' => $isElementDisabled + 'disabled' => false ] ); @@ -103,14 +102,12 @@ protected function _prepareForm(): static 'label' => __('Created'), 'title' => __('Created'), 'date_format' => $dateFormat, - //'time_format' => $timeFormat, - - 'disabled' => $isElementDisabled, + 'disabled' => false ] ); if (!$model->getId()) { - $model->setData('is_active', $isElementDisabled ? '0' : '1'); + $model->setData('is_active', '1'); } $form->setValues($model->getData()); @@ -121,20 +118,16 @@ protected function _prepareForm(): static /** * Prepare label for tab - * - * @return \Magento\Framework\Phrase */ - public function getTabLabel() + public function getTabLabel(): Phrase|string { return __('Item Information'); } /** * Prepare title for tab - * - * @return \Magento\Framework\Phrase */ - public function getTabTitle() + public function getTabTitle(): Phrase|string { return __('Item Information'); } @@ -142,7 +135,7 @@ public function getTabTitle() /** * {@inheritdoc} */ - public function canShowTab() + public function canShowTab(): bool { return true; } @@ -150,23 +143,20 @@ public function canShowTab() /** * {@inheritdoc} */ - public function isHidden() + public function isHidden(): bool { return false; } /** * Check permission for passed action - * - * @param string $resourceId - * @return bool */ - protected function _isAllowedAction($resourceId) + protected function _isAllowedAction(string $resourceId): bool { return $this->_authorization->isAllowed($resourceId); } - public function getTargetOptionArray() + public function getTargetOptionArray(): array { return ['_self' => 'Self', '_blank' => 'New Page']; } diff --git a/Block/Adminhtml/Akeneo/Grid.php b/Block/Adminhtml/Akeneo/Grid.php index 061fedb..732dbfa 100755 --- a/Block/Adminhtml/Akeneo/Grid.php +++ b/Block/Adminhtml/Akeneo/Grid.php @@ -3,6 +3,7 @@ namespace JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo; use Exception; +use Magento\Backend\Block\Widget\Grid\Massaction; use Magento\Backend\Helper\Data; use Magento\Framework\Module\Manager; use Magento\Backend\Block\Template\Context; @@ -116,7 +117,9 @@ protected function _prepareMassaction(): static $this->setMassactionIdField('id'); $this->getMassactionBlock()->setFormFieldName('akeneo'); - $this->getMassactionBlock()->addItem( + /** @var Massaction $massactionBlock */ + $massactionBlock = $this->getMassactionBlock(); + $massactionBlock->addItem( 'delete', [ 'label' => __('Delete'), @@ -127,7 +130,7 @@ protected function _prepareMassaction(): static $statuses = $this->status->getOptionArray(); - $this->getMassactionBlock()->addItem( + $massactionBlock->addItem( 'status', [ 'label' => __('Change status'), diff --git a/Block/Adminhtml/System/Config/Form/Field/TaxIdMapping.php b/Block/Adminhtml/System/Config/Form/Field/TaxIdMapping.php index 51859f3..a37043a 100644 --- a/Block/Adminhtml/System/Config/Form/Field/TaxIdMapping.php +++ b/Block/Adminhtml/System/Config/Form/Field/TaxIdMapping.php @@ -45,11 +45,7 @@ public function renderCellTemplate($columnName): string return parent::renderCellTemplate($columnName); } - $options = []; - - if (isset($this->_columns[$columnName])) { - $options = $this->productTaxClassSource->getAllOptions(); - } + $options = $this->productTaxClassSource->getAllOptions(); /** @var Select $element */ $element = $this->elementFactory->create('select'); diff --git a/Console/Command/ImportMetricUnits.php b/Console/Command/ImportMetricUnits.php index 48bd222..60a4ccf 100644 --- a/Console/Command/ImportMetricUnits.php +++ b/Console/Command/ImportMetricUnits.php @@ -2,6 +2,7 @@ namespace JustBetter\AkeneoBundle\Console\Command; +use Exception; use JustBetter\AkeneoBundle\Job\ImportMetricUnits as ImportMetricUnitsJob; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -23,8 +24,13 @@ protected function configure(): void parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output): void + /** + * @throws Exception + */ + protected function execute(InputInterface $input, OutputInterface $output): int { $this->job->execute($output); + + return 0; } } diff --git a/Console/Command/SetNotVisible.php b/Console/Command/SetNotVisible.php index 71a4695..eed9346 100644 --- a/Console/Command/SetNotVisible.php +++ b/Console/Command/SetNotVisible.php @@ -23,12 +23,14 @@ protected function configure(): void parent::configure(); } - protected function execute(InputInterface $input, OutputInterface $output): void + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln('Starting'); $this->job->execute($output); $output->writeln('Finished!'); + + return 0; } } diff --git a/Controller/Adminhtml/akeneo/Delete.php b/Controller/Adminhtml/Akeneo/Delete.php similarity index 100% rename from Controller/Adminhtml/akeneo/Delete.php rename to Controller/Adminhtml/Akeneo/Delete.php diff --git a/Controller/Adminhtml/akeneo/Edit.php b/Controller/Adminhtml/Akeneo/Edit.php similarity index 100% rename from Controller/Adminhtml/akeneo/Edit.php rename to Controller/Adminhtml/Akeneo/Edit.php diff --git a/Controller/Adminhtml/akeneo/ExportCsv.php b/Controller/Adminhtml/Akeneo/ExportCsv.php similarity index 92% rename from Controller/Adminhtml/akeneo/ExportCsv.php rename to Controller/Adminhtml/Akeneo/ExportCsv.php index b155482..8546c09 100755 --- a/Controller/Adminhtml/akeneo/ExportCsv.php +++ b/Controller/Adminhtml/Akeneo/ExportCsv.php @@ -6,6 +6,7 @@ use JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo\Grid; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Block\Widget\Grid\Export; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\App\ResponseInterface; @@ -27,6 +28,7 @@ public function execute(): ResultInterface|ResponseInterface { $this->_view->loadLayout(false); + /** @var Export $exportBlock */ $exportBlock = $this->_view->getLayout()->createBlock(Grid::class); return $this->fileFactory->create( diff --git a/Controller/Adminhtml/akeneo/ExportExcel.php b/Controller/Adminhtml/Akeneo/ExportExcel.php similarity index 92% rename from Controller/Adminhtml/akeneo/ExportExcel.php rename to Controller/Adminhtml/Akeneo/ExportExcel.php index 64da440..3391cec 100755 --- a/Controller/Adminhtml/akeneo/ExportExcel.php +++ b/Controller/Adminhtml/Akeneo/ExportExcel.php @@ -6,6 +6,7 @@ use JustBetter\AkeneoBundle\Block\Adminhtml\Akeneo\Grid; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Block\Widget\Grid\Export; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\App\ResponseInterface; @@ -27,6 +28,7 @@ public function execute(): ResultInterface|ResponseInterface { $this->_view->loadLayout(false); + /** @var Export $exportBlock */ $exportBlock = $this->_view->getLayout()->createBlock(Grid::class); return $this->fileFactory->create( diff --git a/Controller/Adminhtml/akeneo/Index.php b/Controller/Adminhtml/Akeneo/Index.php similarity index 100% rename from Controller/Adminhtml/akeneo/Index.php rename to Controller/Adminhtml/Akeneo/Index.php diff --git a/Controller/Adminhtml/akeneo/MassDelete.php b/Controller/Adminhtml/Akeneo/MassDelete.php similarity index 100% rename from Controller/Adminhtml/akeneo/MassDelete.php rename to Controller/Adminhtml/Akeneo/MassDelete.php diff --git a/Controller/Adminhtml/akeneo/MassStatus.php b/Controller/Adminhtml/Akeneo/MassStatus.php similarity index 100% rename from Controller/Adminhtml/akeneo/MassStatus.php rename to Controller/Adminhtml/Akeneo/MassStatus.php diff --git a/Controller/Adminhtml/akeneo/NewAction.php b/Controller/Adminhtml/Akeneo/NewAction.php similarity index 100% rename from Controller/Adminhtml/akeneo/NewAction.php rename to Controller/Adminhtml/Akeneo/NewAction.php diff --git a/Controller/Adminhtml/akeneo/Save.php b/Controller/Adminhtml/Akeneo/Save.php similarity index 75% rename from Controller/Adminhtml/akeneo/Save.php rename to Controller/Adminhtml/Akeneo/Save.php index 25839fb..6b7bd78 100755 --- a/Controller/Adminhtml/akeneo/Save.php +++ b/Controller/Adminhtml/Akeneo/Save.php @@ -2,9 +2,12 @@ namespace JustBetter\AkeneoBundle\Controller\Adminhtml\Akeneo; +use JustBetter\AkeneoBundle\Model\Akeneo; use Magento\Backend\App\Action; use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\HTTP\PhpEnvironment\Request; class Save extends Action { @@ -16,14 +19,16 @@ public function __construct( public function execute(): ResultInterface { - $data = $this->getRequest()->getPostValue(); + /** @var Request $request */ + $request = $this->getRequest(); + $data = $request->getPostValue(); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); if ($data) { - $model = $this->_objectManager->create(\JustBetter\AkeneoBundle\Model\Akeneo::class); + $model = $this->_objectManager->create(Akeneo::class); - $id = $this->getRequest()->getParam('id'); + $id = $request->getParam('id'); if ($id) { $model->load($id); $model->setCreatedAt(date('Y-m-d H:i:s')); @@ -35,18 +40,18 @@ public function execute(): ResultInterface $model->save(); $this->messageManager->addSuccess(__('The Akeneo has been saved.')); $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false); - if ($this->getRequest()->getParam('back')) { + if ($request->getParam('back')) { return $resultRedirect->setPath('*/*/edit', ['id' => $model->getId(), '_current' => true]); } return $resultRedirect->setPath('*/*/'); - } catch (\Magento\Framework\Exception\LocalizedException|\RuntimeException $e) { + } catch (LocalizedException|\RuntimeException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong while saving the Akeneo.')); } $this->_getSession()->setFormData($data); - return $resultRedirect->setPath('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); + return $resultRedirect->setPath('*/*/edit', ['id' => $request->getParam('id')]); } return $resultRedirect->setPath('*/*/'); diff --git a/Helper/Import/Product.php b/Helper/Import/Product.php index ddc82ff..00b95e5 100644 --- a/Helper/Import/Product.php +++ b/Helper/Import/Product.php @@ -3,6 +3,7 @@ namespace JustBetter\AkeneoBundle\Helper\Import; use Akeneo\Connector\Helper\Import\Product as BaseProduct; +use Magento\Framework\DB\Adapter\AdapterInterface; class Product extends BaseProduct { @@ -43,7 +44,7 @@ protected function getFirstValue(array $values): mixed } /** - * Check if an attribute is scopeable or localizable based on the column result name, ex. name-nl_NL-ecommerce + * Check if an attribute is scopable or localizable based on the column result name, ex. name-nl_NL-ecommerce */ protected function isScopableOrLocalizable(string $attributeCode, array $columnResult): bool { @@ -71,13 +72,15 @@ protected function getRequiredAttributes(): array $eavAttributeTable = $this->connection->getTableName('eav_attribute'); $eavEntityTypeTable = $this->connection->getTableName('eav_entity_type'); - $select = $this->connection->select() + /** @var AdapterInterface $connection */ + $connection = $this->connection; + $select = $connection->select() ->from("$eavAttributeTable AS attr") ->join("$eavEntityTypeTable AS type", "attr.entity_type_id = type.entity_type_id AND type.entity_type_code = 'catalog_product'") ->where('is_required = 1'); - $requiredAttributes = $this->connection->fetchAll($select); + $requiredAttributes = $connection->fetchAll($select); return array_map(fn (array $attribute) => $attribute['attribute_code'], $requiredAttributes); } diff --git a/Job/ImportMetricUnits.php b/Job/ImportMetricUnits.php index 95e00ee..084e761 100644 --- a/Job/ImportMetricUnits.php +++ b/Job/ImportMetricUnits.php @@ -4,10 +4,11 @@ use Akeneo\Connector\Helper\Authenticator; use Akeneo\Pim\ApiClient\AkeneoPimClientInterface; -use Akeneo\Pim\ApiClient\Pagination\ResourceCursor; +use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface; use Akeneo\Pim\ApiClient\Search\SearchBuilder; use Exception; use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Eav\Model\Entity\Attribute; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Exception\NoSuchEntityException; use Symfony\Component\Console\Output\OutputInterface; @@ -33,6 +34,9 @@ public function __construct( } } + /** + * @throws Exception + */ public function execute(OutputInterface $output = null): void { if (! $this->akeneoClient) { @@ -55,6 +59,7 @@ public function execute(OutputInterface $output = null): void : $akeneoAttribute['default_metric_unit']; try { + /** @var Attribute $magentoAttribute */ $magentoAttribute = $this->attributeRepository->get('catalog_product', $code); } catch (NoSuchEntityException) { $output?->writeln("Skipping $code because it does not exist in Magento"); @@ -66,7 +71,7 @@ public function execute(OutputInterface $output = null): void } $magentoAttribute->setData(self::EAV_ATTRIBUTE_UNIT_FIELD, $unit); - $magentoAttribute->save(); + $magentoAttribute->save(); // @phpstan-ignore-line $output?->writeln("Set unit for $code to $unit"); } @@ -74,7 +79,7 @@ public function execute(OutputInterface $output = null): void $output?->writeln("Done"); } - protected function getMetricAttributes(): ResourceCursor + protected function getMetricAttributes(): ResourceCursorInterface { $search = (new SearchBuilder())->addFilter('type', 'IN', ['pim_catalog_metric']); diff --git a/Job/RunSlackMessage.php b/Job/RunSlackMessage.php index 4f8c454..e51f5fa 100644 --- a/Job/RunSlackMessage.php +++ b/Job/RunSlackMessage.php @@ -97,23 +97,26 @@ protected function getMessage(): string */ protected function send(string $message): string { + $config = [ + 'api' => $this->helperData->getGeneralConfig('api'), + 'token' => $this->helperData->getGeneralConfig('token'), + 'channel' => $this->helperData->getGeneralConfig('channel'), + 'username' => $this->helperData->getGeneralConfig('username') + ]; + try { - $slackApi = $this->helperData->getGeneralConfig('api'); - $this->client->request('POST', $slackApi, [ - 'form_params' => [ - 'token' => $this->helperData->getGeneralConfig('token'), - 'channel' => $this->helperData->getGeneralConfig('channel'), - 'text' => $message, - 'username' => $this->helperData->getGeneralConfig('username') - ]]); + $this->client->request('POST', $config['api'], ['form_params' => [ + 'token' => $config['token'], + 'channel' => $config['channel'], + 'text' => $message, + 'username' => $config['username'] + ]]); - return '✅ Message has been send to Slack channel: ' - . $this->helperData->getGeneralConfig('channel') . ''; + return "✅ Message sent to Slack channel: {$config['channel']}"; } catch (RequestException $e) { - return '⚠️ There\'s a problem with sending the message to Slack channel: ' - . $this->helperData->getGeneralConfig('channel') . " \n\n" - . 'The following exception appeared:' - . '' . "\n\n" . $e->getResponse() . ''; + $response = $e->getResponse() ? $e->getResponse()->getBody() : 'No response body'; + return "⚠️ Problem sending message to Slack channel: {$config['channel']}\n\n" + . "Exception:\n{$response}"; } } } diff --git a/Plugin/CheckWebsiteAssociation.php b/Plugin/CheckWebsiteAssociation.php index c0bf87c..f4e963f 100644 --- a/Plugin/CheckWebsiteAssociation.php +++ b/Plugin/CheckWebsiteAssociation.php @@ -44,9 +44,7 @@ public function beforeSetWebsites(Product $subject): array ); /** @var Mysql $query */ $query = $connection->query($select); - /** @var array $row */ while (($row = $query->fetch())) { - if(!isset($row[$websiteAssociation])) { continue; } diff --git a/Plugin/Helper/Import/Product.php b/Plugin/Helper/Import/Product.php index f7490a8..4be9eb0 100644 --- a/Plugin/Helper/Import/Product.php +++ b/Plugin/Helper/Import/Product.php @@ -31,7 +31,7 @@ public function beforeCreateTmpTableFromApi( $this->codes = explode(',', (string)$this->config->getValue('akeneo_connector/justbetter/important_attributes')); } - if (!(is_countable($this->codes) ? count($this->codes) : 0)) { + if (!count($this->codes)) { return [$result, $tableSuffix, $family]; } diff --git a/Plugin/SetTaxClassId.php b/Plugin/SetTaxClassId.php index 00322cc..50a88ea 100644 --- a/Plugin/SetTaxClassId.php +++ b/Plugin/SetTaxClassId.php @@ -106,11 +106,12 @@ public function createQuery(string $taxIdColumn, string $tableName): string /** * Add the switch case to the query. */ - public function addCase(string $query, string $taxIdColumn): string + public function addCase(string $query, string $taxIdColumn): ?string { if (!($mappings = $this->scopeConfig->getValue('akeneo_connector/product/tax_id_mapping'))) { - return; + return null; } + $mappings = $this->serializer->unserialize($mappings); if (!(is_countable($mappings) ? count($mappings) : 0)) { diff --git a/composer.json b/composer.json index d10b528..ded7273 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,8 @@ "description": "Magento2 bundle for extending the Akeneo connector with awesome features.", "require": { "php": ">=8.2", - "akeneo/module-magento2-connector-community": "*" + "akeneo/module-magento2-connector-community": "^104.3.12", + "ext-intl": "*" }, "require-dev": { "bitexpert/phpstan-magento": "^0.11.0", diff --git a/phpstan.neon b/phpstan.neon index d5ab6f2..d0483a7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,7 +5,7 @@ parameters: - . excludePaths: - vendor - level: 1 + level: 4 ignoreErrors: - '#Magento\\Backend\\Model\\View\\Result\\ForwardFactory#' - '#Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\CollectionFactory#' From 60bebaccc005f80793e47e592c28db7409664c4b Mon Sep 17 00:00:00 2001 From: Claudio Ferraro Date: Mon, 16 Sep 2024 08:51:21 +0200 Subject: [PATCH 2/3] Import class --- Controller/Adminhtml/Akeneo/Save.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Controller/Adminhtml/Akeneo/Save.php b/Controller/Adminhtml/Akeneo/Save.php index 6b7bd78..7a0fa1e 100755 --- a/Controller/Adminhtml/Akeneo/Save.php +++ b/Controller/Adminhtml/Akeneo/Save.php @@ -4,6 +4,7 @@ use JustBetter\AkeneoBundle\Model\Akeneo; use Magento\Backend\App\Action; +use Magento\Backend\Model\Session; use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; @@ -39,7 +40,7 @@ public function execute(): ResultInterface try { $model->save(); $this->messageManager->addSuccess(__('The Akeneo has been saved.')); - $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false); + $this->_objectManager->get(Session::class)->setFormData(false); if ($request->getParam('back')) { return $resultRedirect->setPath('*/*/edit', ['id' => $model->getId(), '_current' => true]); } From ff9c62a2df60229ce68b488db8ca93128d485339 Mon Sep 17 00:00:00 2001 From: Claudio Ferraro Date: Mon, 16 Sep 2024 10:53:43 +0200 Subject: [PATCH 3/3] Return query --- Plugin/SetTaxClassId.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin/SetTaxClassId.php b/Plugin/SetTaxClassId.php index 50a88ea..c04175d 100644 --- a/Plugin/SetTaxClassId.php +++ b/Plugin/SetTaxClassId.php @@ -109,7 +109,7 @@ public function createQuery(string $taxIdColumn, string $tableName): string public function addCase(string $query, string $taxIdColumn): ?string { if (!($mappings = $this->scopeConfig->getValue('akeneo_connector/product/tax_id_mapping'))) { - return null; + return $query; } $mappings = $this->serializer->unserialize($mappings);