自product-variants.tpl Prestashop起调用函数
我正在Prestashop创建一个网站,我的问题是: 我在db(mysql)中创建了一个名为“tallas”的新表,并且我拥有用户的大小偏好。现在,由于页面product-variants.tpl,我需要调用此表,因为我想将checked作为默认选项,由客户选择 我在classes/Product.php中创建了这个函数自product-variants.tpl Prestashop起调用函数,prestashop,smarty,Prestashop,Smarty,我正在Prestashop创建一个网站,我的问题是: 我在db(mysql)中创建了一个名为“tallas”的新表,并且我拥有用户的大小偏好。现在,由于页面product-variants.tpl,我需要调用此表,因为我想将checked作为默认选项,由客户选择 我在classes/Product.php中创建了这个函数 public function getTalla($id_customer){ $result = Db::getInstance()->ExecuteS('
public function getTalla($id_customer){
$result = Db::getInstance()->ExecuteS('
SELECT `talla1`
FROM `tallas`
WHERE `cliente` = `$id_customer`');
return $result;
}
public function getTalla(){
$variable = Context::getContext()->customer->id;
$result = Db::getInstance()->ExecuteS('SELECT * FROM `tallas` WHERE `cliente` = `$variable`');
return $result;
}
好的,我想接收用户id的参数(我还不知道怎么做),我想接收talla1
的值,然后我想把客户选择的选项放在收音机的themes/asmart/templates/catalog/_partials/product-variants.tpl中
<li class="float-xs-left input-container">
<label>
<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
<span
{if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
{if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
><span class="sr-only">{$group_attribute.name}</span></span>
</label>
</li>
在ProductController.php中
$this->context->smarty->assign('images_ex',$this->product->getTalla());
在product-variants.tpl中
{if $images_ex[0]['talla1'] == $group_attribute.name} checked="checked"{/if}
我希望这能对将来的人有所帮助