NVision-Commerce-Solutions / module-customer-price

Commerce 365 for Magento - Magento 2 Extension - Customer Price Module
https://n.vision/products/commerce-365-for-magento-b2b/
2 stars 4 forks source link

Setup:upgrade fails for version 1.1.3 when using prefixed tables #16

Closed jenskomunikado closed 1 year ago

jenskomunikado commented 1 year ago

After updating to version 1.1.3, running bin/magento setup:upgrade fails because the table "customer_entity_varchar" does not exist when Magento is set up to use prefixed tables.

It is caused by the following function (Setup/Patch/Data/ClearCustomerCurrencyValues.php#25):

    public function apply()
    {
        $attribute = $this->attributeRepository->get(Customer::ENTITY, 'bc_customer_currency');
        $this->resourceConnection->getConnection()
            ->delete(
                'customer_entity_varchar',
                ['attribute_id = ?' => $attribute->getAttributeId()]
            );
    }

which isn't using the \Magento\Framework\App\ResourceConnection::getTableName() function to get the prefixed table name

Fixed by changing the function to the following:

    public function apply()
    {
        $attribute = $this->attributeRepository->get(Customer::ENTITY, 'bc_customer_currency');
        $tableName = $this->resourceConnection->getTableName('customer_entity_varchar');
        $this->resourceConnection->getConnection()
            ->delete(
                $tableName,
                ['attribute_id = ?' => $attribute->getAttributeId()]
            );
    }
TysvdHeuvel commented 1 year ago

Thank you for your input! This will be fixed in the next release.

soloma88 commented 1 year ago

Fixed