-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8003: Using System Value for Base Currency Results in Config Error. #11809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this plugin is not needed. From what I can see the methods getConfigDefaultCurrencies
and getConfigBaseCurrencies
should behave like getConfigAllowCurrencies
. This method reads the data from the database but then also checks for the value set in the config. In this case it means that you will get all currencies set in the DB but also the default. Does that make sense?
@dmanners correct me, if I'm wrong, but in https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Directory/Model/Currency.php#L348 I see that allowed currencies reads only from DB, and later adds base currency(which indeed reads from db and system config) to allowed currencies array. So, if in admin I'll check 'Use system value' for Allowed Currencies, I'll get only base currency code. |
@nmalevanec with regards to My concern with using the plugin is that this is a bug with the code code but fixing it with a plugin is not that obvious to all developers. If someone is interested in finding out how this code works it seems to be hidden. I would actually love to see the following either been added to
In this way we would cover the database and config values and since both getConfigDefaultCurrencies and getConfigBaseCurrencies are due to return an array it should work with 1 or more currencies. How does that sound? |
@dmanners Well, it's pretty doable. The only thing I'm concerning about(And this is actually one of the initial reasons to move logic into plugin) is Model/Currency already has coupling between objects more than allowed and suppressed warning about this. So adding to it another dependency like Magento\Config\App\Config\Type\System... Well, I'm not sure it's valid scenario. At least previously it wasn't. |
@nmalevanec a very valid point. We could always consider changing the |
@dmanners Done. |
public function __construct( | ||
System $systemConfig, | ||
StoreManagerInterface $storeManager, | ||
ResourceConnection $resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we do not need this if it is never assigned to anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@@ -88,6 +95,7 @@ public function __construct( | |||
\Magento\Framework\Locale\CurrencyInterface $localeCurrency, | |||
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, | |||
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, | |||
CurrencySystemConfig $currencyConfig = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be after the $data
otherwise it will break backwards compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -378,7 +390,8 @@ public function getConfigDefaultCurrencies() | |||
*/ | |||
public function getConfigBaseCurrencies() | |||
{ | |||
$defaultCurrencies = $this->_getResource()->getConfigCurrencies($this, self::XML_PATH_CURRENCY_BASE); | |||
$defaultCurrencies = $this->_getResource()->getConfigCurrencies($this, self::XML_PATH_CURRENCY_BASE) ?: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in the case that you have multiple stores, 1 with a database value and one without. In this case I guess we need to merge the values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Description
Fix for "Using System Value for Base Currency Results in Config Error".
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist