
I have below Product Category Hierarchy setup and products is assigned to the lowest category e.g MT0001 to 6ft Rectangle. In x++ how can I retrieve all the related category hierachy in sequence for the particular product?
Any suggestion and advice will be highly appreciated.
e.g for MT0001 will return [Furniture,Office,Table, Manager, 6ft Rectangle]
Furniture
-> Office
-> Table
-> Manager
-> 6ft Rectangle
-> 5ft L-Shape
*This post is locked for comments
I have the same question (0)You can get the product category hierarchy for the product "MT0001" by using the below code.
ItemId itemId = "MT0001";
EcoResProductCategory EcoResProductCategory;
EcoResCategory EcoResCategory,EcoResCategoryNext;
EcoResCategoryId parentCategory;
List li = new List(Types::String);
ListEnumerator enumer;
select * from EcoResCategory
join RecId from EcoResProductCategory
where EcoResCategory.RecId == EcoResProductCategory.Category
&& EcoResProductCategory.Product == InventTable::find(itemId).Product;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
while (parentCategory)
{
select * from EcoResCategory
where EcoResCategory.RecId == parentCategory;
//&& EcoResCategory.ParentCategory != 0;
parentCategory = EcoResCategory.ParentCategory;
li.addStart(EcoResCategory.Name);
}
enumer = li.getEnumerator();
while (enumer.moveNext())
{
info(enumer.current());
}