Jump to content

Changing the store by changing the language !!!


Recommended Posts

 

Hello. Immediately I apologize for my poor English.

 

I found an article on how to change the language change to change the multi store. my prestashop 1.7.7.1 But I have errors, who can help? or where to look?

article: https://www.prestashop.com/forums/topic/382956-multi-language-store-with-unique-domains-multistore-way/

i don't have override override\modules\ps_languageselector\ps_languageselector.php so i put everything in /modules/ps_languageselector/ps_languageselector.php 

this is how it looks

<?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('displayNav2'))
		  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 hookDisplaydisplayNav2($params)
	{
		$shopsList = $this->getWidgetVariables();

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

    return false;
	}

}

 themes\classic\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>

as in the article.

My mistake on the site.

(1/1) 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 6e578e133ed58d47a69ee7062b6bb5122428d6e7_2.file.header.tpl.php line 81
at Block_3343910586101ad15b33e87_53697865->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_3343910586101ad15b33e87_53697865), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_3343910586101ad15b33e87_53697865))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_3343910586101ad15b33e87_53697865', 'header_nav')
in 6e578e133ed58d47a69ee7062b6bb5122428d6e7_2.file.header.tpl.php line 31
at content_6101ad15b3f561_84992769(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, 'classiclayouts/layout-full-width.tpl', 0, 31536000, array(), 0, false)
in e82d89c22dc120d03bf6a7f5543e8ff56fbae356_2.file.layout-both-columns.tpl.php line 188
at Block_12778859336101ad15ab2483_59246451->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_12778859336101ad15ab2483_59246451), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_12778859336101ad15ab2483_59246451))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_12778859336101ad15ab2483_59246451', 'header')
in e82d89c22dc120d03bf6a7f5543e8ff56fbae356_2.file.layout-both-columns.tpl.php line 62
at content_6101ad15ace019_67500863(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, 'classiclayouts/layout-full-width.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 d67279c1e8169c42112671b957277c41b71cf45f_2.file.layout-full-width.tpl.php line 42
at content_6101ad15a99ce2_15076725(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-full-width.tpl', null, 'classiclayouts/layout-full-width.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-full-width.tpl')
in 10ad1afad3da53f0c9d3801b0f1ca9b3acdb797c_2.file.page.tpl.php line 33
at content_6101ad15a87000_96927155(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('page.tpl', null, 'classiclayouts/layout-full-width.tpl', 0, 31536000, array(), 2, false, null, null)
in smarty_internal_runtime_inheritance.php line 116
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'page.tpl')
in 8b9e5a7b8263849536862e2cbe12fc8157224ed3_2.file.index.tpl.php line 33
at content_6101ad15a2fa48_41477484(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, 'classiclayouts/layout-full-width.tpl', null, 0)
in smarty_internal_templatebase.php line 116
at Smarty_Internal_TemplateBase->fetch('index.tpl', null, 'classiclayouts/layout-full-width.tpl', null, false, true, false)
in SmartyDev.php line 40
at SmartyDev->fetch('index.tpl', null, 'classiclayouts/layout-full-width.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

error in admin

Symfony\Component\Debug\Exception\
ClassNotFoundException
in modules/ps_languageselector/ps_languageselector.php (line 32)
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('displayNav2'))
require_once()
in src/Adapter/Module/ModuleDataProvider.php (line 248)
ModuleDataProvider->PrestaShop\PrestaShop\Adapter\Module\{closure}('ps_languageselector')
in src/Adapter/Module/ModuleDataProvider.php (line 266)
ModuleDataProvider->isModuleMainClassValid('ps_languageselector')
in src/Core/Addon/Module/ModuleRepository.php (line 478)
ModuleRepository->getModule('ps_languageselector', false)
in src/Core/Addon/Module/ModuleRepository.php (line 570)
ModuleRepository->getModulesOnDisk(false)
in src/Core/Addon/Module/ModuleRepository.php (line 213)
ModuleRepository->getFilteredList(object(AddonListFilter))
in src/Core/Addon/Module/ModuleRepository.php (line 611)
ModuleRepository->getInstalledModules()
in src/Core/Addon/Module/ModuleRepository.php (line 621)
ModuleRepository->getInstalledModulesCollection()
in var/cache/dev/ContainerUqcy2y0/getPrestashop_Core_Form_ChoiceProvider_ModuleByNameService.php (line 8)
require('/var/www/www-root/data/www/xx.com/var/cache/dev/ContainerUqcy2y0/getPrestashop_Core_Form_ChoiceProvider_ModuleByNameService.php')
in var/cache/dev/ContainerUqcy2y0/appDevDebugProjectContainer.php (line 2600)
appDevDebugProjectContainer->load('getPrestashop_Core_Form_ChoiceProvider_ModuleByNameService.php')
in var/cache/dev/ContainerUqcy2y0/getForm_Type_Translations_ModifyService.php (line 8)
require('/var/www/www-root/data/www/xx.com/var/cache/dev/ContainerUqcy2y0/getForm_Type_Translations_ModifyService.php')
in var/cache/dev/ContainerUqcy2y0/appDevDebugProjectContainer.php (line 2600)
appDevDebugProjectContainer->load('getForm_Type_Translations_ModifyService.php')
in var/cache/dev/ContainerUqcy2y0/getForm_RegistryService.php (line 117)
appDevDebugProjectContainer->{closure}()
in vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ServiceLocator.php (line 64)
ServiceLocator->get('PrestaShopBundle\\Form\\Admin\\Improve\\International\\Translations\\ModifyTranslationsType')
in vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php (line 64)
DependencyInjectionExtension->getType('PrestaShopBundle\\Form\\Admin\\Improve\\International\\Translations\\ModifyTranslationsType')
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php (line 78)
FormRegistry->getType('PrestaShopBundle\\Form\\Admin\\Improve\\International\\Translations\\ModifyTranslationsType')
in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php (line 74)
FormFactory->createNamedBuilder('form', 'PrestaShopBundle\\Form\\Admin\\Improve\\International\\Translations\\ModifyTranslationsType')
in src/PrestaShopBundle/Form/Admin/Improve/International/Translations/TranslationsSettingsFormHandler.php (line 78)
TranslationsSettingsFormHandler->getForm()
in src/PrestaShopBundle/Controller/Admin/TranslationsController.php (line 104)
TranslationsController->showSettingsAction(object(Request))
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php (line 151)
HttpKernel->handleRaw(object(Request), 1)
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php (line 68)
HttpKernel->handle(object(Request), 1, false)
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php (line 200)
Kernel->handle(object(Request), 1, false)
in admin673fujfr6/index.php (line 82)

Thank you for your help.

Edited by ckiy (see edit history)
Link to comment
Share on other sites

  • 1 year later...

The idea to have a different design ist pretty good as tastes of Nations are quite different.
Take the cremy colors German speaking countries prefer to more colorful designs from non german speaking countries. Just in gerneral.

When selling good as a shop you should have a national base, except you are amazon. The cost is not that large an LTD comes to around 200 with most gimiks. Server plus domain, shop setup about $500. Should you come from shopify that cost is 350 per year. 3 Years later you are out of red and have a national office in a secon country. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...