public void RebuildProductSearchIndex(MerchantTribeApplication app) { MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer = new MerchantTribe.Web.Search.Indexers.ComplexIndexer(searcher); int totalProducts = app.CatalogServices.Products.FindAllForAllStoresCount(); int totalPages = MerchantTribe.Web.Paging.TotalPages(totalProducts, INDEXREBUILDPAGESIZE); for (int i = 1; i <= totalPages; i++) { IndexAPage(i, indexer, app); } }
private void IndexAPage(int pageNumber, MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer, MerchantTribeApplication app) { int startIndex = MerchantTribe.Web.Paging.StartRowIndex(pageNumber, INDEXREBUILDPAGESIZE); List <Product> page = app.CatalogServices.Products.FindAllPagedForAllStores(startIndex, INDEXREBUILDPAGESIZE); if (page != null) { foreach (Product p in page) { IndexProduct(p, indexer); } } }
//private void IndexProduct(string productBvin, BVSoftware.Search.Indexers.ComplexIndexer indexer) //{ // Product p = Catalog.Product.FindByBvinForAllStores(productBvin); // IndexProduct(p, indexer); //} private void IndexProduct(Product p, MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer) { if (p != null) { long storeId = p.StoreId; string documentId = p.Bvin; int documentType = (int)SearchManagerObjectType.Product; string title = p.ProductName + " | " + p.Sku; Dictionary <string, int> scoredparts = new Dictionary <string, int>(); ParseAndValue(p.Sku, SearchManagerImportance.Highest, scoredparts, 10); ParseAndValue(p.ProductName, SearchManagerImportance.Highest, scoredparts, 20); ParseAndValue(p.MetaTitle, SearchManagerImportance.High, scoredparts, 20); ParseAndValue(p.MetaKeywords, SearchManagerImportance.High, scoredparts, 20); ParseAndValue(p.MetaDescription, SearchManagerImportance.Normal, scoredparts, 20); ParseAndValue(p.LongDescription, SearchManagerImportance.Normal, scoredparts, 100); ParseAndValue(p.Keywords, SearchManagerImportance.Normal, scoredparts, 20); if (p.HasVariants()) { foreach (Variant v in p.Variants) { if (v.Sku != p.Sku) { ParseAndValue(v.Sku, SearchManagerImportance.Highest, scoredparts, 10); } } } string optiontext = string.Empty; if (p.HasOptions()) { foreach (Option opt in p.Options) { optiontext += opt.Name + " "; foreach (OptionItem item in opt.Items) { optiontext += item.Name + " "; } } } ParseAndValue(optiontext, SearchManagerImportance.NormalHigh, scoredparts, 10); indexer.Index(storeId, documentId, documentType, title, scoredparts); } }
// Products public void IndexSingleProduct(Catalog.Product p) { MerchantTribe.Web.Search.Indexers.ComplexIndexer indexer = new MerchantTribe.Web.Search.Indexers.ComplexIndexer(searcher); IndexProduct(p, indexer); }