How to remove a product from a category API wise in Demandware(sfcc)?

238 views Asked by At

I'm using the code below to remove the product from catelog - skincare ,

var name=pdict.categoryName;  
var category=CatalogMgr.getCategory('skincare'); 

if(category && category.products.length){
    for each(var product in category.products){
        if(!product.custom.productBadge1){
              var assignments = product.getCategoryAssignments();
              
              for(var i=0;i<assignments.length;i++)  
                  {
                  if(assignments[i].category.ID=='skincare'){
                     //TO DO remove product from category
                  }
                  } 

        }
    }
}

which API to be used here

1

There are 1 answers

0
Albin Joseph On

Well, one possible way is, you can write an XML to remove the assignment and import it manually or through a job. This can be the worst-case scenario.