Prestashop 1.7:如何从配件中的购物车 URL 中移除

Prestashop 1.7 : How to get remove from cart URL in accessories

如何正确地从购物车 URL 中移除每件 $accessories 商品? 我从模板中尝试过:

{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 

我应该修改哪个控制器才能使用 $accessories 从购物车 URL 中移除?

在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 中创建覆盖。 如果尚未创建文件,请自行创建。