akeneo / magento2-connector-community

Akeneo Connector for Magento 2
Open Software License 3.0
85 stars 89 forks source link

Admin locale is taken from general magento store configuration what is highly unintuitive #78

Open bartoszkubicki opened 4 years ago

bartoszkubicki commented 4 years ago

Environment and configuration

  1. Akeno connector 100.2.4
  2. Magento Open Source 2.3.3

Steps to reproduce

  1. Configure Magento store language in any language you need, for example pl_PL. Admin language is by default english.
  2. Enter connector configuration
  3. Choose channel mapped as admin, and to produce problem it shouldn't have locale pl_PL. You can set it to have en_US locale, because it seem fair for admin values.
  4. Run for example product import

Expected result

  1. It should be added new configuration field for akeneo connector, when you explicitly choose locale for admin channel, from which default/admin values are imported. Then, we you get error that chosen locale is not available for this channel, you can easily figure out situation. You have just chosen locale, being aware that there is a configuration is responsible for this.

Actual result

  1. You get error that there is no locale pl_PL mapped in admin channel.
  2. You are confused. You have chosen admin channel in module configuration, but why pl_PL is seeked? No idea. There is no field reposonsible for this.
  3. You ended up debbuging to figure out how to configure module to properly import values.
rbouma commented 1 year ago

Magento 2.4.6-p2 Akeneo connector v104.0.3

We experienced same problem today. This is due this line for attribute en option import job > https://github.com/akeneo/magento2-connector-community/blob/f8cf0d2a6285bc7ba2f191de97197e9df47cf4f8/Job/Option.php#L270

This gets the default locale from the database via the scopeConfig with scope 'store' in https://github.com/akeneo/magento2-connector-community/blob/f8cf0d2a6285bc7ba2f191de97197e9df47cf4f8/Helper/Config.php#L1144-L1151

We did not a deep dive in the store resolving of Magento but this is what we think the problem is and what we fixed to get it working for our side:

our assumption what is causing this issue is due to because no $storeId is given as argument to the getDefaultLocale function it tries to get the first available store which != store 0 and initiate this store to be used as default store but the language of the actual admin store can be different then the first store.

so we changed this line https://github.com/akeneo/magento2-connector-community/blob/f8cf0d2a6285bc7ba2f191de97197e9df47cf4f8/Helper/Config.php#L1144 to

public function getDefaultLocale($storeId = 0)

so it will always load default admin store 0 instead of the first available store that is not the default store.

we get it working.

We don't know if this is a bug in Akeneo connector or in Magento but we don't have enough time to figure this one out completely to the bottom so hope it will give other users to the right direction for a complete answer.