public void Execute(IJobExecutionContext context) { try { var container = EngineConnectUtility.GetShopsContainer(string.Empty, storefrontContext.CurrentStorefront.ShopName, storefrontContext.CurrentStorefront.Context.User.GetId().ToString()); Proxy.DoCommand(container.RunMinionNow("Sitecore.Commerce.Plugin.Orders.PendingOrdersMinionBoss, Sitecore.Commerce.Plugin.Orders", "HabitatMinions")); } catch (Exception ex) { Log.Error("Sitecron: Commerce.RunMinionNow: ERROR something went wrong - " + ex.Message, ex, this); } }
protected ProductCompareResult AddToCompare(string shopName, string customerId, string catalogName, string productId, string varientId) { try { var container = EngineConnectUtility.GetShopsContainer(shopName: shopName, customerId: customerId); Proxy.DoCommand(container.AddProductToComparison(customerId, catalogName, productId, varientId)); } catch (Exception ex) { Log.Error($"Unable to add product to Compare for shopName:'{shopName}', customerId'{customerId}'", ex, this); } return(LoadCompare(shopName, customerId)); }
protected ProductCompareResult LoadCompare(string shopName, string customerId) { var ProductComparisonResult = new ProductCompareResult(); try { var container = EngineConnectUtility.GetShopsContainer(shopName: shopName, customerId: customerId); var dataServiceActionQuerySingle = container.Compare.ByKey(customerId).Expand("Products"); ProductComparisonResult.ProductComparison = Proxy.GetValue(dataServiceActionQuerySingle); ProductComparisonResult.Success = true; } catch (Exception ex) { Log.Error($"Unable to retrieve Product Compare for shopName:'{shopName}', customerId'{customerId}'", ex, this); } return(ProductComparisonResult); }
private void InvalidateCommerceCache() { ICache <string> cache = CacheManager.FindCacheByName <string>("CommerceCache.Default"); if (cache != null) { cache.Clear(); Log.Info(string.Format("Manually Cleared Commerce Cache ({0}) via Sitecore Interface", cache.Name), this); } CatalogRepository.MappingEntries = null; Log.Info("Manually Cleared Commerce Cache (CatalogRepository.MappingEntries) via Sitecore Interface", this); EngineConnectUtility.RefreshSitecoreCaches("web"); Log.Info("Manually Cleared Commerce Cache ( EngineConnectUtility.RefreshSitecoreCaches[web]) via Sitecore Interface", this); var ceConfig = (CommerceEngineConfiguration)Factory.CreateObject("commerceEngineConfiguration", true); var client = GetClient(ceConfig); var commerceEndpoint = "RequestCacheReset()"; // var opsApi = "commerceops"; if (string.IsNullOrEmpty(commerceEndpoint)) { throw new ConfigurationErrorsException("Missing Commerce endpoint configuration."); } var content = new MultipartFormDataContent { { new StringContent(ceConfig.DefaultEnvironment), "environmentName" }, { new StringContent(ceConfig.DefaultEnvironment), "cacheStoreName" } }; var result = client.PutAsync(commerceEndpoint, content).Result; if (result.IsSuccessStatusCode) { Log.Info("Manually Cleared Commerce Cache (Shops Cache) via Sitecore Interface", this); } else { var error = result.Content.ReadAsStringAsync().Result; Log.Error($"Could not clear shops cache, error: {error}", this); } }
/// <summary> /// The get container. /// </summary> /// <param name="shopName"> /// The shop name. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <param name="customerId"> /// The customer id. /// </param> /// <param name="language"> /// The language. /// </param> /// <param name="currency"> /// The currency. /// </param> /// <param name="effectiveDate"> /// The effective date. /// </param> /// <returns> /// The <see cref="Container"/>. /// </returns> public Container GetContainer( string shopName, string userId, string customerId = "", string language = "", string currency = "", DateTime?effectiveDate = new DateTime?()) { return(EngineConnectUtility.GetShopsContainer( string.Empty, shopName, userId, customerId, language, currency, effectiveDate)); }
protected RemoveFromCompareResult RemoveFromCompare(string shopName, string customerId, string sellableItemId) { var result = new RemoveFromCompareResult { RemovedSellableItemId = sellableItemId }; try { var container = EngineConnectUtility.GetShopsContainer(shopName: shopName, customerId: customerId); Proxy.DoCommand(container.RemoveProductFromComparison(customerId, sellableItemId)); result.Success = true; } catch (Exception ex) { Log.Error($"Unable to add product to Compare for shopName:'{shopName}', customerId'{customerId}'", ex, this); } return(result); }
protected GetLoyaltyOrderResult GetLoyaltyOrderFromEngine(string shopName, string customerId, string orderId) { var result = new GetLoyaltyOrderResult(); try { var container = EngineConnectUtility.GetShopsContainer(shopName: shopName, customerId: customerId); Sitecore.Commerce.Plugin.Orders.Order order = Proxy.GetValue <Sitecore.Commerce.Plugin.Orders.Order>(container.Orders.ByKey(orderId).Expand("Lines($expand=CartLineComponents),Components")); if (order != null) { result.LoyaltyOrder = order; result.Success = true; } } catch (Exception ex) { Log.Error($"Unable to get order:'{orderId}' shopName:'{shopName}', customerId'{customerId}'", ex, this); } return(result); }
public void Process(ServicePipelineArgs args) { AddPaymentInfoRequest request; AddPaymentInfoResult result; request = args.Request as AddPaymentInfoRequest; result = args.Result as AddPaymentInfoResult; if (request.Payments.Any(p => p is SimplePaymentInfo)) { var cart = request.Cart; var container = EngineConnectUtility.GetShopsContainer(shopName: cart.ShopName, customerId: cart.CustomerId); foreach (var payment in request.Payments.Where(p => p is SimplePaymentInfo).Select(p => TranslatePayment((SimplePaymentInfo)p)).ToList()) { var command = Proxy.DoCommand(container.AddSimplePayment(cart.ExternalId, payment)); result.HandleCommandMessages(command); } // Remove the SimplePaymentInfo payments from the list of payments, so they are not evaluated by other processors request.Payments = request.Payments.Where(p => !(p is SimplePaymentInfo)).ToList(); } }
protected virtual void ClearItemCache(Item productItem) { var cache = CacheManager.FindCacheByName <string>("CommerceCache.Default"); if (cache != null) { cache.Clear(); } EngineConnectUtility.RefreshSitecoreCaches("web"); EngineConnectUtility.RefreshSitecoreCaches("master"); CacheManager.ClearAllCaches(); //productItem.Database.Caches.DataCache.RemoveItemInformation(productItem.ID); ////clear item cache //productItem.Database.Caches.ItemCache.RemoveItem(productItem.ID); ////clear standard values cache //productItem.Database.Caches.StandardValuesCache.RemoveKeysContaining(productItem.ID.ToString()); ////remove path cache //productItem.Database.Caches.PathCache.RemoveKeysContaining(productItem.ID.ToString()); //foreach (var cache in global::Sitecore.Caching.CacheManager.GetAllCaches()) //{ // if (cache.Name.Contains(string.Format("Prefetch data({0})", productItem.Database.Name))) // { // cache.Clear(); // } //} //foreach (var info in Factory.GetSiteInfoList()) //{ // info.HtmlCache.Clear(); //} }