GithubHelp home page GithubHelp logo

Admin version not updated about adyen-magento2 HOT 5 CLOSED

adyen avatar adyen commented on September 16, 2024
Admin version not updated

from adyen-magento2.

Comments (5)

rikterbeek avatar rikterbeek commented on September 16, 2024

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.

pivulic avatar pivulic commented on September 16, 2024

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.

pivulic avatar pivulic commented on September 16, 2024

OR, maybe you just use $context->getVersion()?

from adyen-magento2.

rikterbeek avatar rikterbeek commented on September 16, 2024

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.

pivulic avatar pivulic commented on September 16, 2024

๐Ÿ‘

from adyen-magento2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.