Prestashop 如何在页眉上获取产品列表?
嗨,我正在试着做我的第一个模块 当我位于分类页面上时,我需要获得副本或相同的$products数组 我有这个密码Prestashop 如何在页眉上获取产品列表?,prestashop,prestashop-1.5,prestashop-1.6,Prestashop,Prestashop 1.5,Prestashop 1.6,嗨,我正在试着做我的第一个模块 当我位于分类页面上时,我需要获得副本或相同的$products数组 我有这个密码 public function hookHeader($params) { if ('category' == $this->context->controller->php_self){ $products = //Here I need the same products array from this category $this
public function hookHeader($params)
{
if ('category' == $this->context->controller->php_self){
$products = //Here I need the same products array from this category
$this->smarty->assign('products', $products);
}
return $this->display(__FILE__, 'views/templates/hook/header.tpl');
}
谢谢 你应该:
error\u log(print\r($this->smarty,1))代码>
Hook.php
findexec(
method,添加error\u log($Hook\u name)
并查看在打开类别页面时执行了哪些钩子。可能有一个钩子适合您的需要产品::
或类别::
函数自己获取所有产品$category = new Category (Tools::getValue('id_category'):
$products = $category->getProducts($this->context->lang->id, 0 99);
这将使99种产品脱离该类别
为什么你不能“复制”该类别的产品?这仅仅是因为当你调用hookHeader时,它们还没有被分配,因为CategoryController紧跟其后
另外,请注意,将在部分中显示内容,如果要显示任何内容,必须使用hookDisplayTop
另外,在1.6中,你应该使用$this->context->smarty:)谢谢尼莫的回答!!