Пример #1
0
 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);
        }
 /// <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);
        }
Пример #6
0
        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();
            }
        }