November Happy Hour will be moved to Thursday December 5th.

Remove the CatalogEntryRelation Row does not work

Vote:
 

I am trying to remove the catalog entry relation row but after calling the CatalogEntryRelation.RemoveCatalogEntryRelationRow function the changes are not reflected in the database. Below is the snippet of code I am using. Am I missing anything? 

 Entry prod = CatalogRef.GetCatalogEntry(MasterSKU);
                CatalogRelationDto skuRelation = null;
                skuRelation = CatalogRef.GetCatalogRelationDto(newEntryRow.CatalogEntryId);
                bool relationshipFound = false;
                //  CatalogRelationDto.CatalogEntryRelationRow[] entryRelations = skuRelation.CatalogEntryRelation.Select(x => x.RelationTypeId == "ProductVariation"); 
                List<CatalogRelationDto.CatalogEntryRelationRow> rowsToDelete = new List<CatalogRelationDto.CatalogEntryRelationRow>();
                for(int i=0; i<skuRelation.CatalogEntryRelation.Count;i++)
                {
                    CatalogRelationDto.CatalogEntryRelationRow currRelation = skuRelation.CatalogEntryRelation[i];
                    if (currRelation.ParentEntryId != prod.CatalogEntryId)
                    {
                        skuRelation.CatalogEntryRelation.RemoveCatalogEntryRelationRow(currRelation);
                    }
                }
                if (skuRelation.HasChanges())
                {
                    CatalogRef.SaveCatalogRelationDto(skuRelation);
                }

Thanks,

Syed

#86943
Jun 04, 2014 21:57
Vote:
 

Hi,

I believe that correct way is to do call Delete on the row: 

CatalogRelationDto.CatalogEntryRelationRow currRelation = skuRelation.CatalogEntryRelation[i];
                   if (currRelation.ParentEntryId != prod.CatalogEntryId)
                   {
                       currRelation.Delete();
                   }
Regards.
/Q
#86944
Edited, Jun 05, 2014 0:18
Vote:
 

Thanks Quan,

I started with .Delete() as my first option but that did not work as well. Do we need to call acceptChanges() after the .Delete()?

Syed

#86984
Jun 05, 2014 16:29
Vote:
 

Quan,

Calling the acceptChanges made it work. Thanks for your help.

Thanks,

Syed

#87018
Jun 06, 2014 17:43
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.