Jump to content

Prestashop 1.5.x - Multistore Smarty Variables


ODM

Recommended Posts

Prestashop 1.5 has a small problem in multistore.

 

This is a good thing to add in your FrontController.php if for example you have 2 different shops with different themes, and you want to access a few multistore smarty variables

 

 

In /classes/controller/FrontController.php find inside public function init() { and add:

 

 // Super Assign Multi Store
 $this->context->smarty->assign(array(
  'ms_id' => $this->context->shop->id, // Shop ID
  'ms_name' => $this->context->shop->name, // Shop Name
  'ms_status' => $this->context->shop->active, // Shop Status
  'ms_theme' => array(
	   'id' => $this->context->shop->id_theme,  // Shop Theme ID
	   'name' => $this->context->shop->theme_name,  // Shop Theme Name
	   'dir' => $this->context->shop->theme_directory // Shop Theme Directory
	   ),
  'ms_domain' => $this->context->shop->domain, // Shop Domain
  'ms_domain_ssl' => $this->context->shop->domain_ssl, // Shop Domain with SSL
  'ms_physical_uri' => $this->context->shop->physical_uri, // Shop Physical URL
  'ms_virtual_uri' => $this->context->shop->virtual_uri, // Shop Virtual URL
 ));

 

and in your templates you can use all $ms_* smarty variables. A 5 minute useful trick

 

Code Free Code Hard !

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hi,

 

use override, it will avoid to lost all after an update of Prestashop :)

 

like this :

 

in /override/classes/controller/FrontController.php

 

<?php
class FrontController extends FrontControllerCore
{

public function init()
{
 parent::init();
 $this->context->smarty->assign(array(
  'ms_id' => $this->context->shop->id, // Shop ID
  'ms_name' => $this->context->shop->name, // Shop Name
  'ms_status' => $this->context->shop->active, // Shop Status
  'ms_theme' => array(
	  'id' => $this->context->shop->id_theme,  // Shop Theme ID
	  'name' => $this->context->shop->theme_name,  // Shop Theme Name
	  'dir' => $this->context->shop->theme_directory // Shop Theme Directory
	  ),
  'ms_domain' => $this->context->shop->domain, // Shop Domain
  'ms_domain_ssl' => $this->context->shop->domain_ssl, // Shop Domain with SSL
  'ms_physical_uri' => $this->context->shop->physical_uri, // Shop Physical URL
  'ms_virtual_uri' => $this->context->shop->virtual_uri, // Shop Virtual URL
 ));
}
}

 

it will avoid to lost all after an update :)

 

enjoy.

  • Like 4
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...