Quantcast
Channel: Customized Commerce 13 and earlier versions
Viewing all articles
Browse latest Browse all 9642

Correct way to change Product-Category association

$
0
0

Hi all,

[using commerce 9.24]

A while back, I associated products (and variants) to Categories, by doing this:

// Create new Category relation:
                    var nodeRelation = relations.NewNodeEntryRelationRow();
                    nodeRelation.CatalogId = _catalogId;
                    nodeRelation.CatalogEntryId = catalogEntryId;
                    nodeRelation.CatalogNodeId = targetCategoryNode.CatalogNodeId;
                    nodeRelation.SortOrder = 0;
                    if (nodeRelation.RowState == DataRowState.Detached)
                    {
                        relations.AddNodeEntryRelationRow(nodeRelation);
                    }
                    CatalogContext.Current.SaveCatalogRelationDto(relationsDto);

Today, I'd like to change those associations -- I'd like to associate those products with a different category (and thus remove the previous association).

How can I accomplish this programmatically?

Thanks!

 - Ken


Viewing all articles
Browse latest Browse all 9642

Trending Articles