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

How to Create sku Associations?

Vote:
 

Hi, I need to create relations/associations between different entry’s. I have found a way to get the correct name of a association through this code:

CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(artNbr,

                  new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

 

            foreach (CatalogEntryDto.CatalogAssociationRow catalogAssociation in entryDto.CatalogAssociation)

            {

                 Debug.WriteLine("Relation AssociationDescription: " + catalogAssociation.CatalogEntryRow.GetCatalogAssociationRows()[0].AssociationDescription);

                Debug.WriteLine("Relation AssociationName: " + catalogAssociation.CatalogEntryRow.GetCatalogAssociationRows()[0].AssociationName);

            }

Which gives the following output:

Relation AssociationDescription: Related description..

Relation AssociationName: Related

Which corresponds to the values entered to AssociationDescription and AssociationName when the associations where created.

My question is, how do I connect two skus programmatically so that they appear in commerce manager under: Catalog Management -> “folderX” -> “skuX” -> “edit” -> “Associations”

Regards,

Tim Hansson

#49889
Apr 05, 2011 10:00
Vote:
 

Hi again,

I found a way to relate the skus:

Entry entryArticle = CatalogContext.Current.GetCatalogEntry(catalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Associations));

Entry entryRelatedArticle = CatalogContext.Current.GetCatalogEntry(catalogEntryIdRelated, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Associations));

var association = CatalogContext.Current.GetCatalogAssociationDtoByEntryId(entryArticle.CatalogEntryId);
var row = association.CatalogEntryAssociation.AddCatalogEntryAssociationRow(association.CatalogAssociation[associationType], entryRelatedArticle.CatalogEntryId, 0, association.AssociationType[0]);


if (association.HasChanges())
{
         CatalogContext.Current.SaveCatalogAssociation(association);

}

Hopefully someone finds this useful. 

/Tim

 

#50068
Apr 12, 2011 8:58
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.