Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Exception when try to Removes the relation

$
0
0

Hi,

I tried to remove relation between Node and Entry but i get an exception 

A value representing catalog content of the type CatalogNode is not valid for the Parent property of a ProductVariation.

Can anyone give me suggestion?

here is my list relation

[{"GroupName":null,"Quantity":null,"Parent":"1073743274__CatalogContent","Child":"158744__CatalogContent","Source":"1073743274__CatalogContent","Target":"158744__CatalogContent","SortOrder":0,"IsReadOnly":false},{"GroupName":null,"Quantity":null,"Parent":"1073743274__CatalogContent","Child":"158745__CatalogContent","Source":"1073743274__CatalogContent","Target":"158745__CatalogContent","SortOrder":0,"IsReadOnly":false},{"GroupName":null,"Quantity":null,"Parent":"1073743274__CatalogContent","Child":"158746__CatalogContent","Source":"1073743274__CatalogContent","Target":"158746__CatalogContent","SortOrder":0,"IsReadOnly":false},{"GroupName":null,"Quantity":null,"Parent":"1073743274__CatalogContent","Child":"158747__CatalogContent","Source":"1073743274__CatalogContent","Target":"158747__CatalogContent","SortOrder":0,"IsReadOnly":false},{"GroupName":null,"Quantity":null,"Parent":"1073743276__CatalogContent","Child":"158748__CatalogContent","Source":"1073743276__CatalogContent","Target":"158748__CatalogContent","SortOrder":0,"IsReadOnly":false}]

1073743274__CatalogContent is node

15874x__CatalogContent is product

My code:

private void DeleteAllNodeEntryRelation(CatalogsCatalogNodeEntryRelation[] relations)
{
var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
var relationRepository = ServiceLocator.Current.GetInstance<IRelationRepository>();
var deleteRelations = new List<Relation>();
foreach (var relation in relations)
{
deleteRelations.Add(new ProductVariation()
{
Child = referenceConverter.GetContentLink(relation.EntryCode),
Parent = referenceConverter.GetContentLink(relation.NodeCode)
});
}

relationRepository.RemoveRelations(deleteRelations);
}

Thanks,

Thao Pham


Viewing all articles
Browse latest Browse all 6894

Trending Articles