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

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

Open
jesseihatsu opened this issue Mar 29, 2023 · 7 comments

Comments

@jesseihatsu
Copy link

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: 7998794#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: 2c83b6d#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
Copy link

yutv commented Mar 29, 2023

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

@jurvi
Copy link

jurvi commented Apr 4, 2023

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
Copy link
Author

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

  • The "Since last successful import" update mode does not seem to work correctly as some products that have not been changed in months are synced.
  • All images are imported on every product import which takes a long time and disk space...
  • Image ordering is wrong after import. This is probably caused by changes in 103.3.0 as this issue persisted after downgrading to it. The image mapping seemed to be correct in Magento settings and the documentation does not tell very much so it was just easier to downgrade further to 103.2.1 which we used before last update.

@jurvi
Copy link

jurvi commented Apr 4, 2023

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
Copy link

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}

kevinmeijer97 added a commit to kevinmeijer97/magento2-connector-community that referenced this issue Apr 26, 2023
This fixes the error stated in akeneo#636. The product model api has to be fetched before you can access the listPerPage function.
@andrew-smart
Copy link

This is still an issue on 103.4.3

@cengizcoskun
Copy link

103.5.0..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants