User Tools

Site Tools


urapidflow:v3:i18n

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

urapidflow:v3:i18n [2017/05/19 19:08] (current)
Line 1: Line 1:
 +====== uRapidFlow i18n ======
  
 +If you're working in multilanguage environment, and running uRapidFlow scripts from cron or command line interface, Magento might not set the correct default language before importing or exporting your profiles, and as result the files will have troubles to be imported/exported.
 +
 +Add these few lines to make sure your uRapidFlow profile runs with the correct language:
 +
 +<file php urapidflow.php>
 +<?php
 +
 +// initialize Magento environment
 +
 +try {
 +//    if you move this file, adjust bootstrap.php path
 +    require __DIR__ . '/app/bootstrap.php';
 +} catch (\Exception $e) {
 +    echo <<<HTML
 +{$e->getMessage()}
 +</div>
 +HTML;
 +    exit(1);
 +}
 +
 +$params = $_SERVER;
 +$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'admin'; // change this to appropriate store if needed.
 +$params[\Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM] = true;
 +$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); // bootstrap
 +
 +/** @var \Magento\Framework\App\Http $app */
 +$app = $bootstrap->createApplication('Magento\Framework\App\Http');
 +
 +// configure environment
 +$om = $bootstrap->getObjectManager();
 +$areaList = $om->get('Magento\Framework\App\AreaList');
 +$areaCode = $areaList->getCodeByFrontName('admin');
 +/** @var \Magento\Framework\App\State $state */
 +$state = $om->get('Magento\Framework\App\State');
 +$state->setAreaCode($areaCode);
 +/** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
 +$configLoader = $om->get('Magento\Framework\ObjectManager\ConfigLoaderInterface');
 +$om->configure($configLoader->load($areaCode));
 +
 +// initialize your language
 +/** @var Magento\Framework\Locale\ResolverInterface $localeResolver */
 +$localeResolver = $om->get('Magento\Framework\Locale\ResolverInterface');
 +$locale = 'nl_NL';
 +$oldLocale = $localeResolver->getLocale();
 +$localeResolver->setLocale($locale);
 +$localeResolver->setLocale($oldLocale);
 +
 +/** @var \Unirgy\RapidFlow\Helper\Data $helper */
 +$helper = $om->get(\Unirgy\RapidFlow\Helper\Data::class);
 + 
 +// run profile using name:
 +$helper->run("Import Products - nl_NL profile");
 +</file>
urapidflow/v3/i18n.txt · (external edit)