这是Prestashop CMS的items.tpl模块,它显示主页中的随机产品,我不需要显示产品数量= 0。
我的英语不好。
感谢您的帮助。
{if isset($products) && $products}
<div class="{if isset($SNSPRT_EFFECT)}{$SNSPRT_EFFECT}{/if} product_list products-grid grid {if isset($class) && $class} {$class}{/if}">
{if isset($ajax_start) && $ajax_start}
{assign var='nbstart' value=$ajax_start}
{else}
{assign var='nbstart' value=0}
{/if}
{counter start=$nbstart skip=1 print=false name=i assign="i"}
{foreach from=$products item=product name=products}
<div class="ajax_block_product item item-animate{if isset($item_class) && $item_class} {$item_class}{/if}">
{counter name=i}
{include file="$tpl_dir./product-blockgrid.tpl"}
</div>
{if $i % $SNSPRT_XS == 0}<div class="clearfix visible-xs"></div>{/if}
{if $i % $SNSPRT_SM == 0}<div class="clearfix visible-sm"></div>{/if}
{if $i % $SNSPRT_MD == 0}<div class="clearfix visible-md"></div>{/if}
{if $i % $SNSPRT_LG == 0}<div class="clearfix visible-lg"></div>{/if}
{/foreach}
</div>
{addJsDefL name=min_item}{l s='Please select at least one product' js=1}{/addJsDefL}
{addJsDefL name=max_item}{l s='You cannot add more than %d product(s) to the product comparison' sprintf=$comparator_max_item js=1}{/addJsDefL}
{addJsDef comparator_max_item=$comparator_max_item}
{addJsDef comparedProductsIds=$compared_products}
{/if}
答案 0 :(得分:0)
您的问题不在TPL文件中。它在PHP关联的模块文件上。您应该在主页(如blockbestsellers或blocknewproducts)中查找显示产品的模块,并查找主PHP模块文件。在里面你应该找到MySQL请求。例如来自blocknewproducts:
/*!
您应该为自己的MySQL句子更改此protected function getNewProducts()
{
if (!Configuration::get('NEW_PRODUCTS_NBR'))
return;
$newProducts = false;
if (Configuration::get('PS_NB_DAYS_NEW_PRODUCT'))
$newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int)Configuration::get('NEW_PRODUCTS_NBR'));
if (!$newProducts && Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
return;
return $newProducts;
}
,保留原始行为但不要随意。