Comments (5)
Hi Pablo,
No problem this will make the module better ๐ Yes we need to retrieve it from the module.xml. I did not know how to do it before so that is why it is hardcoded. If you have the solution already you can do of course a Pull Request.
For the regular user this is important as well because this can help us out if there is some need to trouble shoot the customer if he sends in a ticket to our support guys. Sometimes we have seen (in magento 1.x) it is difficult for a merchant to retrieve this if he does not have access to the code.
Regards,
Rik
from adyen-magento2.
Ah, of course.
I'm afraid I don't know how to retrieve the version :( I can only think of a hack, that would be to load the version from the setup_module
database table.
This is an example, that I used from http://magento.stackexchange.com/a/88129/34433, see getStores()
:
namespace Vaimo\NatyConfigSetup\Setup;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Store\Model\ScopeInterface;
class UpgradeData implements UpgradeDataInterface
{
const STORE_TABLE_NAME = 'store';
protected $configFactory;
protected $connection;
protected $resource;
public function __construct(
\Magento\Config\Model\ResourceModel\ConfigFactory $configFactory,
\Magento\Framework\App\ResourceConnection $resource
)
{
$this->configFactory = $configFactory;
$this->resource = $resource;
}
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$stores = $this->getStores();
$config = $this->configFactory->create();
if (version_compare($context->getVersion(), '1.0.0') < 0) {
foreach ($stores as $store) {
switch ($store['code']) {
case 'global':
$locale = 'en_US';
break;
case 'us':
$locale = 'en_US';
break;
case 'uk':
$locale = 'en_GB';
break;
case 'au':
$locale = 'en_AU';
break;
case 'en_ca':
$locale = 'en_CA';
break;
case 'se':
$locale = 'sv_SE';
break;
case 'fr_ca':
$locale = 'fr_FR';
break;
case 'kr':
$locale = 'ko_KR';
break;
case 'cn':
$locale = 'zh_Hans_CN';
break;
default:
$locale = $store['code'] . '_' . $store['name'];
}
$config->saveConfig('general/locale/code', $locale, ScopeInterface::SCOPE_STORES, $store['store_id']);
}
}
}
protected function getConnection()
{
if (!$this->connection) {
$this->connection = $this->resource->getConnection('core_write');
}
return $this->connection;
}
/**
* Manually retrieve store IDs/Codes/Names except for the admin store,
* since we can't use \Magento\Store\Api\StoreRepositoryInterface::getList(),
* since it will return a cached collection of stores,
* since this module is being setup during the same session as Vaimo_NatyStoresSetup is
*/
protected function getStores()
{
$table = $this->resource->getTableName(self::STORE_TABLE_NAME);
$stores = $this->getConnection()->fetchAll('SELECT store_id,code,name FROM ' . $table . ' WHERE store_id <> 0');
return $stores;
}
}
from adyen-magento2.
OR, maybe you just use $context->getVersion()
?
from adyen-magento2.
Hi Pablo,
That is not possible because it has not the context of the installer/updater. What I have done is retrieve the setup_version from the moduleList see commit above. Will be in the next release.
Regards,
Rik
Adyen
from adyen-magento2.
๐
from adyen-magento2.
Related Issues (20)
- Unable to get payment creation date HOT 2
- Firecheckout: Paymethods not rendering when using one step checkout HOT 5
- [ECP-9281] Multiple Shipment failed through API incase of the partial fulfillment with multi captures enabled HOT 2
- [ECP-9289] Gerar Link pay-by-link com opรงรฃo parcelar o pagamento HOT 1
- [ECP-9290] Undocumented breaking change in 9.6.0 HOT 2
- [ECP-9339]Loader freezes and payment methods are not loading HOT 1
- [ECP-9281] Cannot create second capture invoice until webhook responds to first capture invoice HOT 1
- [ECP-9346]$txVariant is null when trying to vault a Google Pay Mastercard HOT 4
- Module compatibility with Upcoming changes to refusal reason HOT 1
- [ECP-9423] Missing configuration for some payment methods, exemple : kcp_creditcard, kcp_payco, kcp_naverpay HOT 5
- [ECP-9327] Magento sending to Adyen the IP of our frontend proxy instead of the IP of the shopper HOT 1
- Klarna Order Status Not Updated HOT 2
- Property with dot in name can't be serialized HOT 4
- Payment method 'oxxo' does not work HOT 2
- [ECP-9444] Klarna payment gets cancelled on paymentDetails endpoint, but then authorised successfully via webhook HOT 1
- GraphQl - Add storeLocale in StoreConfig HOT 1
- Order in pending status if already cancelled HOT 1
- Order status update fails when Merchant reference changes HOT 1
- Race condition may cause the order status to be reverted to pending HOT 9
- Adyen Ideal Payment Options are not visible in Magento 2.4.7-p2 Checkout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adyen-magento2.