Magento 产品类别
我必须列出产品及其类别,我只有产品的 SKU,我需要找到它属于哪个类别,所以我想知道此信息保留在哪个 magento 表中。
即:对于sku 52429,它分为3类。该报告将显示所有 3 个类别树:
BL >头发护理>定型产品
Bl>自然&有机>头发护理>定型产品
BL>我们的品牌 >纯学>造型师
谢谢! 里查
I have to list products with its category or categories, I have only products' SKU by it I need to find which category it belongs, so I want to know in which magento table this information stay.
ie: for sku 52429, it is categorized into 3 categories. the report would show all 3 category trees:
Bl > Hair Care > Styling products
Bl > Natural & Organic > Hair Care > Styling Products
Bl > Our Brands > Pureology > Stylers
Thanks!
Richa
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Magento 类别存储在
catalog_category_entity
中(pk 为entity_id
)。要查找产品和类别之间的关系,请使用catalog_category_product
。它的结构很简单:因此,要获取产品的所有类别:
编辑以注意您要查找的信息(以显示类别树)位于类别表本身中。列摘录(部分省略):
您可以在
path
列上使用 split 来获取路径中所有类别的类别 ID,并为报告加载它们的名称。Magento categories are stored in
catalog_category_entity
(pk isentity_id
). To find the relationship between a product and a category, usecatalog_category_product
. Its structure is simple:So, to get all categories for a product:
EDIT to note that the info you are looking for (to display category trees) is in the category table itself. An excerpt of the columns (some omitted):
You can use split on that
path
column to get the category IDs of all the categories in the path, and load their names for the report.加载产品模型
首先按 ID
或按属性 (SKU)
现在您可以加载类别 ID
然后获取完整的类别对象
现在获取每个类别的父级
我认为这就是您所需要的。
First load up the product model
Either by ID
or by attribute (SKU)
Now you can load the category IDs
Then to get the full category objects
Now to get the parent of each category
This is all you need i think.