Page 1 of 1

Define parent node category id in Magento Plugin

PostPosted: Mon Jan 16, 2017 9:55 pm
by jak
Hi!

I'm customizing Magento Integration Plugin in jiwa,
in this we need to add category 4 as sub-category of Magento main category, we change it's code, it works properly, but the problem when we create/update product into that category it will create one more sub-category of same name in Main category,
we find out the problem for this, and

// Find the category which matches the Jiwa category 4

MagentoServiceReference.catalogCategoryEntity category4_Catalog = MagentoIntegration.GetMagentoCategoryFromDescription(category1_Catalog, inventory.Category4.Description);
if (category4_Catalog == null)
{


here in the above code,
we need to define parent node id means we need to define category1_Catalog id,

can you please tell us how we can define it's id, or is their is any other way to do that.

Thank you in Advance!

Re: Define parent node category id in Magento Plugin  Topic is solved

PostPosted: Tue Jan 17, 2017 3:11 pm
by Mike.Sheen
We already determine what we think must be the root category when we do the following in the CreateOrUpdateMagentoProductsFromJiwa method:

Code: Select all
// find the first active level 1 category in Magento and use that as the root category
List<MagentoServiceReference.catalogCategoryEntity> topLevelMagentoCategories = MagentoIntegration.GetMagentoCategoriesForLevel(magentoCatalogCategoryTree, 1);
if (topLevelMagentoCategories.Count == 0)
{
   throw new Exception("No top-level Magento Category found.");
}


so if you want the Jiwa category 4 to appear under the root, just change the code you posted to be:

Code: Select all
// Find the first sub category of root category category which matches the Jiwa category 4 description
MagentoServiceReference.catalogCategoryEntity category4_Catalog = MagentoIntegration.GetMagentoCategoryFromDescription(root_Category, inventory.Category4.Description);
if (category4_Catalog == null)
{
   // no category was found with that description, create one
...