Skip to content

Table prefix not being read correctly #723

@pixiemediaweb

Description

@pixiemediaweb

issue exists in the latest version of the module 105.1.0. Originally found the issue in 104.3.18 so tried upgrading. Below is based on the latest version. So...

Issue: With a table prefix set for my adobe commerce/magento installation in env;

'table_prefix' => 'mg_',

Imports fail with 'table not found', because it is not testing for the table with the prefix.

Traced the issue back to here (maybe deeper too);

<?php

declare(strict_types=1);

namespace Akeneo\Connector\App;

use Magento\Framework\App\ResourceConnection as BaseResourceConnection;

/**
 * @author    Agence Dn'D <contact@dnd.fr>
 * @copyright 2004-present Agence Dn'D
 * @license   https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      https://www.dnd.fr/
 */
class ResourceConnection extends BaseResourceConnection
{

}

This class exists in the module to hand-hold the core resource connection class in to the helper;

namespace Akeneo\Connector\Helper\Import;

use Akeneo\Connector\App\ResourceConnection;
use Akeneo\Connector\Helper\Authenticator;
use Akeneo\Connector\Helper\Config as ConfigHelper;
use Akeneo\Connector\Model\Source\Edition;
use Akeneo\Connector\Model\Source\Engine;
use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
use Akeneo\Pim\ApiClient\Api\ProductApiInterface;
use Akeneo\Pim\ApiClient\Api\ProductUuidApiInterface;
use Akeneo\Pim\ApiClient\Pagination\ResourceCursor;
use Exception;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Model\Product as BaseProductModel;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\DB\Select;
use Magento\Framework\DB\Statement\Pdo\Mysql;
use Zend_Db_Exception;
use Zend_Db_Expr as Expr;
use Zend_Db_Select_Exception;

/**
 * @author    Agence Dn'D <contact@dnd.fr>
 * @copyright 2004-present Agence Dn'D
 * @license   https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      https://www.dnd.fr/
 */
class Entities

In the constructor, $this->connection is defined as $connection->getConnection();

public function __construct(
        ResourceConnection $connection,
        DeploymentConfig $deploymentConfig,
        BaseProductModel $product,
        ConfigHelper $configHelper,
        Authenticator $authenticator
    ) {
        $this->connection       = $connection->getConnection();
        $this->connection       = $connection;
        $this->deploymentConfig = $deploymentConfig;
        $this->configHelper     = $configHelper;
        $this->product          = $product;
        $this->authenticator    = $authenticator;
    }

Where this file is used for import jobs, the table names are called via;

$this->connection->getTableName($tableName);

This ignores the prefix set for the table. You can only retrieve the prefix from the resource - not the connection.

Ie

Magento\Framework\App\ResourceConnection->getTableName('some_table') = 'myprefix_some_table'

Magento\Framework\App\ResourceConnection->getConnection()->getTableName('some_table') = 'some_table'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions