Ejemplo n.º 1
0
        public IEnumerable <IEntity> Convert(CatalogEntryDto.CatalogEntryRow entry, IEnumerable <string> languages, CatalogDto.CatalogRow catalog,
                                             ESalesVariantHelper variantHelper)
        {
            var entities = GetEntities(entry, languages, catalog.Name, variantHelper);

            return(entities);
        }
Ejemplo n.º 2
0
        private IEnumerable <IEntity> GetEntities(CatalogEntryDto.CatalogEntryRow entry, IEnumerable <string> languages, string catalogName,
                                                  ESalesVariantHelper variantHelper)
        {
            foreach (var language in languages)
            {
                var locale     = language.ToESalesLocale();
                var attributes = new List <Attribute>
                {
                    NewAttribute("id", entry.CatalogEntryId + "_" + language),
                    NewAttribute("_id", entry.CatalogEntryId),
                    NewAttribute("code", entry.Code),
                    NewAttribute("name", entry.Name),
                    NewAttribute("_lang", language),
                    NewAttribute("locale", locale),
                    NewAttribute("locale_filter", locale),
                    NewAttribute("startdate", entry.StartDate),
                    NewAttribute("enddate", entry.EndDate),
                    NewAttribute("_classtype", entry.ClassTypeId.ToLowerInvariant()),
                    NewAttribute("_catalog", catalogName),
                    NewAttribute("product_url", _urlResolver.GetEntryUrl(entry, language))
                };
                attributes.AddRange(GetPrices(entry));
                attributes.AddRange(GetNodeEntryRelations(catalogName, new CatalogEntryRowMapper(entry)));
                attributes.AddRange(GetMetaData(entry, language));
                AddAds(entry, attributes);
                AddFacets(attributes);

                var filteredAttributes = FilterConfiguredAttributes(attributes);

                yield return(GetEntity(entry, variantHelper, language, filteredAttributes));
            }
        }
 private void UpdateProduct(CatalogEntryDto.CatalogEntryRow entry, string[] languages, CatalogDto.CatalogRow catalog,
                            ESalesVariantHelper variantHelper)
 {
     if (_incremental)
     {
         // Variants might have changed from products -> variants, so delete as products just in case.
         var variantEntries = variantHelper.GetVariants(entry.CatalogEntryId).Select(v => _catalogSystem.GetCatalogEntry(v));
         RemoveProducts(new[] { entry }.Concat(variantEntries), languages);
     }
     Add(entry, languages, catalog, variantHelper);
 }
Ejemplo n.º 4
0
        private IEntity GetEntity(CatalogEntryDto.CatalogEntryRow entry, ESalesVariantHelper variantHelper, string language,
                                  IEnumerable <Attribute> attributes)
        {
            var keyValue = _keyLookup.Value(entry, language);

            if (variantHelper.IsVariant(entry.CatalogEntryId))
            {
                var productKey = _keyLookup.Value(_catalogSystem.GetCatalogEntry(variantHelper.GetParentProduct(entry.CatalogEntryId)), language);
                return(new Variant(keyValue, productKey, attributes));
            }
            return(new Product(keyValue, attributes));
        }
 private void Add(CatalogEntryDto.CatalogEntryRow entry, IEnumerable <string> languages, CatalogDto.CatalogRow catalog,
                  ESalesVariantHelper variantHelper)
 {
     foreach (var convertedEntry in _entryConverter.Convert(entry, languages, catalog, variantHelper))
     {
         var entity = convertedEntry;
         if (_converterPlugin != null)
         {
             entity = _converterPlugin.Convert(convertedEntry);
         }
         _writer.Add(entity);
     }
 }
        private void IndexEntry(CatalogEntryDto.CatalogEntryRow entry, string[] languages, CatalogDto.CatalogRow catalog,
                                ESalesVariantHelper variantHelper)
        {
            if (variantHelper.IsVariant(entry.CatalogEntryId))
            {
                Add(entry, languages, catalog, variantHelper);
            }
            else
            {
                UpdateProduct(entry, languages, catalog, variantHelper);
            }

            ReportAddProgress();
        }
        private void WriteDocuments(CatalogDto.CatalogRow catalog, string[] languages)
        {
            var variantHelper        = new ESalesVariantHelper(GetRelations(catalog.CatalogId));
            var catalogEntryProvider = CatalogEntryProviderFactory.Create(_incremental, catalog.CatalogId, variantHelper, _catalogSystem, _indexSystem);

            _progress.TotalNbrOfEntries = catalogEntryProvider.Count;
            var firstCatalogEntryId = int.MaxValue;
            var lastCatalogEntryId  = int.MinValue;

            _indexSystem.Log("Begin indexing catalog \"{0}\" in eSales...", _progress.GetCurrentProgressPercent(), catalog.Name);

            foreach (var entry in catalogEntryProvider.GetCatalogEntries())
            {
                SetFirstAndLastEntry(entry.CatalogEntryId, ref firstCatalogEntryId, ref lastCatalogEntryId);
                IndexEntry(entry, languages, catalog, variantHelper);
            }

            _progress.IncreaseCatalogCount();
            _indexSystem.Log("Done indexing catalog \"{0}\".", _progress.GetCurrentProgressPercent(), catalog.Name);
            _indexSystem.SetBuildProperties(firstCatalogEntryId, lastCatalogEntryId, catalog.Name);
        }