有没有办法在 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) 中。
希望对你有帮助
关于php - 获取产品页面 Opencart 的父类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9883105/