akeneo / magento2-connector-community

Akeneo Connector for Magento 2
Open Software License 3.0
81 stars 88 forks source link

Product import throws undefined method call and swatch attribute SQL error #636

Open jesseihatsu opened 1 year ago

jesseihatsu commented 1 year ago

Environment and configuration

  1. Magento 2.4.4-p3
  2. akeneo/module-magento2-connector-community 103.4.0
  3. akeneo/api-php-client v10.0.0

Steps to reproduce

  1. Create test products in Akeneo (if testing the swatch issue: do not add swatch attributes to products)
  2. Start product import job

Expected result

  1. Product Models are loaded from API.
  2. Product swatch attributes are updated correctly.
  3. Products are imported successfully.

Actual result

  1. Import throws critical error and freezes in "processing" state.

Exception thrown:

[2023-03-29T09:44:03.184275+00:00] main.CRITICAL: Error: Call to undefined method Akeneo\Pim\ApiClient\AkeneoPimClient::listPerPage() in /var/www/vendor/akeneo/module-magento2-connector-community/Job/Product.php:520
Stack trace:
#0 /var/www/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(556): Akeneo\Connector\Job\Product->createTable()
#1 /var/www/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(451): Akeneo\Connector\Executor\JobExecutor->executeStep()
#2 /var/www/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(349): Akeneo\Connector\Executor\JobExecutor->run()
#3 /var/www/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(283): Akeneo\Connector\Executor\JobExecutor->execute()
#4 /var/www/vendor/akeneo/module-magento2-connector-community/Cron/LaunchScheduledJob.php(68): Akeneo\Connector\Executor\JobExecutor->execute()
#5 [internal function]: Akeneo\Connector\Cron\LaunchScheduledJob->execute()
#6 /var/www/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(368): call_user_func_array()
#7 /var/www/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(879): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob()
#8 /var/www/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(840): Magento\Cron\Observer\ProcessCronQueueObserver->tryRunJob()
#9 /var/www/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(280): Magento\Cron\Observer\ProcessCronQueueObserver->processPendingJobs()
#10 /var/www/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute()
#11 /var/www/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
#12 /var/www/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
#13 /var/www/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()
#14 /var/www/vendor/magento/framework/App/Cron.php(86): Magento\Framework\Event\Manager\Proxy->dispatch()
#15 /var/www/vendor/magento/module-cron/Console/Command/CronCommand.php(117): Magento\Framework\App\Cron->launch()
#16 /var/www/vendor/symfony/console/Command/Command.php(255): Magento\Cron\Console\Command\CronCommand->execute()
#17 /var/www/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run()
#18 /var/www/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent()
#19 /var/www/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}()
#20 /var/www/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(23): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins()
#21 /var/www/vendor/symfony/console/Application.php(1021): Magento\Cron\Console\Command\CronCommand\Interceptor->run()
#22 /var/www/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#23 /var/www/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun()
#24 /var/www/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()
#25 /var/www/bin/magento(23): Symfony\Component\Console\Application->run()
#26 {main}

This seems to be related to this change: https://github.com/akeneo/magento2-connector-community/commit/79987940ca1288474de34066b1815a71aaae4169#diff-f95e6e2026b743b405c1eeb4b97e5e70a3cccbd4aee0751917084fc21eff6597L465

This change seems to fix the problem:

- $productModels = $akeneoClient->listPerPage(1, false, $filter);
+ $productModels = $akeneoClient->getProductModelApi()->listPerPage(1, false, $filter);
  1. Import tries to insert empty product swatch attributes and throws SQL error. Job state is updated to "error".

SQL error:

SQLSTATE[23000]: Integrity constraint violation:
1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`eav_attribute_option_swatch`, CONSTRAINT `EAV_ATTR_OPT_SWATCH_OPT_ID_EAV_ATTR_OPT_OPT_ID` FOREIGN KEY (`option_id`) REFERENCES `eav_attribute_option` (`option_id`) ON DELETE CASCADE)

Query was: INSERT INTO `eav_attribute_option_swatch` () VALUES () ON DUPLICATE KEY UPDATE `option_id` = VALUES(`option_id`), `store_id` = VALUES(`store_id`), `type` = VALUES(`type`), `value` = VALUES(`value`)

This seems to be related to this change: https://github.com/akeneo/magento2-connector-community/commit/2c83b6d82a23f758799066d2d8470b704387bd98#diff-69e28a83d9932901ad9f81bb89bf5035c0208ae0197b3b8008c156d3a4bb5d84

We do not use swatches so we commented the new $this->insertSwatchOption(); call in \Akeneo\Connector\Job\Option::insertValues on row 496

yutv commented 1 year ago

The issue still remains in the akeneo/module-magento2-connector-community 103.4.1.

jurvi commented 1 year ago

Just bumped into this as well, kind of unbelievable that such a breaking change has gone through A) review and B) testing. One can easily see from just glancing through that commit that something ain't right with that change.

jesseihatsu commented 1 year ago

We downgraded back to version 103.2.1 which seems to work correctly. We found more issues with the latest versions.

jurvi commented 1 year ago

Author

Yah I had to revert the importMedia as well, it was insanely slow now. I can't believe they have actually released broken crap like this.

xturavaina commented 1 year ago

Exact same problem with bitnami magento 2.4.6 docker, connector 103.4.1 and akeneo CE 6.0.37. looks like this method does not exist in our community versions :-(

[2023-04-05T17:51:17.701799+00:00] main.CRITICAL: Error: Call to undefined method Akeneo\Pim\ApiClient\AkeneoPimClient::listPerPage() in /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Job/Product.php:520 Stack trace:

0 /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(556): Akeneo\Connector\Job\Product->createTable()

1 /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(451): Akeneo\Connector\Executor\JobExecutor->executeStep()

2 /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(349): Akeneo\Connector\Executor\JobExecutor->run()

3 /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Executor/JobExecutor.php(283): Akeneo\Connector\Executor\JobExecutor->execute()

4 /bitnami/magento/vendor/akeneo/module-magento2-connector-community/Cron/LaunchScheduledJob.php(68): Akeneo\Connector\Executor\JobExecutor->execute()

5 [internal function]: Akeneo\Connector\Cron\LaunchScheduledJob->execute()

6 /bitnami/magento/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(368): call_user_func_array()

7 /bitnami/magento/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(879): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob()

8 /bitnami/magento/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(840): Magento\Cron\Observer\ProcessCronQueueObserver->tryRunJob()

9 /bitnami/magento/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(280): Magento\Cron\Observer\ProcessCronQueueObserver->processPendingJobs()

10 /bitnami/magento/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute()

11 /bitnami/magento/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()

12 /bitnami/magento/vendor/magento/framework/Event/Manager.php(65): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()

13 /bitnami/magento/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()

14 /bitnami/magento/vendor/magento/framework/App/Cron.php(86): Magento\Framework\Event\Manager\Proxy->dispatch()

15 /bitnami/magento/vendor/magento/module-cron/Console/Command/CronCommand.php(126): Magento\Framework\App\Cron->launch()

16 /bitnami/magento/vendor/symfony/console/Command/Command.php(298): Magento\Cron\Console\Command\CronCommand->execute()

17 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run()

18 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent()

19 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception{closure}()

20 /bitnami/magento/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(77): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins()

21 /bitnami/magento/vendor/symfony/console/Application.php(1040): Magento\Cron\Console\Command\CronCommand\Interceptor->run()

22 /bitnami/magento/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()

23 /bitnami/magento/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun()

24 /bitnami/magento/vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun()

25 /bitnami/magento/bin/magento(23): Symfony\Component\Console\Application->run()

26 {main}

andrew-smart commented 1 year ago

This is still an issue on 103.4.3

cengizcoskun commented 1 year ago

103.5.0..