- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Automatic preference activation based on magento version
Hi everybody.
Suggest me please how should I properly fight with magento2 core bugs?
I have my extension which I want to be compatible with different Magento versions.
As an example there is next situation.
In the Magento 2.2.6 there is a bug which affects us reset any password, see:
https://github.com/magento/magento2/pull/19026
https://github.com/magento/magento2/commit/4e883743bec5b14271351c46e043c5f8e109d2b7
I fixed that by adding a preference for several of my clients.
I'd want to add that preference to my released plugin, but I really want it to be activated only if a client has 2.2.6 installed.
And I can't simply use
$this->productMetadata->getVersion();
inside of the preference class, because that class has changed not only one buggy function, it also has sheet of private methods and private parameters used in that function.
I'd want to have something in di.xml, but as I found it wasn't invented.
Maybe someone knows other solution.
Thanks for advise.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Automatic preference activation based on magento version
Hello @plodistov
into di.xml not possible to check Magento 2 version but into plugin class possible to check that thing.
you can write code into plugin class and check version 2.2.6 run your code otherwise use parent,
$objManager = \Magento\Framework\App\ObjectManager::getInstance(); $magentoVersion = $objManager->get('Magento\Framework\App\ProductMetadataInterface'); echo $magentoVersion->getVersion();
by using above code you can get magento 2 version
https://magento.stackexchange.com/questions/134265/magento-2-programmatically-check-magento-version-...
hope it will help you, if work then mark as solution
Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer