magento / meta-for-magento2

33 stars 19 forks source link

Error after reinstall with version 1.1.1 #13

Closed likearocket closed 1 month ago

likearocket commented 11 months ago

Preconditions (*) 1.Magento 2.4.6-p1 Open Source 2.PHP 8.1 3.Php-business-sdk 15.0.3

Steps to reproduce (*)

  1. Install with command composer require meta/meta-for-magento2 -W
  2. After install run command bin/magento setup:upgrade

Expected result (*)

  1. Command runs as expected.

Actual result (*)

  1. Installs but generates the following error within the SSH window:

Unable to apply data patch Meta\BusinessExtension\Setup\Patch\Data\DeleteLegacyData for module Meta_BusinessExtension. Original exception message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xnjyrekmqf.eav_attribute' doesn't exist, query was: DELETE FROMeav_attributeWHERE (attribute_code = 'facebook_age_group')

likearocket commented 11 months ago

This error continues to show in the SSH each time bin/magento setup:upgrade is executed. Also, even though the extension is installed correctly and setup/connected to our Facebook account successfully, clicking "Push Products/Upload to Meta" fails to add products to our catalog. We're getting the error ({"success":false,"message":"The \"send_to_facebook\" attribute name is invalid. Reset the name and try again."}) push-error

likearocket commented 11 months ago

I believe the error might be where tables have prefixes, as we have had a similar issue with another module and that was the cause. A fix ASAP would be gratefully received.

Jeijnde commented 10 months ago

I ran into the same issue. We also use a table prefix.

The error is caused by calling the getTableName method on the $connection. The table prefix is configured outside of a connection and so the connection won't honor it.

The getTableName method should be called on an instance of \Magento\Framework\App\ResourceConnection instead. Also, in some places the table name is used statically instead of called through getTableName, so that would also not return the table name with the prefix.

Classes that threw this error at me were Meta\BusinessExtension\Setup\Patch\Data\DeleteLegacyData and Meta\Catalog\Setup\Patch\Data\AddCatalogSwitch

likearocket commented 10 months ago

Has this issue been fixed in 1.2.0 that's just been released?

likearocket commented 8 months ago

When is this issue going to be resolved? It's still not fixed over 3 months later!

likearocket commented 7 months ago

@zlik can you investigate this? Issue is still present in the latest version. Because of the code in the patch file, the extension does not uninstall legacy data on tables with a prefix. It then continues to show an error in the cmd window:

Unable to apply data patch Meta\BusinessExtension\Setup\Patch\Data\DeleteLegacyData for module Meta_BusinessExtension. Original exception message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xnjyrekmqf.eav_attribute' doesn't exist, query was: DELETE FROM eav_attribute WHERE (attribute_code = 'facebook_age_group')

garcia110 commented 3 months ago

I have the same problem: Unable to apply data patch Meta\Catalog\Setup\Patch\Data\AddCatalogSwitch for module Meta_Catalog. Original exception message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'example_mani184.core_config_data' doesn't exist, query was: SELECT core_config_data.* FROM core_config_data WHERE (scope_id = 0) AND (path = 'facebook/catalog_management/daily_product_feed')

angelo983 commented 2 months ago

The problem is still present coming from /vendor/meta/module-business-extension/Setup/Patch/Data/DeleteLegacyData.php

    // delete legacy product attributes
    $eavAttributeTable = $connection->getTableName('eav_attribute');
    foreach ($productAttributesToDelete as $attributeCode) {
        $connection->delete($eavAttributeTable, ['attribute_code = ?' => $attributeCode]);
    }

because of

    $connection = $this->moduleDataSetup->getConnection();

not taking into consideration table prefix.