Ejemplo n.º 1
0
        private void IndexProduct(Product p, string culture)
        {
            var storeId      = p.StoreId;
            var documentId   = p.Bvin;
            var documentType = (int)SearchManagerObjectType.Product;
            var title        = p.ProductName + " | " + p.Sku;
            var scoredparts  = new Dictionary <string, int>();

            ParseAndValue(p.Sku, culture, SearchManagerImportance.Highest, scoredparts, 10);
            ParseAndValue(p.ProductName, culture, SearchManagerImportance.Highest, scoredparts, 20);
            ParseAndValue(p.MetaTitle, culture, SearchManagerImportance.High, scoredparts, 20);
            ParseAndValue(p.MetaKeywords, culture, SearchManagerImportance.High, scoredparts, 20);

            ParseAndValue(p.MetaDescription, culture, SearchManagerImportance.Normal, scoredparts, 20);
            ParseAndValue(p.LongDescription, culture, SearchManagerImportance.Normal, scoredparts, 100);
            ParseAndValue(p.Keywords, culture, SearchManagerImportance.Normal, scoredparts, 20);

            if (p.HasVariants())
            {
                foreach (var v in p.Variants)
                {
                    if (v.Sku != p.Sku)
                    {
                        ParseAndValue(v.Sku, culture, SearchManagerImportance.Highest, scoredparts, 10);
                    }
                }
            }

            var optiontext = string.Empty;

            if (p.HasOptions())
            {
                foreach (var opt in p.Options)
                {
                    optiontext += opt.Name + " ";
                    foreach (var item in opt.Items)
                    {
                        optiontext += item.Name + " ";
                    }
                }
            }
            ParseAndValue(optiontext, culture, SearchManagerImportance.NormalHigh, scoredparts, 10);

            using (MiniProfiler.Current.Step("Search Index Rebuilt For Product"))
            {
                var objectId = DataTypeHelper.BvinToGuid(documentId);
                searcher.AddObjectIndex(storeId, objectId, documentType, title, scoredparts, culture);
            }
        }