private void AddAssociationElements(LinkType linkType,
                                            StructureEntity structureEntity,
                                            string itemCode)
        {
            if (!IsAssociationLinkType(linkType))
            {
                return;
            }

            if (!_config.UseThreeLevelsInCommerce && _config.ItemsToSkus && structureEntity.IsItem())
            {
                AddItemToSkusAssociations(linkType, structureEntity, itemCode);
            }
            else
            {
                AddNormalAssociations(structureEntity);
            }
        }
예제 #2
0
        private void AddRelations(LinkType linkType,
                                  StructureEntity structureEntity,
                                  Entity entity)
        {
            var skus = new List <string> {
                _catalogCodeGenerator.GetEpiserverCode(entity.Id)
            };

            int parentId = structureEntity.EntityId;

            if (structureEntity.IsItem() && _config.ItemsToSkus)
            {
                skus = _catalogElementFactory.SkuItemIds(entity);
                for (var i = 0; i < skus.Count; i++)
                {
                    skus[i] = _catalogCodeGenerator.GetPrefixedCode(skus[i]);
                }

                if (_config.UseThreeLevelsInCommerce)
                {
                    skus.Add(_catalogCodeGenerator.GetEpiserverCode(parentId));
                }
            }

            foreach (string skuId in skus)
            {
                if (_epiMappingHelper.IsRelation(linkType))
                {
                    AddNodeEntryRelationElement(linkType, structureEntity, skuId);
                    AddEntryRelationElement(structureEntity, skuId, linkType);
                }
                else
                {
                    if (_config.ForceIncludeLinkedContent)
                    {
                        AddMissingParentRelation(structureEntity, skuId);
                    }

                    IntegrationLogger.Write(LogLevel.Debug, "AddAssociationElements");
                    AddAssociationElements(linkType, structureEntity, skuId);
                }
            }
        }
 private bool ShouldCreateSkus(StructureEntity structureEntity)
 {
     return(structureEntity.IsItem() && _config.ItemsToSkus);
 }