コード例 #1
0
        private void ProcessTaxonomy(TaxonomyInfo taxonomy)
        {
            // set formatted taxonomy string
            var taxonomyString = taxonomy.ToString(_args.IgnoreT1Taxonomy);

            // get list of SKUs for this taxonomy
            var allSkus = taxonomy.GetSkus(_args.ExportCrossListNodes);

            if (!allSkus.Any())
            {
                return;
            }

            // filter skus based on sku inclusions and exclusions, then include only Product skus.
            var skus = _args.GetFilteredSkuList(allSkus).ToList();

            // process each sku...
            skus.ForEach(sku =>
            {
                // write line to attribute file
                if (taxonomy.NodeType == TaxonomyInfo.NodeTypeDerived)
                {
                    var firstOrDefault = sku.SkuInfos.FirstOrDefault(a => a.Active);
                    if (firstOrDefault != null)
                    {
                        var originalTaxonomy = firstOrDefault.TaxonomyInfo;
                        var attributes       = GetExportAttributes(originalTaxonomy);
                        ProcessAttributes(sku, "Cross List",
                                          taxonomyString + TaxonomyInfo.CROSS_PREFIX +
                                          originalTaxonomy.ToString(), attributes);
                    }
                }
                else
                {
                    var attributes = GetExportAttributes(taxonomy);
                    ProcessAttributes(sku, TaxonomyInfo.NodeTypeRegular, taxonomyString, attributes);
                }
            });
        }
コード例 #2
0
        private void ProcessTaxonomy(TaxonomyInfo taxonomy)
        {
            // set formatted taxonomy string
            var taxonomyString = taxonomy.ToString(_args.IgnoreT1Taxonomy);

            // get list of SKUs for this taxonomy
            var allSkus = taxonomy.GetSkus(_args.ExportCrossListNodes);

            if (!allSkus.Any())
            {
                return;
            }

            // filter skus based on sku inclusions and exclusions, then include only Product skus.
            var skus = _args.GetFilteredSkuList(allSkus).ToList();

            // process each sku...
            skus.ForEach(sku =>
            {
                // get data on this sku's taxonomy history
                var taxonomies = sku.SkuInfos.Select(
                    si =>
                    new
                {
                    Taxonomy          = si.TaxonomyInfo.OldString(),
                    SkuAssignedOn     = si.CreatedOn,
                    SkuAssignedBy     = si.User.FullName,
                    SkuAssignRemark   = (si.CreatedRemark == null) ? String.Empty : si.Remark.Remark1,
                    TaxonomyCreatedOn = si.TaxonomyInfo.OldTaxonomyData == null
                                ? string.Empty
                                : si.TaxonomyInfo.OldTaxonomyData.CreatedOn.ToString(CultureInfo.InvariantCulture),
                    TaxonomyCreatedBy = si.TaxonomyInfo.OldTaxonomyData == null
                                ? string.Empty
                                : si.TaxonomyInfo.OldTaxonomyData.User.FullName
                }).Where(d => !string.IsNullOrWhiteSpace(d.Taxonomy));

                // write line to taxonomy file
                if (taxonomy.NodeType == TaxonomyInfo.NodeTypeDerived)
                {
                    var firstOrDefault = sku.SkuInfos.FirstOrDefault(a => a.Active);
                    if (firstOrDefault != null)
                    {
                        var originalTaxonomy = firstOrDefault.TaxonomyInfo;
                        WriteTaxonomyRow(sku.ItemID, taxonomyString + TaxonomyInfo.CROSS_PREFIX +
                                         originalTaxonomy.ToString(), "Cross List", taxonomyString);
                    }
                }
                else
                {
                    var firstOrDefault = taxonomies.FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        WriteTaxonomyRow(sku.ItemID, taxonomyString, TaxonomyInfo.NodeTypeRegular, firstOrDefault.Taxonomy);
                    }
                }

                // write line to attribute file
                if (taxonomy.NodeType == TaxonomyInfo.NodeTypeDerived)
                {
                    var firstOrDefault = sku.SkuInfos.FirstOrDefault(a => a.Active);
                    if (firstOrDefault != null)
                    {
                        var originalTaxonomy = firstOrDefault.TaxonomyInfo;
                        var attributes       = GetExportAttributes(originalTaxonomy);
                        ProcessAttributes(sku, originalTaxonomy, "Cross List",
                                          taxonomyString + TaxonomyInfo.CROSS_PREFIX +
                                          originalTaxonomy.ToString(), attributes);
                    }
                }
                else
                {
                    var attributes = GetExportAttributes(taxonomy);
                    ProcessAttributes(sku, taxonomy, TaxonomyInfo.NodeTypeRegular, taxonomyString, attributes);
                }
            });
        }