예제 #1
0
        protected override void OnCatalogEntryIndex(ref SearchDocument document, Mediachase.Commerce.Catalog.Dto.CatalogEntryDto.CatalogEntryRow entry, string language)
        {
            if (entry != null && entry.ClassTypeId.Equals(EntryType.Product, StringComparison.InvariantCultureIgnoreCase))
            {
                if (!MetaDataContextClone.Language.Equals(language, StringComparison.InvariantCultureIgnoreCase))
                {
                    MetaDataContextClone.Language = language;
                }

                CatalogRelationDto relationDto = _catalog.GetCatalogRelationDto(0, 0, entry.CatalogEntryId, string.Empty,
                                                                                new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogEntry));

                if (relationDto != null && relationDto.CatalogEntryRelation != null && relationDto.CatalogEntryRelation.Count > 0)
                {
                    List <int> childIds = new List <int>();

                    foreach (CatalogRelationDto.CatalogEntryRelationRow relationRow in relationDto.CatalogEntryRelation)
                    {
                        childIds.Add(relationRow.ChildEntryId);
                    }

                    CatalogEntryDto skuDto = _catalog.GetCatalogEntriesDto(childIds.ToArray(),
                                                                           new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

                    List <string> searchProperties = new List <string>
                    {
                        SearchField.Store.NO,
                        SearchField.Index.TOKENIZED,
                        SearchField.IncludeInDefaultSearch.YES
                    };

                    List <string> colorVariations = new List <string>();
                    if (skuDto != null && skuDto.CatalogEntry != null && skuDto.CatalogEntry.Count > 0)
                    {
                        foreach (CatalogEntryDto.CatalogEntryRow row in skuDto.CatalogEntry)
                        {
                            Hashtable hash = ObjectHelper.GetMetaFieldValues(row);
                            if (hash.Contains("Color"))
                            {
                                string color = hash["Color"].ToString();
                                if (!string.IsNullOrEmpty(color) && !colorVariations.Contains(color.ToLower()))
                                {
                                    colorVariations.Add(color.ToLower());
                                    document.Add(new SearchField("Color", color.ToLower(), searchProperties.ToArray()));
                                    OnSearchIndexMessage(new Mediachase.Search.SearchIndexEventArgs(
                                                             $"The color {color} was added to the index for {entry.Name}.", 1));
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
 public CatalogRelationDto.CatalogEntryRelationDataTable GetCatalogRelations(int catalogId)
 {
     return
         (_catalogSystem.GetCatalogRelationDto(catalogId, 0, 0, "", new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogEntry))
          .CatalogEntryRelation);
 }
예제 #3
0
 /// <summary>
 /// Gets the catalog relation dto.
 /// </summary>
 /// <param name="catalogId">The catalog id.</param>
 /// <param name="catalogNodeId">The catalog node id.</param>
 /// <param name="catalogEntryId">The catalog entry id.</param>
 /// <param name="groupName">Name of the group.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogRelationDto GetCatalogRelationDto(int catalogId, int catalogNodeId, int catalogEntryId, string groupName, CatalogRelationResponseGroup responseGroup)
 {
     return(_Proxy.GetCatalogRelationDto(catalogId, catalogNodeId, catalogEntryId, groupName, responseGroup));
 }