How to get a transfer from another module in PrestaShop?

I have the PrestaShop baseModule module and the baseExtensionModule [n] module group.

So, to avoid redundancy, I would like to reuse the translation from "baseModule" inside others.

I checked Translate :: getModuleTranslation (), and it looks like ModuleCore :: l () makes it impossible to pass the module name and transfer it to the first one.

A workaround you can know for this?

I assume that getting an instance of the baseModule module will be another way to do this - using this l () method instead of the current $ this-> l. How can I get an instance for another module?

0
source share
1 answer

, ajax:

$module_name = 'mymodule';

if (Module::isInstalled($module_name) && Module::isEnabled($module_name))
{
    $mod = Module::getInstanceByName($module_name);

    if (method_exists($mod, 'doSomething'))
        $mod->doSomething();
}

Module::getInstanceByName('mymodule')->l('string'), , .

, $this->l\((.*)\) . Module::getInstanceByName('modulename')->l('') , .

, Module::getInstanceByName('modulename')->l('string1'), $this->l('string1') , .

, , :

public static $l = array();

public function __construct()
{
    ...
    $this->init();
}

public function init()
{
   if (self::isInstalled($this->name)) {
      self::$l = array(
         'string1' => $this->l('string1'),
      );
   }
}

Module::getInstanceByName, .

, .

+1

Source: https://habr.com/ru/post/1688460/


All Articles