Prestashop 检查产品是否属于特定类别?
我正在尝试检查产品是否位于特定类别中,并更改product-list.tpl中“添加到购物车”按钮的标签Prestashop 检查产品是否属于特定类别?,prestashop,prestashop-1.6,Prestashop,Prestashop 1.6,我正在尝试检查产品是否位于特定类别中,并更改product-list.tpl中“添加到购物车”按钮的标签 {assign findcat [['id_category' => 14], ['id_category' => 33]]} {if Product::idIsOnCategoryId($product.id_product, $findcat)} {assign var="PS_CATALOG_MODE" value="true"} {/if} 在这种情况下,如果产
{assign findcat [['id_category' => 14], ['id_category' => 33]]}
{if Product::idIsOnCategoryId($product.id_product, $findcat)}
{assign var="PS_CATALOG_MODE" value="true"}
{/if}
在这种情况下,如果产品位于类别id 14中,我希望显示“在此处阅读更多”,而不是“添加到购物车”
目前,第14类的所有产品都将获得“添加到购物车”
我正在运行1.6.0.11
{assign var='associated' value=0}
{foreach Product::getProductCategories($smarty.get.id_product) as $category}
{if in_array($category, 14)}
{assign var='associated' value=1}
{/if}
{/foreach}
{if $associated==1}
{l s='Read more here'}
{else}
{l s='Add to cart'}
{/if}
试试这个:
{assign cat14 [['id_category' => 14]]}
{if Product::idIsOnCategoryId($smarty.get.id_product, $cat14)}
{l s='Read more here'}
{else}
{l s='Add to cart'}
{/if}
当我必须执行类似操作时,我只需为一个(或多个)类别设置目录模式: (我在product list.tpl中的foreach循环之后添加了这个) 如果您需要在产品页面中隐藏销售选项,请在开头添加此选项(product.tpl): 这适用于product.tpl中的PS 1.6.1.5:-),
$product->id
甚至更短:-),
{assign cat15 [['id_category' => 15], ['id_category' => 17], ['id_category' => 27], ['id_category' => 29], ['id_category' => 30], ['id_category' => 31]]}
{if Product::idIsOnCategoryId($product->id, $cat15)}
{assign var="PS_CATALOG_MODE" value="true"}
{/if}