加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 获取产品页面Opencart的父类别

发布时间:2020-12-13 18:23:18 所属栏目:PHP教程 来源:网络整理
导读:有没有办法在Opencart的产品页面中获取产品的父类别?谢谢 是的你可以. 我在OpenCart 1.5.1.x中测试了我的代码 首先,您必须修改文件/catalog/controller/product/product.php才能添加 第94行之后: $product_info = $this- model_catalog_product- getProduc
有没有办法在Opencart的产品页面中获取产品的父类别?谢谢
是的你可以.
我在OpenCart 1.5.1.x中测试了我的代码

首先,您必须修改文件/catalog/controller/product/product.php才能添加
第94行之后:
$product_info = $this-> model_catalog_product-> getProduct($product_id);

添加:

$categories = $this-> model_catalog_product-> getCategories($product_info [‘product_id’]);
if($categories){
$categories_info = $this-> model_catalog_category-> getCategory($categories [0] [‘category_id’]);
$this-> data [‘category_id’] = $categories_info [‘category_id’];
}

然后,您可以使用变量<?php echo $category_id?>在您的模板文件(product.tpl)中.

希望这对你有所帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读