Prestashop 分组显示产品功能
我是prestashop的新手,我想分组展示我的产品功能。如下图所示 输出 光源: 颜色: 机械 温度: 重量: 高度: 电气 输入电压: 耗电量:Prestashop 分组显示产品功能,prestashop,prestashop-1.6,Prestashop,Prestashop 1.6,我是prestashop的新手,我想分组展示我的产品功能。如下图所示 输出 光源: 颜色: 机械 温度: 重量: 高度: 电气 输入电压: 耗电量: here output, mechanical, electricals are groups. light source, color, weight's are features of that groups. 请帮助我解决此问题。在某些时候,您必须修改产品页面模板(我假设您希望在产品页面中显示分类功能) 您可以为分类功能创建一个模块,但
here output, mechanical, electricals are groups. light source, color, weight's are features of that groups.
请帮助我解决此问题。在某些时候,您必须修改产品页面模板(我假设您希望在产品页面中显示分类功能) 您可以为分类功能创建一个模块,但仍然需要修改产品模板 最直接的方法是将类别硬编码到
product.tpl
:
{if $feature.id == 1}
...
{elseif $feature.id == 2}
...
{/if}
但是,我不建议这样做。更好的方法是创建一个简单的模块,您可以在其中为产品页面准备分类功能:
public function hookDisplayFooterProduct {
// pick ane product page hook, not necessarilly displayFooterProduct;
$categorized_features = array(
'electrical' => array(),
'mechanical' => array(),
'other' => array(),
);
foreach($product->features as $f)
{
switch ($f->name)
{
case 'inpu voltage':
$categorized_features['electrical'][] = $f;
break;
....
default:
$categorized_features['other'][] = $f;
}
}
}
$this->context->smarty->assign(array(
'categorized_features' => $categorized_features,
));
然后修改product.tpl
{foreach $$categorized_features as $cf}
{$f->name}: {$f->value}
{/foreach}
请记住,这个例子只是展示了这个想法