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

Incompatibility with the enterprise edition database (adobe commerce cloud) when receiving a response from the manual category push #87

Open
bonllavier opened this issue Sep 18, 2024 · 1 comment

Comments

@bonllavier
Copy link

Preconditions (*)

1.Adobe commerce cloud 2.4.6 p6, php 8.1.28
2.Meta Extension Version: 1.3.3

Steps to reproduce (*)

  1. Go to admin area > Store > Configuration > Facebook and Instagram > Extension Settings
  2. Go to "manual data sync" section
  3. press button "Push categories to meta"
  4. categories are uploaded correctly, but log file: "/var/log/meta/meta-business-extension.log" is showing a error

Expected result (*)

  1. log file: "/var/log/meta/meta-business-extension.log" not showing errors when manual catalog push is trigger

Actual result (*)

  1. log file: "/var/log/meta/meta-business-extension.log" is showing the following error:

Screenshot_20240918_111912
reporerro324253463432

  1. [2024-09-17T05:00:31.722383+00:00] FBE.INFO: saving product set id for category Accesorios ,id 493 ,storeId 43 and setId 8349883411721373 [] [] [2024-09-17T05:00:31.722923+00:00] FBE.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'entity_id' in 'field list', query was: INSERT INTO catalog_category_entity_varchar (attribute_id, store_id, entity_id, value) VALUES (?, ?, ?, ?) [] [] [2024-09-17T05:00:31.722980+00:00] FBE.ERROR: #0 /app/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(91): Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute(Object(Closure)) #1 /app/vendor/magento/zend-db/library/Zend/Db/Statement.php(313): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array) #2 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #3 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Pdo/Abstract.php(242): Zend_Db_Adapter_Abstract->query('INSERT INTO ca...', Array)
    faced issues during composer require  #4 /app/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(564): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO ca...', Array) #5 /app/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(634): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO ca...', Array)
    Unable to (re?) setup extension #6 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Abstract.php(576): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO ca...', Array) #7 /app/vendor/meta/module-catalog/Model/Category/CategoryUtility/CategoryUtilities.php(392): Zend_Db_Adapter_Abstract->insert('catalog_categor...', Array) #8 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(589): Meta\Catalog\Model\Category\CategoryUtility\CategoryUtilities->saveFBProductSetID(Object(Magento\Catalog\Model\Category\Interceptor), '834988341172137...', 43) #9 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(515): Meta\Catalog\Model\Category\CategoryCollection->processCategoryBatchResponse(Array, Array, 43, 1, 'daily_categorie...', 'magento_66e90ce...') #10 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(372): Meta\Catalog\Model\Category\CategoryCollection->flushCategoryBatchRequest(Array, Array, 1, 'EAACxonUmtyIBO9...', 43, 'daily_categorie...', 'magento_66e90ce...') #11 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(222): Meta\Catalog\Model\Category\CategoryCollection->pushCategoriesToFBCollections(Object(Magento\Catalog\Model\ResourceModel\Category\Collection\Interceptor), 'EAACxonUmtyIBO9...', 43, 'daily_categorie...', 'magento_66e90ce...') #12 /app/vendor/meta/module-catalog/Cron/CategorySyncCron.php(75): Meta\Catalog\Model\Category\CategoryCollection->pushAllCategoriesToFbCollections(43, 'daily_categorie...', 'magento_66e90ce...') #13 [internal function]: Meta\Catalog\Cron\CategorySyncCron->execute(Object(Magento\Cron\Model\Schedule)) #14 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(362): call_user_func_array(Array, Array) #15 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(873): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob(1726549200, 1726549226, Array, Object(Magento\Cron\Model\Schedule), 'facebook_automa...') #16 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(834): Magento\Cron\Observer\ProcessCronQueueObserver->tryRunJob(1726549200, 1726549226, Array, Object(Magento\Cron\Model\Schedule), 'facebook_automa...') #17 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(280): Magento\Cron\Observer\ProcessCronQueueObserver->processPendingJobs('facebook_automa...', Array, 1726549226) #18 /app/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute(Object(Magento\Framework\Event\Observer)) #19 /app/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Cron\Observer\ProcessCronQueueObserver), Object(Magento\Framework\Event\Observer)) #20 /app/vendor/magento/module-staging/Model/Event/Manager.php(97): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer)) #21 /app/generated/code/Magento/Staging/Model/Event/Manager/Proxy.php(95): Magento\Staging\Model\Event\Manager->dispatch('default', Array) #22 /app/vendor/magento/framework/App/Cron.php(86): Magento\Staging\Model\Event\Manager\Proxy->dispatch('default') #23 /app/vendor/magento/module-cron/Console/Command/CronCommand.php(126): Magento\Framework\App\Cron->launch() #24 /app/vendor/symfony/console/Command/Command.php(298): Magento\Cron\Console\Command\CronCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #25 /app/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #26 /app/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent('run', Array) #27 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #28 /app/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(23): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins('run', Array, Array) #29 /app/vendor/symfony/console/Application.php(1040): Magento\Cron\Console\Command\CronCommand\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #30 /app/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Magento\Cron\Console\Command\CronCommand\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #31 /app/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #32 /app/vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #33 /app/bin/magento(23): Symfony\Component\Console\Application->run() #34 {main} [] [] [2024-09-17T05:00:31.723101+00:00] FBE.INFO: saving product set id for category Cuotas 18-24 ,id 505 ,storeId 43 and setId 8425590937529936 [] [] [2024-09-17T05:00:31.723732+00:00] FBE.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'entity_id' in 'field list', query was: INSERT INTO catalog_category_entity_varchar (attribute_id, store_id, entity_id, value) VALUES (?, ?, ?, ?) [] [] [2024-09-17T05:00:31.723811+00:00] FBE.ERROR: #0 /app/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(91): Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute(Object(Closure)) #1 /app/vendor/magento/zend-db/library/Zend/Db/Statement.php(313): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array) #2 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #3 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Pdo/Abstract.php(242): Zend_Db_Adapter_Abstract->query('INSERT INTO ca...', Array)
    faced issues during composer require  #4 /app/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(564): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO ca...', Array) #5 /app/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(634): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO ca...', Array)
    Unable to (re?) setup extension #6 /app/vendor/magento/zend-db/library/Zend/Db/Adapter/Abstract.php(576): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO ca...', Array) #7 /app/vendor/meta/module-catalog/Model/Category/CategoryUtility/CategoryUtilities.php(392): Zend_Db_Adapter_Abstract->insert('catalog_categor...', Array) #8 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(589): Meta\Catalog\Model\Category\CategoryUtility\CategoryUtilities->saveFBProductSetID(Object(Magento\Catalog\Model\Category\Interceptor), '842559093752993...', 43) #9 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(515): Meta\Catalog\Model\Category\CategoryCollection->processCategoryBatchResponse(Array, Array, 43, 1, 'daily_categorie...', 'magento_66e90ce...') #10 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(372): Meta\Catalog\Model\Category\CategoryCollection->flushCategoryBatchRequest(Array, Array, 1, 'EAACxonUmtyIBO9...', 43, 'daily_categorie...', 'magento_66e90ce...') #11 /app/vendor/meta/module-catalog/Model/Category/CategoryCollection.php(222): Meta\Catalog\Model\Category\CategoryCollection->pushCategoriesToFBCollections(Object(Magento\Catalog\Model\ResourceModel\Category\Collection\Interceptor), 'EAACxonUmtyIBO9...', 43, 'daily_categorie...', 'magento_66e90ce...') #12 /app/vendor/meta/module-catalog/Cron/CategorySyncCron.php(75): Meta\Catalog\Model\Category\CategoryCollection->pushAllCategoriesToFbCollections(43, 'daily_categorie...', 'magento_66e90ce...') #13 [internal function]: Meta\Catalog\Cron\CategorySyncCron->execute(Object(Magento\Cron\Model\Schedule)) #14 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(362): call_user_func_array(Array, Array) #15 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(873): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob(1726549200, 1726549226, Array, Object(Magento\Cron\Model\Schedule), 'facebook_automa...') #16 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(834): Magento\Cron\Observer\ProcessCronQueueObserver->tryRunJob(1726549200, 1726549226, Array, Object(Magento\Cron\Model\Schedule), 'facebook_automa...') #17 /app/vendor/magento/module-cron/Observer/ProcessCronQueueObserver.php(280): Magento\Cron\Observer\ProcessCronQueueObserver->processPendingJobs('facebook_automa...', Array, 1726549226) #18 /app/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver->execute(Object(Magento\Framework\Event\Observer)) #19 /app/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Cron\Observer\ProcessCronQueueObserver), Object(Magento\Framework\Event\Observer)) #20 /app/vendor/magento/module-staging/Model/Event/Manager.php(97): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer)) #21 /app/generated/code/Magento/Staging/Model/Event/Manager/Proxy.php(95): Magento\Staging\Model\Event\Manager->dispatch('default', Array) #22 /app/vendor/magento/framework/App/Cron.php(86): Magento\Staging\Model\Event\Manager\Proxy->dispatch('default') #23 /app/vendor/magento/module-cron/Console/Command/CronCommand.php(126): Magento\Framework\App\Cron->launch() #24 /app/vendor/symfony/console/Command/Command.php(298): Magento\Cron\Console\Command\CronCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #25 /app/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #26 /app/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent('run', Array) #27 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #28 /app/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(23): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins('run', Array, Array) #29 /app/vendor/symfony/console/Application.php(1040): Magento\Cron\Console\Command\CronCommand\Interceptor->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #30 /app/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Magento\Cron\Console\Command\CronCommand\Interceptor), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #31 /app/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #32 /app/vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #33 /app/bin/magento(23): Symfony\Component\Console\Application->run() #34 {main} [] []

I have managed to understand a little of the instructions that are declared where the error is being marked, and the code seems to be incompatible with the table structure for Adobe Commerce Cloud or the Enterprise version, since this version has a column with a different name that replaces "entity_id" with "row_id" due to the Content Staging of the Enterprise version. Can I request to review this problem? It is still not clear to me how much of an impact there is by not being able to execute these instructions on Magento.
Screenshot_20240918_114516
Screenshot_20240918_114745

@oleksii-lisovyi
Copy link

oleksii-lisovyi commented Oct 11, 2024

@bonllavier here's a patch of a possible solution:

diff --git a/Model/Category/CategoryUtility/CategoryUtilities.php b/Model/Category/CategoryUtility/CategoryUtilities.php
index 9fd8c9147..741f18418 100644
--- a/Model/Category/CategoryUtility/CategoryUtilities.php
+++ b/Model/Category/CategoryUtility/CategoryUtilities.php
@@ -27,6 +27,7 @@ use Magento\Catalog\Model\ResourceModel\Category\Collection;
 use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
 use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
+use Magento\Framework\EntityManager\MetadataPool;
 use Magento\Framework\Exception\LocalizedException;
 use Magento\Eav\Model\Config as EavConfig;
 use Magento\Framework\App\ResourceConnection;
@@ -93,6 +94,11 @@ class CategoryUtilities
      */
     private ResourceConnection $resourceConnection;
 
+    /**
+     * @var MetadataPool
+     */
+    private MetadataPool $metadataPool;
+
     /**
      * Constructor
      * @param ProductCollectionFactory $productCollectionFactory
@@ -104,6 +110,7 @@ class CategoryUtilities
      * @param CategoryImageService $imageService
      * @param EavConfig $eavConfig
      * @param ResourceConnection $resourceConnection
+     * @param MetadataPool $metadataPool
      */
     public function __construct(
         ProductCollectionFactory    $productCollectionFactory,
@@ -114,7 +121,8 @@ class CategoryUtilities
         ProductIdentifier           $productIdentifier,
         CategoryImageService        $imageService,
         EavConfig                   $eavConfig,
-        ResourceConnection          $resourceConnection
+        ResourceConnection          $resourceConnection,
+        MetadataPool                $metadataPool
     ) {
         $this->categoryCollection = $categoryCollection;
         $this->categoryRepository = $categoryRepository;
@@ -125,6 +133,7 @@ class CategoryUtilities
         $this->imageService = $imageService;
         $this->eavConfig = $eavConfig;
         $this->resourceConnection = $resourceConnection;
+        $this->metadataPool = $metadataPool;
     }
     /**
      * Fetch products for product category
@@ -377,6 +386,7 @@ class CategoryUtilities
                 SystemConfig::META_PRODUCT_SET_ID
             );
             $productSetAttributeId = $productSetAttribute->getAttributeId();
+            $categoryEntityLinkField = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\CategoryInterface::class)->getLinkField();
 
             if ($productSetAttributeId) {
                 $categoryEntityVarcharTable = $this->resourceConnection->getTableName(
@@ -388,7 +398,7 @@ class CategoryUtilities
                         [
                             'attribute_id' => $productSetAttributeId,
                             'store_id' => $storeId,
-                            'entity_id' => $category->getId(),
+                            $categoryEntityLinkField => $category->getId(),
                             'value' => $setId
                         ]
                     );
@@ -398,13 +408,13 @@ class CategoryUtilities
                         [
                             'attribute_id' => $productSetAttributeId,
                             'store_id' => $storeId,
-                            'entity_id' => $category->getId(),
+                            $categoryEntityLinkField => $category->getId(),
                             'value' => $setId
                         ],
                         [
                             'attribute_id = ?' => $productSetAttributeId,
                             'store_id = ?' => $storeId,
-                            'entity_id = ?' => $category->getId(),
+                            \sprintf('%s = ?', $categoryEntityLinkField) => $category->getId(),
                         ]
                     );
                 }

‼️ Please test the patch before attempting to install it on production environment. There is used a best practice for handling Adobe Commerce Staging Content extension which makes this extension not compatible, you should be able to find in other extensions in Magento/Adobe Commerce or other 3rd party extensions.
I highly recommend looking for other usage of \Magento\Framework\EntityManager\EntityMetadataInterface::getLinkField function and its implementation to get a better understanding what the use case is.

[UPDATE] I've tested the patch myself, so for me the solution is working.

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

2 participants