如何在Prestashop中使用我自己的模块为产品页面创建新的挂钩


How to create new hook for product page using my own module in Prestashop

我需要列出所选产品的相关产品项。我有新的相关产品列表。

我有下面的挂钩来展示相关的产品。

 public function hookDisplayProductTabContent($params) {
   $related_items = Product::getRelatedProducts((int) $this->context->language->id, 0, (int)Configuration::get('NEW_PRODUCTS_NBR'),(int) $id_product);
 return $this->display(__FILE__, 'views/frontend/relateditems.tpl');
}

ProductTabContent不显示相关产品。我怎样才能做到这一点。请帮帮我。

您需要将$related_items变量分配给Smarty。

$this->smarty->assign('related_items', $related_items);