gpt4 book ai didi

php - 使用 Prestashop 1.6 在模块中获取产品类别名称

转载 作者:行者123 更新时间:2023-12-05 09:21:07 24 4
gpt4 key购买 nike

我为 prestashop 创建了自己的模块(目前非常基础)。

我想为产品添加一些自定义(类似于 Attribute Wizard Pro )最终目标:我希望我的模块根据产品所属的类别在产品页面上显示一个小表格(每个类别的表格略有不同) - 并且在购买产品时将保存该表格的结果。

我想将表单放入 RightColumnProduct - 我可以通过在此 Hook 中访问它并调用我创建的 TPL 来实现。

public function hookDisplayRightColumnProduct()
{
/* Place your code here. */
/*Get the Current Category name to see which TPL to show*/


return $this->display(__FILE__,'views/hooks/mytpl.tpl');
}

我需要做的是访问当前产品的类别名称,但这很难做到。

我已经尝试过各种解决方案,但都没有成功。

最佳答案

此代码段将向您显示默认产品类别的名称。

$product = $this->context->controller->getProduct();
$category = new Category((int)$product->id_category_default, (int)$this->context->language->id);
echo $category->名称;

关于php - 使用 Prestashop 1.6 在模块中获取产品类别名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34326238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com