0

这是 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}
4

1 回答 1

0

您的问题不在 TPL 文件中。它在 PHP 相关的模块文件上。您应该在主页中查找显示产品的模块(如 blockbestsellers 或 blocknewproducts)并查找主要的 PHP 模块文件。在里面你应该找到 MySQL 请求。例如来自 blocknewproducts:

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;
}

您应该$newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int)Configuration::get('NEW_PRODUCTS_NBR'));为您自己的 MySQL 语句更改此设置,保持原始行为但避免随机。

祝你好运

于 2017-01-30T15:07:45.387 回答