Hello,
I display a category with products. The display of products is done in a products.tpl file.
For each product, I need to display a special block. For this I created a module with ESI block.
This is a sample of the products.tpl file
This is the content of the tpl file (mycustomblock/mycustomblock_product_bouton.tpl) from my module
Sometimes $product appears to be NULL, sometimes it shows only the first product id.
I have two cases of generated HTML content.
First :
Second :
It seems the difference depends of browsers so maybe a problem with cookies. In all cases I am not logged into my account.
In case 1, if i go to account page, the account fields are prefilled that's why I think it's a story with cookies.
In case 2, if I go to account page, the account fields are empty.
Anyway, in these 2 cases, I have a problem. In case 1, we can see that '<p class="launchJS" productid="1">Do something</p>' has always the id of the first product found.
So is there something I can do to pass the correct value of the $product variable to my ESI block?
As additional info, this is the part of my htaccess file related to LSCache:
I display a category with products. The display of products is done in a products.tpl file.
For each product, I need to display a special block. For this I created a module with ESI block.
This is a sample of the products.tpl file
Code:
{foreach from=$produits_categories key="i" item="product"}
<div class="product_block">
<p>{$product.description</p>
<div class="special_content">
{hook h="litespeedEsiBegin" m="mycustomblock" field="widget_block" tpl="module:mycustomblock/mycustomblock_product_bouton.tpl"}
{widget_block name="mycustomblock"}
{include 'module:mycustomblock/mycustomblock_product_bouton.tpl'}
{/widget_block}
{hook h="litespeedEsiEnd"}
</div>
</div>
{/foreach}
Code:
<p class="launchJS" productid="{$product.id_product}">{l s='Do something'}</p>
I have two cases of generated HTML content.
First :
HTML:
<div class="product_block" id="1">
<p>Product description 1</p>
<div class="special_content">
<p class="launchJS" productid="1">Do something</p>
</div>
</div>
<div class="product_block" id="2">
<p>Product description 2</p>
<div class="special_content">
<p class="launchJS" productid="1">Do something</p>
</div>
</div>
HTML:
<div class="product_block" id="1">
<p>Product description 1</p>
<div class="special_content">
<p class="launchJS" productid="">Do something</p>
</div>
</div>
<div class="product_block" id="2">
<p>Product description 2</p>
<div class="special_content">
<p class="launchJS" productid="">Do something</p>
</div>
</div>
In case 1, if i go to account page, the account fields are prefilled that's why I think it's a story with cookies.
In case 2, if I go to account page, the account fields are empty.
Anyway, in these 2 cases, I have a problem. In case 1, we can see that '<p class="launchJS" productid="1">Do something</p>' has always the id of the first product found.
So is there something I can do to pass the correct value of the $product variable to my ESI block?
As additional info, this is the part of my htaccess file related to LSCache:
Code:
<IfModule Litespeed>
RewriteEngine On
RewriteCond %{HTTP_COOKIE} my_cookie_admin [NC]
RewriteRule .* - [E=Cache-Control:no-cache]
</IfModule>
### LITESPEED_CACHE_START - Do not remove this line, LSCache plugin will automatically update it
# automatically genereated by LiteSpeedCache plugin: https://docs.litespeedtech.com/lscache/lscps/
<IfModule LiteSpeed>
CacheLookup on
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !PrestaShop-
RewriteRule .* - [E=Cache-Control:vary=guest]
</IfModule>
### LITESPEED_CACHE_END