Commerce 9 Oktober 2015 Petter Sørby Agenda Ytelsesforbedringer Workflow Kampanje/promotion API endringer Bonusfeature Ytelsesforbedringer TID • Ytelse har vært hovedfokus siste året • Tidligere oppdateringer har kraftig redusert tidsforbruk • Endret struktur for versjoner og kladder 120 100 80 60 40 20 0 7.5 9.0 Workflow • Windows Workflow Foundation – Enkelt å legge til egne steg – Små konkrete oppgaver i hver aktivitet – Brukt til raske oppgaver med definert start og stop. Ment for oppgaver som kan starte og stoppe • Manglende støtte i Visual Studio • Problematisk å bruke i senere versjon. – Forutsetter kompilering med riktig versjon Checkout <SequentialWorkflowActivity x:Class="EPiCode.Commerce.Workflow.CartCheckoutWorkflow" x:Name="CartCheckoutWorkflow" xmlns:ns0="clrnamespace:EPiCode.Commerce.Workflow.Activities;Assembly=EPiCode.Commerce.Workflow.Activities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow"> <IfElseActivity x:Name="ifElseActivity1"> <IfElseBranchActivity x:Name="ifElseBranchActivity1"> <IfElseBranchActivity.Condition> <CodeCondition Condition="RunProcessPayment" /> </IfElseBranchActivity.Condition> <ns0:ProcessPaymentActivity Warnings="{x:Null}" OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" Payment="{x:Null}" x:Name="processPaymentActivity1" /> </IfElseBranchActivity> </IfElseActivity> <ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity1" OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" Warnings="{x:Null}" /> <IfElseActivity x:Name="ifElseActivity2"> <IfElseBranchActivity x:Name="ifElseBranchActivity2"> <IfElseBranchActivity.Condition> <CodeCondition Condition="CheckInstoreInventory" /> </IfElseBranchActivity.Condition> <ns0:AdjustInstoreInventoryActivity PickupWarehouseInShipment="{ActivityBind CartCheckoutWorkflow,Path=PickupWarehouseInShipment}" Warnings="{ActivityBind CartCheckoutWorkflow,Path=Warnings}" Description="Adjusts In Store Inventory." OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" x:Name="adjustInstoreInventoryActivity1" /> </IfElseBranchActivity> <IfElseBranchActivity x:Name="ifElseBranchActivity3"> <ns0:AdjustInventoryActivity Description="Adjusts Inventory." x:Name="adjustInventoryActivity1" OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" Warnings="{x:Null}" /> </IfElseBranchActivity> </IfElseActivity> <ns0:RecordPromotionUsageActivity UsageStatus="Used" Warnings="{x:Null}" OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" x:Name="recordPromotionUsageActivity1" /> <ns0:CreatePurchaseOrderActivity x:Name="createPurchaseOrderActivity1" OrderGroup="{ActivityBind CartCheckoutWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartCheckoutWorkflow,Path=Warnings}" /> </SequentialWorkflowActivity> Activity Flow [ActivityFlowConfiguration(Name = OrderGroupWorkflowManager.CartCheckOutWorkflowName)] public class CartCheckoutActivityFlow : ActivityFlow { public override ActivityFlowRunner Configure(ActivityFlowRunner activityFlow) { return activityFlow .If(() => ShouldProcessPayment()) .Do<ProcessPaymentActivity>() .EndIf() .Do<CalculateTotalsActivity>() .Do<AdjustInventoryActivity>() .Do<RecordPromotionUsageActivity>(); } } ExecutionManager • Registrerer ActivityFlow implementasjoner • Vurderer prioritet – Høyere prioritet «vinner» ved samme navn – [ActivityFlowConfiguration(Name = OrderGroupWorkflowManager.CartValidateWorkflowName)] public class CartValidateActivityFlow : ActivityFlow {...} – [ActivityFlowConfiguration(Name = OrderGroupWorkflowManager.CartValidateWorkflowName, Priority=1)] public class CustomCartValidateActivityFlow : ActivityFlow {...} • OrderGroupWorkflowManager ‐> ExecutionManager – Sender inn cart – I fremtidige versjoner vil muligens ExecutionManager brukes direkte EPiServer.Commerce.Tools.WorkflowMigration Workflow Marketing • Ny rabatt/kampanjestyring • Enklere (mer kjent) for redaktører • Forbedret testbarhet for utviklere Marketing / Promotion (Beta) • Tilgjengeliggjøre <add name="EPiBetaUsers" type="EPiServer.Security.MappedRole, EPiServer.Framework" roles="WebEditors, WebAdmins, Administrators" mode="Any" /> • Prosessere <Features> <add feature="WorkflowsVNext" state="Enabled" type="Mediachase.Commerce.Core.Features.WorkflowsVNext" /> </Features> Promotion/Discount Data Result Processor Promotion Data • IContent • PromotionData – EntryPromotion – OrderPromotion – ShippingPromotion • Definerer egenskaper for å validere og angi rabatten Processor • PromotionProcessorBase<T> where T : PromotionData – public IPromotionResult Evaluate(IOrderGroup orderGroup, PromotionData promotionData) • Validerer gyldighet av en rabatt • Returnerer IPromotionResult med FulfillmentStatus – NotFulfilled, SomewhatFulfilled, AlmostFulfilled, Fulfilled Result • IPromotionResult • ApplyReward. Blir kalt når FulfillementStatus er Fulfilled • Gjør selve beregningen/endring av handlekurven Promotion Nye deler av APIet Ordreobjekter • • • • • • IOrderRepository IOrderGroup IOrderForm IShipment ILineItem IOrderAddress «Kalkulatorer» • • • • • ITaxCalculator IShippingCalculator IOrderGroupCalculator IOrderFormCalculator ILineItemCalculator Add to cart 9.0 public void AddToCart(VariationContent variation, int quantity, IPriceService priceService, ICurrentMarket market) { var OrderRepository = ServiceLocator.Current.GetInstance<IOrderRepository>(); var cart = OrderRepository.Load<Cart>(GetContactId(),Cart.DefaultName).FirstOrDefault(); if (cart == null){ cart = OrderRepository.Create<Cart>(GetCommerceCustomerId(), Cart.DefaultName); cart.CustomerName = PrincipalInfo.CurrentPrincipal.Identity.Name; var orderReference = OrderRepository.Save(cart); } var price = priceService.GetDefaultPrice(market.GetCurrentMarket().MarketId, DateTime.UtcNow, new CatalogKey(new Guid(variation.ApplicationId), variation.Code), SiteContext.Current.Currency); var lineItem = CreateLineItem(variation, quantity, price.UnitPrice.Amount); var orderForm = cart.OrderForms.First(); orderForm.LineItems.Add(lineItem); var index = orderForm.LineItems.IndexOf(lineItem); cart.OrderForms.First().Shipments.First().AddLineItemIndex(index, lineItem.Quantity); OrderRepository.Save(cart); cart = OrderRepository.Load<Cart>(GetCommerceCustomerId(), Cart.DefaultName).FirstOrDefault(); PromotionEngine.Run(cart); OrderRepository.Save(cart); } Add to cart 9.2 public void AddToCart(VariationContent variation, int quantity, IPriceService priceService, ICurrentMarket market) { var OrderRepository = ServiceLocator.Current.GetInstance<IOrderRepository>(); var cart = OrderRepository.LoadOrCreate<Cart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName).FirstOrDefault(); var price = PriceService.GetDefaultPrice(market.GetCurrentMarket().MarketId,DateTime.UtcNow, new CatalogKey(new Guid(variation.ApplicationId), variation.Code),Context.Current.Currency); var lineItem = CreateLineItem(variation, quantity, price.UnitPrice.Amount); cart.Forms.First().Shipments.First().LineItems.Add(lineItem); PromotionEngine.Run(cart); OrderRepository.Save(cart); } OPPGAVER TIL NESTE DEPLOY! Endre startsiden Opprett artikkelside under FAQ Kontakt oss etc. Alle sider må opprettes på samtlige språk. Innhold finner du på h:\felles\...\...\...\deployment.v12.34.5 \tekster.txt Migration Steps [ServiceConfiguration(typeof(IMigrationStep))] public class ChangeSettingsMigrationStep : IMigrationStep Migration
© Copyright 2024