Ejemplo n.º 1
0
 // Create or Update
 public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata)
 {
     string data = string.Empty;
     string objecttype = FirstParameter(parameters);
     string objectid = GetParameterByIndex(1, parameters);
     ApiResponse<bool> response = new ApiResponse<bool>();
     
     try
     {
         if (objecttype.Trim().ToLowerInvariant() == "products")
         {
             SearchManager m = new SearchManager();
             Product p = MTApp.CatalogServices.Products.Find(objectid);
             if (p != null)
             {
                 if (p.Bvin.Length > 0)
                 {
                     m.IndexSingleProduct(p);
                     response.Content = true;
                 }
             }                    
         }                                
     }
     catch(Exception ex)
     {
         response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
         return MerchantTribe.Web.Json.ObjectToJson(response);                
     }
                 
     data = MerchantTribe.Web.Json.ObjectToJson(response);            
     return data;
 }
Ejemplo n.º 2
0
 public ActionResult RebuildSearchPost()
 {
     SearchManager manager = new SearchManager();
     manager.RebuildProductSearchIndex(MTApp);
     TempData["message"] = "Finished rebuild at " + DateTime.Now.ToLocalTime();                        
     return View();
 }
Ejemplo n.º 3
0
        public ActionResult Search(string keyword)
        {
            string r = "No Results Found";

            SearchManager searcher = new SearchManager();
            int total = 0;
            List<SearchObject> results = searcher.DoSearchForAllStores(keyword.Trim(), 1, 100, ref total);

            if (results != null)
            {
                r = "Found " + total.ToString() + " matches";
                r += "<ul>";

                foreach (SearchObject obj in results)
                {
                    r += "<li>";
                    r += obj.Title;
                    r += "</li>";
                }
                r += "</ul>";
            }

            TempData["results"] = r;
            return View();
        }
Ejemplo n.º 4
0
        public bool ProductsUpdateWithSearchRebuild(Product item)
        {
            bool success = this.Products.Update(item);

            if (success)
            {
                SearchManager manager = new SearchManager();
                manager.IndexSingleProduct(item);
            }
            return(success);
        }
Ejemplo n.º 5
0
        public ActionResult Index(string q)
        {
            // Initial Setup
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.Search);
            ViewBag.MetaTitle = ViewBag.Title + " | " + q;
            ViewBag.MetaDescription = ViewBag.MetaTitle;
            ViewBag.BodyClass = "store-search-page";
            ViewBag.GoButtonUrl = MTApp.ThemeManager().ButtonUrl("Go", Request.IsSecureConnection);
            ViewBag.q = q;

            // Pager Vars
            int pageNumber = GetPageNumber();
            int pageSize = 9;
            int totalItems = 0;

            // Do Search
            CategoryPageViewModel model = new CategoryPageViewModel();
            SearchManager manager = new SearchManager();
            List<SearchObject> objects = manager.DoSearch(MTApp.CurrentStore.Id, 
                                                        q, pageNumber, 
                                                        pageSize, ref totalItems);
            List<string> ids = new List<string>();
            foreach (SearchObject o in objects)
            {
                switch (o.ObjectType)
                {
                    case (int)SearchManagerObjectType.Product:
                        ids.Add(o.ObjectId);
                        break;
                }
            }
            List<Product> products = MTApp.CatalogServices.Products.FindMany(ids);

            // Save to Model
            model.Products = PrepProducts(products);            
            model.PagerData.PageSize = pageSize;
            model.PagerData.TotalItems = totalItems;
            model.PagerData.CurrentPage = pageNumber;
            model.PagerData.PagerUrlFormat = Url.Content("~/search?q=" + HttpUtility.UrlEncode(q) + "&p={0}");
            model.PagerData.PagerUrlFormatFirst = Url.Content("~/search?q=" + HttpUtility.UrlEncode(q));            

            return View(model);
        }
Ejemplo n.º 6
0
 public bool ProductsUpdateWithSearchRebuild(Product item)
 {
     bool success = this.Products.Update(item);
     if (success)
     {
         SearchManager manager = new SearchManager();
         manager.IndexSingleProduct(item);
     }
     return success;
 }
Ejemplo n.º 7
0
        //Products
        public bool ProductsCreateWithInventory(Product item, bool rebuildSearchIndex)
        {
            if (item == null) return false;
            if (item.UrlSlug.Trim().Length < 1)
            {
                item.UrlSlug = MerchantTribe.Web.Text.Slugify(item.ProductName, true, true);
            }

            bool result = this.Products.Create(item);
            if (rebuildSearchIndex)
            {
                SearchManager manager = new SearchManager();
                manager.IndexSingleProduct(item);
            }
            if (result)
            {
                InventoryGenerateForProduct(item);
                UpdateProductVisibleStatusAndSave(item);
            }
            return result;
        }