Quantcast
Viewing all articles
Browse latest Browse all 175888

RE: X++ How to get Product Category Hierarchy

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());
}


Viewing all articles
Browse latest Browse all 175888

Trending Articles