Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有类别树。Cat1 : (id=2), Cat1-sub(ID=3), Cat1-sub-sub(id=4) 和 Cat2 (id=5) 现在如果更新类别 Cat-sub-sub,我想显示它的全部父类别 ID 也是如此。例如 3,2 两者。
我认为,根据您的问题,您想获取给定类别的父类别 ID 如果是这样,您可以使用以下内容获取 ID:
$category->getParentIds()
或者,您可以通过以下方式获得实际模型:
$category->getParentCategories()
如果这不是问题,请澄清您的问题。