opencart-在子类别页面上获取父类别名称/ID [英] opencart - get parent category name/id on a sub-category page

查看:84
本文介绍了opencart-在子类别页面上获取父类别名称/ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码块,只想对特定类别的子类别执行.我想为此使用面包屑,但是如果为当前子类别设置了SEO网址,则父类别将从面包屑中消失.

I have a code block that I want to execute only on sub-categories of a particular category. I wanted to use breadcrumbs for this purpose but the parent category disappears from breadcrumbs if a SEO url is set for the current sub-category.

有没有办法在子类别中获取父类别的名称或ID?

Is there a way to get the name or id of the parent category inside a sub-category?

推荐答案

每个类别都分配了一个parent_id.您需要根据当前类别获取parent_id.

Every category has a parent_id assigned to it. You need to get the parent_id based off the current category.

$result = $this->db->query("SELECT `parent_id` FROM `" . DB_PREFIX . "category` WHERE `category_id` = '123'");
$parent_id = $result->row['parent_id'];

这篇关于opencart-在子类别页面上获取父类别名称/ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆