如何在每个$附件项目中正确删除购物车网址? 我试过模板:
{foreach from=$accessories item=accessory}
{assign var="deleteURL" value=Link::getRemoveFromCartURL($accessory.id_product,$accessory.id_product_attribute,null)}
{/foreach}
但是我收到了一个错误:
Runtime Notice: Non-static method LinkCore::getRemoveFromCartURL() should not be called statically
我应修改哪个控制器才能使用$附件从购物车网址中删除?
答案 0 :(得分:0)
在controllers / front / ProductController.php中,编辑函数initContent。
$accessories = $this->product->getAccessories($this->context->language->id);
if (is_array($accessories)) {
foreach ($accessories as &$accessory) {
$accessory = $presenter->present(
$presentationSettings,
Product::getProductProperties($this->context->language->id, $accessory, $this->context),
$this->context->language
);
}
unset($accessory);
}
到
$accessories = $this->product->getAccessories($this->context->language->id);
if (is_array($accessories)) {
foreach ($accessories as &$accessory) {
$accessory = $presenter->present(
$presentationSettings,
Product::getProductProperties($this->context->language->id, $accessory, $this->context),
$this->context->language
);
$accessory['remove_from_cart_url'] = $this->context->link->getRemoveFromCartURL($accessory['id'],$accessory['id_product_attribute']);
}
unset($accessory);
}
编辑: 您不应该直接编辑控制器,而是在override / controllers / front / ProductController.php中创建覆盖。 如果尚未创建文件,请自行完成。