Prestashop: [BOOM-4673] Shopping cart multi-store

Created on 22 Aug 2018  Â·  35Comments  Â·  Source: PrestaShop/PrestaShop

This issue has been migrated from the Forge. Read the original ticket here.

Hi !

I have activate multistore with two different themes.

When i add a product in cart in the second shop, the html element .blockcart is well updated but it update also the .blockcart element on the other shop.

If compilation is set on force compilation for each call, it doesn't append. Seems to be a file name cahce problem ?

  • How to reproduce the issue ?

N/A

1.7.2.4 1.7.4.0 1.7.4.1 Bug FO Fixed Minor Modules & Themes Multistore Topwatchers

Most helpful comment

When I have only one store and I install the theme it's ok:

capture d ecran_877

When I am in multistore and install the same theme on the second shop, some modules are not correctly displayed (shopping cart, search bar, menu, block currency and block languages, customer "sign in' link)

capture d ecran_876

Modules are correctly hooked at the same place between the 2 shops

All 35 comments

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Mon, 22 Jan 2018 17:44:10 +0100

Hi Alex,

In BO => CONFIGURE => Advanced Parameters => Multistore in the page edit of the SHOP GROUP did you enabled the option Share orders ?

Because if once this option is enabled the customer's cart will be shared by all shops in this group.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

Hi Khouloud,

Yeah i know those options very well and they are not activated.

The thing is more about templating, total of products and total cart are the right one for both.

The javascript shoppin_cart.js replace content of the block ".blockcart" with the same as the second shop (not the cart informations only the html parts)

If i use same template it works, because tpl is the same.

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Tue, 23 Jan 2018 12:13:49 +0100

Hi Alex,

I did not manage to reproduce the issue with PS 1.7.2.4.
I attached a video record.
Could you please try to clear cache, check and feedback.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

Hi,

You won't because same theme and same shopping-cart.tpl structure, mine are completly different between the two themes.

I'll try to do a video today to show you !

Regards

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Tue, 23 Jan 2018 12:40:25 +0100

Hi Alex,

I checked your issue with others theme and I did not manage to reproduce the issue.
I an other attached a video record.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

Hi !

My video recorder won't work today grrr !

Here are the exacts step :

  • store 1 => theme 1
  • store 2 => theme 2
  • on store 2, I go on a product page, i click on "add to cart" (not the add to cart in the modal, the one on the product page)
  • the modal open to ask if i want to continue shopping or go to cart
  • behind the modal, i can see my header cart icon change by the one of the store 1, but only the templating, the cart content is the good one

This is the ajax execution which replace the content of .blockcart with the wrong one.

I'm gonna try the video again !

 

Regards, Alex

This comment has been migrated from the Forge. Read the original comment here.

I uploaded a video you can see now the thing

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Wed, 24 Jan 2018 15:54:52 +0100

Hi Alex Fasciaux !

Thank you for your report.
We'll first try to reproduce it and we'll come back to you if we need more information.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Wed, 24 Jan 2018 16:51:22 +0100

Hi Alex,

I manage to reproduce the issue with the version PS 1.7.2.4.
We will see how to fix it.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Wed, 24 Jan 2018 16:53:48 +0100

Salut,

Le bug est au niveau le style du block panier.
Les étapes à reproduire :
1-Créer deux boutiques (multistore)
2- Chaque boutique a sa propre thème
3- le style du block panier de la boutique n°2 (ayant un thème n°2 différent de la boutique n°1) change.

PS : les deux cas sont possibles : Si la boutique n°2 avec le thème par défaut classic, alors le style du panier de la boutique n°1 qui change.

Merci!

This comment has been migrated from the Forge. Read the original comment here.

Hi,

Allright, for now i'm gonna design my templates the same way on both store

Regards,

Alex

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ prasanthsd
  • _Created at:_ Sat, 2 Jun 2018 09:41:28 +0200

Hi,

Not sure why this is marked with "Minor" priority. This bug happens completely random and does change many templates across different stores. Even if you turn on force compilation and disable cache for every request it still happens randomly.

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Mon, 4 Jun 2018 11:07:27 +0200

Hi,

The issue is added to our bug roadmap.
There are some major issues to solve before this one.
So, it will probably not solved right now.
But PrestaShop is an open source project, so it can be solved before if someone submits a pull request to solve it.
Thanks for your understanding.

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ prasanthsd
  • _Created at:_ Mon, 4 Jun 2018 11:10:42 +0200

Hi,

Can someone point at which files/direction to look in troubleshooting this? I can try to submit a PR.

is it fixed?

Hi @kratekk,

Sorry not yet.
There are some major issues to solve before this one.
So, it will probably not solved right now.
But PrestaShop is an open source project, so it can be solved before if someone submits a pull request to solve it.
Thanks!

Hi @khouloudbelguith I will try to look at it myself.
Can you tell me in which files this setting can occur?
Which one controller or class can it be?

Hi @kratekk,

You need to debug the issue to find a solution.
If you need help, you can ask on the Forum (https://www.prestashop.com/forums/), Gitter (https://gitter.im/PrestaShop/General) or Stack Overflow (https://stackoverflow.com/questions/tagged/prestashop).
Thanks for your understanding!

Hi @khouloudbelguith I found the solution. Propably :)
The problem occurs when the module's tpl file is not inside in the directory (views/templates):
'modules / name_of_module / views / templates / hook / tplfile.tpl' When it is left alone in the directory: 'modules/ name_of_module / tplfile.tpl'
Then problem occur.

In my case the problem appeared in the module: ps_customtext.
My sollution:
I changed the code line 51 from:
$this->templateFile = 'module:ps_searchbar/ps_searchbar.tpl';
to:
$this->templateFile = 'module:ps_searchbar/views/templates/hook/ps_searchbar.tpl';

and I moved the template files from:
"modules/ps_customtext/ps_customtext.tpl" to: "modules/ps_customtext/views/templates/hook/ps_customtext.tpl"

The same should be make in the module files in the multistore templates.

I'm not sure but the bug can be inside the function: Module :: getTemplatePath.
Have a nice day!

Hi @kratekk,

Thanks for your fix suggestion & thanks for your feedback.

@khouloudbelguith I see that this solution does not bring benefits.
After next clear the cache, the problem returns

The temporary solution of this problem:
Changing of function inside all modules from:

public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId('ps_socialfollow'))) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } return $this->fetch($this->templateFile, $this->getCacheId('ps_socialfollow')); }

to:

public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached('ps_socialfollow.tpl', $this->getCacheId('ps_socialfollow'))) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } return $this->display(__FILE__, 'ps_socialfollow.tpl', $this->getCacheId('ps_socialfollow')); }

Just just the fetch function returns the wrong path.

@kratekk, would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/PrestaShop/tree/develop
Thank you!

@khouloudbelguith No, because it is a temporary solution. Not to the permanent. That's how I managed the need for the moment. Sorry, but I don't have time to analyze it more

Hi, just, please, don't consider it this a "minor" problem,
there are many multishops on prestashop right now, and is better not to update to 1.7.4.x
leave force compile with many visitors online is really "heavy" on a server.

@khouloudbelguith, I agree with @disarci on this. Anyone using multistore will have to use the same theme for each store which does not make sense.

Is it possible to add this on PS 1.7.6 kanban?

Hi,

I manage to reproduce the issue with PS1.7.5.0 with multistore context is enabled.
In the FO, in the second shop, I used another theme, the design is changed, it is displayed like that
image
=> Because the first shop use the Classic theme.
It should be displayed like this
image
@marionf, @colinegin, what do you think can we fix this issue in the PS1.7.6?
Thanks!

@khouloudbelguith
I am not sure to understand what is the problem on your screenshots, you have the same theme for each shop ?

HI @marionf, yes I use the same theme for different Project Prestashop.
In the first screenshot, I use multistore context with a different theme for each shop => the block style is changed => NOK.
In the second picture => I used the same theme with multistore context is disabled => block style is OK.
Thanks!

When I have only one store and I install the theme it's ok:

capture d ecran_877

When I am in multistore and install the same theme on the second shop, some modules are not correctly displayed (shopping cart, search bar, menu, block currency and block languages, customer "sign in' link)

capture d ecran_876

Modules are correctly hooked at the same place between the 2 shops

In my case, I installed the classic theme on various different shops in multistore and all was ok.

I then installed a new theme (purchased from a premium developer / Prestashop partner) on one of my stores. After that, the new theme modules displayed correctly but the modules of my main store with classic theme installed did not display correctly.

Having looked into this a bit further it's ridiculous that this problem still exists, especially in 1.7.5.

I'm working on a 1.7.5 multi-store for a client and each store has it's own child theme using the same parent theme. Each store needs to look different and will not be sharing products, customers, orders etc.

If I override a normal module template file inside each of my child themes, both stores end up using whichever of the theme module files that was last updated and not the one that is within that actual child theme - obviously this is completely unworkable.

To get these modules outputting the correct store specific content I've had to override each module with the solution posted by @kratekk above.

I've got a serious concern that this multi-store is going to have other problems going forwards and that multi-store in 1.7 is not stable enough to consider using it an option for clients.

For anyone interested the overrides I've created for each module so far are…

ps_customtext

class Ps_CustomtextOverride extends Ps_Customtext { public function __construct() { parent::__construct(); $this->templateFile = 'module:ps_customtext/ps_customtext.tpl'; } public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId('ps_customtext'))) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } return $this->display(__FILE__, 'ps_customtext.tpl', $this->getCacheId('ps_customtext')); } }

ps_socialfollow

class Ps_SocialfollowOverride extends Ps_Socialfollow { public function __construct() { parent::__construct(); $this->templateFile = 'module:ps_socialfollow/ps_socialfollow.tpl'; } public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId('ps_socialfollow'))) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } return $this->display(__FILE__, 'ps_socialfollow.tpl', $this->getCacheId('ps_socialfollow')); } }

ps_featured_products

class Ps_FeaturedProductsOverride extends Ps_FeaturedProducts { public function __construct() { parent::__construct(); $this->templateFile = 'module:ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl'; } public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId('ps_featuredproducts'))) { $variables = $this->getWidgetVariables($hookName, $configuration); if (empty($variables)) { return false; } $this->smarty->assign($variables); } return $this->display(__FILE__, 'ps_featuredproducts.tpl', $this->getCacheId('ps_featuredproducts')); } }

ps_customersignin

class Ps_CustomerSignInOverride extends Ps_CustomerSignIn { public function __construct() { parent::__construct(); $this->templateFile = 'module:ps_customersignin/ps_customersignin.tpl'; } public function renderWidget($hookName, array $configuration) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); return $this->display(__FILE__, 'ps_customersignin.tpl'); } }

ps_shoppingcart

class Ps_ShoppingcartOverride extends Ps_Shoppingcart { public function __construct() { parent::__construct(); } public function renderWidget($hookName, array $params) { if (Configuration::isCatalogMode()) { return; } $this->smarty->assign($this->getWidgetVariables($hookName, $params)); return $this->display(__FILE__, 'ps_shoppingcart.tpl'); } }

Hi All,

Has there been any progression with this (frankly major) bug?

Currently this is stopping clients from using the multi-store functionality with different themes.

Kind regards,
Dan

Hi All,

Has there been any progression with this (frankly major) bug?

Currently this is stopping clients from using the multi-store functionality with different themes.

Kind regards,
Dan

Yes there is https://github.com/PrestaShop/PrestaShop/pull/13804 😄

Was this page helpful?
0 / 5 - 0 ratings