magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Can not import table rates when condition is set in the global scope #22142

Closed leabaertschi closed 5 years ago

leabaertschi commented 5 years ago

Preconditions (*)

  1. Magento 2.3.1, the system was upgraded from Magento 2.2.6
  2. PHP 7.2.10
  3. MySQL 5.7.23
  4. Mac OS 10.14.3
  5. Apache 2.2.34
  6. The application config is dumped to app/etc/config.php

Steps to reproduce (*)

  1. Activate tablerate shipping method
  2. Set condition to 'Weight vs. Destination' in the global scope and save
  3. Change to the website scope of the configuration
  4. Upload a tablerate.csv file
  5. You get an error that something went wrong
  6. To be able to import the file I had to uncheck the 'standard value' checkbox for the condition and save the config in website scope before importing the file

Expected result (*)

  1. I'm able to import a tablerate.csv file in the website scope, when the shipping method is correctly configured in global scope

Actual result (*)

  1. In the exception.log I got the following error message:
    main.CRITICAL: The "condition_name_short: " code type for Table Rate is incorrect. Verify the type and try again. {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): The \"condition_name_short: \" code type for Table Rate is incorrect. Verify the type and try again. at vendor/magento/module-offline-shipping/Model/Carrier/Tablerate.php:252)"} []
m2-assistant[bot] commented 5 years ago

Hi @leahaense. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@leahaense do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

leabaertschi commented 5 years ago

@magento-engcom-team give me 2.3.1 instance

magento-engcom-team commented 5 years ago

Hi @leahaense. Thank you for your request. I'm working on Magento 2.3.1 instance for you

magento-engcom-team commented 5 years ago

Hi @leahaense, here is your Magento instance. Admin access: https://i-22142-2-3-1.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

leabaertschi commented 5 years ago

The issue is not reproducible on a vanilla Magento 2.3.1 instance.

m2-assistant[bot] commented 5 years ago

Hi @engcom-backlog-nazar. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

ghost commented 5 years ago

Hi @leahaense thank you for you report, i'm not able to reproduce following steps you described on clean magento 2.3-develop, seems like problem related to your configuration , or wrong data in csv file.

leabaertschi commented 5 years ago

Hi @engcom-backlog-nazar, definitely not the csv file, since I was able to import it after changing the configuration in website scope, as described in the issue. I was thinking that maybe it was caused due to something going wrong during the upgrade from version 2.2.6, or due to the app:config:dump, app:config:import messing something up. If I have time I will try to reproduce it with a clean 2.2.x with upgrade to 2.3.1 with dumped config.

ghost commented 5 years ago

@leahaense i think this related to app:config:dump, app:config:import error that you have, says that condition_name_short is the key of value but we need value, so i think this related to wrong config data array.

ghost commented 5 years ago

@leahaense found! you have condition_name_short: must be condition_name_short

leabaertschi commented 5 years ago

@engcom-backlog-nazar the : is just in the exception error message coming from the file mentioned in the comment, which is Magento core. The issue seems to be, that it does not find the condition name in the config when fetching it from the default config scope here: https://github.com/magento/magento2/blob/0eb8677b0b4e35606032e856cc1ef7c80e68829f/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php#L307 The result of this function is NULL.

ghost commented 5 years ago

@leahaense hmm... this may be related to app:config:import

giacmir commented 5 years ago

I'm having the same issue after upgrading from 2.2.6 to 2.3.1. My config is also dumped in config.php. Probably this issue should be reopened. It's an upgrade issue or something related to app:config:dump not reproducible with simple checks.

akosglue commented 4 years ago

so it is closed, but what is the solution for this problem?

byjujohn commented 4 years ago

@giacmir I managed to import it after removing the below entries from the app/etc/config.php file temporarily. Please note that there are two set of entries for the tablerate remove both.

'carriers' => [
    'tablerate' => [
        //....
    ]
]

Then do a cache clean - php bin/magento cache:clean. Now if you try to import it, this should work.

AndresAndreev commented 4 years ago

I had the same problem on Magento 2.2.8. I can confirm that the issue is related to app:config:dump / app:config:import. When I removed the default tablerate configurations in config.php file, as @byjujohn suggested, I managed to import the csv file.

slackerzz commented 4 years ago

Magento 2.3.4 on Magento Cloud and this bug is still present

dcarl-dotsource commented 2 years ago

The issue seems to be located at https://github.com/magento/magento2/blob/cd826aa2215e19d543a3a606aebde18fa3e40d4e/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php#L309-L313 The config path groups/tablerate/fields/condition_name is never set in the object in case it was read from etc/config.php.

I think the config should be read via ScopeConfigInterface instead.