Автор Тема: Смена магазина через смену языка!!!  (Прочитано 969 раз)

28 Июль 2021, 15:27:44
  • Новичок
  • *
  • Сообщений: 24
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Добрый день.
Вопрос состоит в том что я нашёл как изменить смену языка на смену мульти магазина.
override\modules\ps_languageselector\ps_languageselector.php
<?php

use PrestaShop\PrestaShop\Core\Module\WidgetInterface;

if (!
defined('_PS_VERSION_'))
exit;

class 
Ps_LanguageselectorOverride extends Ps_Languageselector implements WidgetInterface
{

public function install()
{
if (!parent::install() || !$this->registerHook('XXXXXX'))
  return false;
return true;
}

public function getWidgetVariables($hookName null, array $configuration = [])
{
$id_shop = (int)$this->context->shop->id;
$id_group = (int)$this->context->shop->id_shop_group;
$shop = new Shop($id_shop);
$shopsList $shop::getShops(false$id_group);

foreach ($shopsList as $index => $currShop) {
$shopsList[$index]['lang'] = Language::getLanguages(true$currShop['id_shop'])[0];
}

return array(
'shopsGroup' => $shopsList,
'currentShop' => $id_shop
);
}

public function hookDisplayXXXXXX($params)
{
$shopsList $this->getWidgetVariables();

if (count($shopsList['shopsGroup'])) {
$this->smarty->assign($shopsList);
return $this->fetch('module:ps_languageselector/ps_languageselector.tpl');
    }

    return 
false;
}

}
themes\шаблон\modules\ps_languageselector\ps_languageselector.tpl
<div id="mod-ps-languageselector">
  <h4>{l s='Language:' d='Shop.Theme.Global'}</h4>
  {if isset($shopsGroup)}
    {foreach from=$shopsGroup item=shop}
      <a href="http://{$shop.domain}" class="{if $shop.id_shop == $currentShop}active{/if}">
        {if isset($shop.lang.id_lang)}
          <img src="/img/l/{$shop.lang.id_lang}.jpg" alt="{$shop.lang.language_code}" title="{$shop.lang.name}" />
        {else}
          <img src="/img/l/none.jpg" alt="Flag no found">
        {/if}
      </a>
    {/foreach}
  {/if}
</div>
Ошибки которые я получаю
ClassNotFoundException
Attempted to load class "Ps_Languageselector" from the global namespace.
Did you forget a "use" statement?

in ps_languageselector.php line 32
at include_once()
in Module.php line 1149
at ModuleCore::coreLoadModule('ps_languageselector')
in Module.php line 1141
at ModuleCore::getInstanceByName('ps_languageselector')
in Hook.php line 904
at HookCore::exec('displayNav2', array('smarty' => object(SmartyDevTemplate), 'cookie' => object(Cookie), 'cart' => object(Cart)), null)
in smarty.config.inc.php line 167
at smartyHook(array('h' => 'displayNav2'), object(SmartyDevTemplate))
in SmartyLazyRegister.php line 83
at SmartyLazyRegister->__call('smartyHook', array(array('h' => 'displayNav2'), object(SmartyDevTemplate)))
in 5119a404af0f0ee0f157711045fe082ce70b6d5c_2.file.header.tpl.php line 289
at Block_28805275261013c67185ff7_49984770->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_28805275261013c67185ff7_49984770), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_28805275261013c67185ff7_49984770))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_28805275261013c67185ff7_49984770', 'header_nav')
in 5119a404af0f0ee0f157711045fe082ce70b6d5c_2.file.header.tpl.php line 61
at content_61013c6719ec96_13009670(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('file:_partials/header.tpl', null, 'ZOneThemelayouts/layout-left-column.tpl', 0, 31536000, array(), 0, false)
in b433b987b2d5bc172c754e0a6ecd0bf83c5e83ea_2.file.layout-both-columns.tpl.php line 239
at Block_63363597961013c670b5850_48316596->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_63363597961013c670b5850_48316596), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_63363597961013c670b5850_48316596))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_63363597961013c670b5850_48316596', 'header')
in b433b987b2d5bc172c754e0a6ecd0bf83c5e83ea_2.file.layout-both-columns.tpl.php line 73
at content_61013c670d49b1_19690209(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-both-columns.tpl', null, 'ZOneThemelayouts/layout-left-column.tpl', 0, 31536000, array(), 2, false, null, null)
in smarty_internal_runtime_inheritance.php line 116
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-both-columns.tpl')
in 6a80d54a30a4be6de58b5e5c25abc6218f86cb51_2.file.layout-left-column.tpl.php line 33
at content_61013c6709c564_99544899(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-left-column.tpl', null, 'ZOneThemelayouts/layout-left-column.tpl', 0, 31536000, array(), 2, false, null, null)
in smarty_internal_runtime_inheritance.php line 116
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-left-column.tpl')
in d27ad6902793c077a45ec9ade3843b92654813ff_2.file.index.tpl.php line 43
at content_61013c67063df1_40195964(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render(false, 0)
in smarty_internal_templatebase.php line 232
at Smarty_Internal_TemplateBase->_execute(object(SmartyDevTemplate), null, 'ZOneThemelayouts/layout-left-column.tpl', null, 0)
in smarty_internal_templatebase.php line 116
at Smarty_Internal_TemplateBase->fetch('index.tpl', null, 'ZOneThemelayouts/layout-left-column.tpl', null, false, true, false)
in SmartyDev.php line 40
at SmartyDev->fetch('index.tpl', null, 'ZOneThemelayouts/layout-left-column.tpl')
in FrontController.php line 704
at FrontControllerCore->smartyOutputContent('index.tpl')
in FrontController.php line 686
at FrontControllerCore->display()
in Controller.php line 326
at ControllerCore->run()
in Dispatcher.php line 518
at DispatcherCore->dispatch()
in index.php line 28
я понимаю что xxxxx это хук.
Может кто подскажет?
28 Июль 2021, 16:24:38
Ответ #1
  • Ветеран
  • *****
  • Сообщений: 1614
  • Репутация: +32/-1
  • Сообщество PrestaShop
    • Просмотр профиля
Хук в который устаналивается модуль изменить нужно.
У вас в модуле $this->registerHook('XXXXXX')
А в ошибке HookCore::exec('displayNav2'
28 Июль 2021, 16:30:45
Ответ #2
  • Ветеран
  • *****
  • Сообщений: 16670
  • Репутация: +14630/-5
  • Сообщество PrestaShop
    • Просмотр профиля
С override у модулей постоянные проблемы. Лучше клонировать или переделать сам модуль.
28 Июль 2021, 18:05:13
Ответ #3
  • Новичок
  • *
  • Сообщений: 24
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
С override у модулей постоянные проблемы. Лучше клонировать или переделать сам модуль.
Можно подробней как клонировать модуль? у меня в папку override вообще нет ps_languageselector
28 Июль 2021, 18:12:54
Ответ #4
  • Новичок
  • *
  • Сообщений: 24
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Хук в который устаналивается модуль изменить нужно.
У вас в модуле $this->registerHook('XXXXXX')
А в ошибке HookCore::exec('displayNav2'
Изменил на
public function install()
{
if (!parent::install() || !$this->registerHook('displayNav2'))
  return false;
return true;
}
}

public function hookDisplaydisplayNav2($params)
{
ошибка не изменилась. кэш чистил.
Может еще предложения?? Пожалуйста
28 Июль 2021, 22:35:09
Ответ #5
  • Ветеран
  • *****
  • Сообщений: 16670
  • Репутация: +14630/-5
  • Сообщество PrestaShop
    • Просмотр профиля
С override у модулей постоянные проблемы. Лучше клонировать или переделать сам модуль.
Можно подробней как клонировать модуль? у меня в папку override вообще нет ps_languageselector
Вы писали
Добрый день.
Вопрос состоит в том что я нашёл как изменить смену языка на смену мульти магазина.
override\modules\ps_languageselector\ps_languageselector.php
...
Вы же переопределяете класс модуля.
Измените класс в /modules/ps_languageselector/ps_languageselector.php
Удалите модуль, измените класс, установите.
31 Июль 2021, 20:30:27
Ответ #6
  • Новичок
  • *
  • Сообщений: 24
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Цитировать
Вы же переопределяете класс модуля.
Измените класс в /modules/ps_languageselector/ps_languageselector.php
Удалите модуль, измените класс, установите.
Большое спасибо помогло.
Теперь только дизайн подогнать.
15 Апрель 2022, 14:37:10
Ответ #7
  • Новичок
  • *
  • Сообщений: 1
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Мы когда настраивали интерфейс сайта, добавляли разные формы, не писали сами. Просто интегрировали формы обратной связи и калькуляторы через конструктор форм , который пока бесплатный, так как тестится.