示例#1
0
        private void TransformTransientData(ImportCategoriesPolicy importPolicy, string[] rawFields, Category item, List <TransientImportCategoryDataPolicy> transientDataList)
        {
            var catalogName = rawFields[CatalogNameIndex];
            var data        = new TransientImportCategoryDataPolicy();

            var categoryRecord = rawFields[ParentCategoryNameIndex].Split(new string[] { importPolicy.FileRecordSeparator }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var categoryUnit in categoryRecord)
            {
                data.ParentAssociationsToCreateList.Add(new CatalogItemParentAssociationModel(item.Id, catalogName.ToEntityId <Sitecore.Commerce.Plugin.Catalog.Catalog>(), categoryUnit.ToCategoryId(catalogName)));
                data.CategoryAssociationList.Add(new CategoryAssociationModel {
                    CatalogName = catalogName, CategoryName = categoryUnit
                });
            }

            if (data.CategoryAssociationList.Count().Equals(0))
            {
                data.ParentAssociationsToCreateList.Add(new CatalogItemParentAssociationModel(item.Id, catalogName.ToEntityId <Sitecore.Commerce.Plugin.Catalog.Catalog>(), catalogName.ToEntityId <Sitecore.Commerce.Plugin.Catalog.Catalog>()));
                data.CatalogAssociationList.Add(new CatalogAssociationModel {
                    Name = catalogName, IsParent = true
                });
            }
            else
            {
                data.CatalogAssociationList.Add(new CatalogAssociationModel {
                    Name = catalogName
                });
            }

            item.Policies.Add(data);
            transientDataList.Add(data);
        }
示例#2
0
        private void LogInitialization(CommercePipelineExecutionContext context, ImportCategoriesPolicy policy)
        {
            var log = new StringBuilder();

            log.AppendLine($"{System.Environment.NewLine}");
            log.AppendLine($"{GetType().Name} - Starting");
            log.AppendLine($"Settings:");
            log.AppendLine($"\t {nameof(policy.ItemsPerBatch)} = {policy.ItemsPerBatch}");
            log.AppendLine($"\t {nameof(policy.SleepBetweenBatches)} = {policy.SleepBetweenBatches}");
            log.AppendLine($"\t {nameof(policy.FileFolderPath)}  = {policy.FileFolderPath}");
            log.AppendLine($"\t {nameof(policy.FileArchiveFolderPath)}  = {policy.FileArchiveFolderPath}");
            log.AppendLine($"\t {nameof(policy.FilePrefix)}  = {policy.FilePrefix}");
            log.AppendLine($"\t {nameof(policy.FileExtention)}  = {policy.FileExtention}");
            log.AppendLine($"\t {nameof(policy.FileRecordSeparator)}  = {policy.FileRecordSeparator}");

            context.Logger.LogInformation(log.ToString());
        }