Quantcast
Channel: Optimizely Search & Navigation
Viewing all 6894 articles
Browse latest View live

Exception when adding/updating cart or listing cart items, problem with workflow

$
0
0

Hi!

We are running Commerce 11.2.2 and are still using workflows. We just found out that exceptions are caught when we run the CartValidate workflow.

Our code:

public bool AddToCart(string code, decimal quantity, out string warningMessage)
        {
            var entry = CatalogContext.Current.GetCatalogEntry(code);
            if (SiteContext.Current.Currency != _cartHelper.Cart.BillingCurrency)
            {
                SiteContext.Current.Currency = _cartHelper.Cart.BillingCurrency;
            }
            var lineItem = _cartHelper.AddEntry(entry, quantity, false);
            // If this is not set explicitly, 
            // place price does not get updated by workflow
            _cartHelper.Cart.ProviderId = "frontend";
            ValidateCart(out warningMessage);
            return _cartHelper.LineItems.Select(x => x.Code).Contains(code);
        }

Running this code gives us this exception:

Mediachase.BusinessFoundation.Data.Meta.ObjectNotFoundException: Object Contact.PrimaryKeyId = 'c0105be4-02c0-4bb5-a257-0b9c76dfa12e' not found
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject.GetRowSource
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject.Load
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject..ctor
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject..ctor
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Load
  at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Execute
  at Mediachase.BusinessFoundation.Data.Business.BaseRequestHandler.Mediachase.BusinessFoundation.Data.Business.IRequestHandler.Execute
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipeline
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipelineInTransaction
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Execute
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Load
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject.GetRowSource
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject.Load
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject..ctor
  at Mediachase.BusinessFoundation.Data.Meta.MetaObject..ctor
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Meta.MetaObjectActivator.CreateInstance
  at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Load
  at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Execute
  at Mediachase.BusinessFoundation.Data.Business.BaseRequestHandler.Mediachase.BusinessFoundation.Data.Business.IRequestHandler.Execute
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipeline
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipelineInTransaction
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Execute
  at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Load

Removing this line of code:

 ValidateCart(out warningMessage);

Which runs the CartValidate workflow, and the exception goes away so I guess there is something in the workflow.

The web works just fine, but I'm nort sure if this affects the perfrormance in any way?

/Kristoffer


Update all packages to support Newtonsoft.Json v12

$
0
0

Newtonsoft.Json is now in v12, it would be nice to be able to update to that version so please fix all your packages that has dependency to this to work with version 12

Putting 2 contentarea side-by-side

$
0
0

Hi, I am new on Episerver. This is my 1st project. I may be asking a very simple question.

I am puttting 2 content areas side-by-side.

<div class="row">
@Html.PropertyFor(x => x.CurrentPage.LeftContentArea,
new{CssClass = "col"})
<div class="w-100 d-sm-none">&nbsp;</div>
@Html.PropertyFor(x => x.CurrentPage.RecentlyUpdateContentArea,
new{CssClass = "col"})
</div>

In CMS edit mode, they go on-and-on downward. Is there any render setting I need to put in?

Thanks.

Null exception in commerce controller

$
0
0

I am trying to create controller fro commerce as explained in the link below. However, I am getting NULL exception in the parameter of action. e.g. 

currentContent is null in
public class AlloyCategoryController : ContentControllerBase<AlloyNode>
{    public ActionResult Index(AlloyNode currentContent)    {        var model = PageViewModel.Create<AlloyNode>(currentContent);        return View(model);    }
}

https://world.episerver.com/blogs/sorby/dates/2017/9/add-commerce-to-an-alloy-web-site/

CMS edit pages redirect issue

$
0
0

Hi Team,

I have a requirement of displaying child pages into grid format instead of out-of-box content tree structure. So i have implemented the logic in parent page type and getting all children pages into rows and binded to grid view. It's wokring fine, But i am facing couple of issues with this approach in CMS edit mode.

1) I need to provide "Edit" link to each row and by clicking on this, it should be open the child page in edit mode. I have tried with below code, it is opening but complete header & left menu reloaded inside.

            <a class="js-edit-link" href="@EPiServer.Editor.PageEditing.GetEditUrl(item.ContentLink)">Edit</a>

2) On child page publish, i should be able to redirect to parent page

3) Need to add "Add New" button on top of grid and by clicking on this it should open the child page to add new record.

I am assuming these issues should be addressed with DoJo scripting in CMS edit mode. Can anyone help me on the DoJo script sample references to override the behavior.

PartialRouter for Simple Address

$
0
0

Hi!

I'm quite new to EPi - working about half a year, and most of issues I had, was successfully solved with help of this forum and some EPi related blogs (jondjones; mathiaskunto). This time I'm having issue I can't deal with and hoping for advice from more experienced developers.

CMSversion: 10.10.4

The Issue

I have implemented partial router for specific page which just fetches two segments with strings and stores these into RouteData and also simple InitializationModule to register this router.

Everythings is working fine if I'm using full url to navigate to page - I can retrieve data in particular page controller from RouteData ( RouteData.Values[]).

Issue begins when I'm using Simple Address for that page - pages without these additional segments are working fine (routed & rendered), but page with these parameters are returning 404 error.

OK: http://localhost/en/all-posts/post-details/year/number (particular post - full hierarchy)
OK: http://localhost/all-posts/post-details/year/number (particular post - full hierarchy)
OK: http://localhost/en/all-posts (all post - full hierarchy)
OK: http://localhost/posts (all post - full hierarchy)

404: http://localhost/post/year/number (particular post - simple address)
Fail: http://localhost/post (particular post - simple address. Reaches controller but no RouteData)

Am I missing something? How can I make partial router work with SimpleAddress?

Hope that you understand my struggle :D

Used code parts

public class PostViewPagePartialRouter : IPartialRouter
{
	public PartialRouteData GetPartialVirtualPath(PostViewPage content, string language, RouteValueDictionary routeValues, RequestContext requestContext)
	{
		return null;
	}
	public object RoutePartial(PostViewPage content, SegmentContext segmentContext)
	{
		var nextValue = segmentContext.GetNextValue(segmentContext.RemainingPath);
		try
		{
			segmentContext.RouteData.Values["year"] = nextValue.Next;
			segmentContext.RouteData.Values["number"] = nextValue.Remaining;
			segmentContext.RemainingPath = string.Empty;
		}
		catch { }
		return content;
	}
}
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class PartialRoutersInitialization : IInitializableModule
{
	public void Initialize(InitializationEngine context)
	{
		RouteTable.Routes.RegisterPartialRouter(new PostViewPagePartialRouter());
	}
	public void Uninitialize(InitializationEngine context)
	{
		//Add uninitialization logic
	}
}

[v12.10 -> 12.16] Legacy Promotions - Code column missing from UI after upgrade

$
0
0

Hi,

I've just upgraded our Commerce Manager and Commerce Manager Core packages from 12.10 to 12.16 and it seems that the column that would normally house the promotional code in the legacy promotion section, is missing.

Was this an intentional change? I've not seen much about it in the release notes.

Thanks,

James

Exclude specific catalog entries from a Promotion

$
0
0

Hello everybody,

A customer I'm working on has for a while asked us to implement a feature where they can create a promotion, select which content they want to be the condition and then select some content that should not be a part of the promotion. I've not really theorized a solution for this, so we've done some workarounds that worked well enough to fulfill the use case they had. However, I want to reach out and see if someone can help me suggest a way of implementing this nicely.

Before anyone asks "Why not just include what should be included in the promotion?", I think I'm safe to say a very common usage of promotions is have one that affects the entire assortment or large portions of it, but that a few products are too "premium" to be affected by a discount.

Way 1: The obvious way

Create a custom promotion processor for the promotion. You can do whatever logic you want from in there, right? Well, this feature should be for all promotions, so that'd mean we'd have to create a custom promotion for every existing built in promotion. A class that inherits the data class for that specific promotion adding the list of exluded content and a processor that overrides the old promotion processor and somewhere injects the logic to exclude the products selected in the list of excluded content. 

So in the end the solution is quite ugly, will have to mean creating tons of code that "already existed" and if Epi releases a new promotion implementation, we will have to manually build that one as well.

Way 2: EntryFilterSettings to our rescue?

The fairly new way of excluding products from promotions, does look very promising, just by looking at the description. However it doesn't fit this use case, as this should be promotion specific. Maybe promotion A should exclude product P1 and promotion B should exclude P2. We can't solve that by the EntryFilterSettings, since that one is used in the promotion engine, removing the items before the engine starts running the specific promotion processors.

So this method is unfortunately a no-go. Even though we do use EntryFilterSettings for a lot of other purposes, such as always excluding gift cards from promotions!

Way 3: Make Epi implement a way!

innocent

In all seriousness I'm looking for a way of implementing this. Am I missing something, am I tunneled visioned and there is an super easy way of achieving this? Currently I'm leaning to implementing it as Way 1, but not super excited about it. 


EPiServer.CMS.UI 11.14.0 Cannot Read Property "ContentData" of Null error

Suspicious cast there is no type in the solution which is inherited from both 'BlockData' and 'IContent'

$
0
0

Hi all,

the code below causes "Suspicious Cast" warning. Nevertheless everything works.

if(contentRepository.TryGet<FormContainerBlock>(copyContentEventArgs.ContentLink, out var formContainerBlock))
{
    var writableFormContainerBlock = formContainerBlock.CreateWritableClone() as IContent;

    ...

    contentRepository.Save(writableFormContainerBlock, SaveAction.Publish);

}

The point is that without "as IContent" part, I could not call "Save" since it's requiring first parameter to be "IContent". And if I put "IContent" in "TryGet<>" instead of "FormContainerBlock", I then can't call "CreateWritableClone()" method.

Invalid cast in Commerce Manager after update from 11.2.5 to 11.8.5

$
0
0

Hi all,

After upgrading from Commerce 11.2.5 to 11.8.5, which should not contain any breaking change, we get the following error in Commerce Manager when trying to create a return. Anyone seen this error? Is this an undocumented breaking change?

[InvalidCastException: Unable to cast object of type 'EPiServer.Commerce.Order.Internal.InMemoryShipment' to type 'Mediachase.Commerce.Orders.Shipment'.]
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetShippingRate(IShipment shipment, ShippingMethodRow row, IMarket market) +282
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.CalculateShippingCost(IShipment shipment, IMarket market, Currency currency) +575
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetDiscountedShippingAmount(IShipment shipment, IMarket market, Currency currency) +388
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency, Func`3 getShippingTotalFunc, Func`3 getDiscountedPriceFunc, Boolean isReturn) +311
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +259
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.GetShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +367
EPiServer.Commerce.Order.Calculator.<>c__DisplayClass7_0.<GetTotalForReturns>b__1(IShipment shipment) +157
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +233
System.Linq.Enumerable.Sum(IEnumerable`1 source) +98
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.GetTotalForReturns(IPurchaseOrder order) +788
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.CalculateReturnTotal(IPurchaseOrder purchaseOrder, IReturnOrderForm currentReturnForm, Boolean isCompletingReturnForm) +338
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.CalculateReturnTotal() +147
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.Page_Load(Object sender, EventArgs e) +1241
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785

Promotions : excluding certain line items from promotions

$
0
0

Hello everybody, 

I have a requirement on a project I'm working on whereby pricing information for products can be pulled in one of two ways:

  1. Via a list price configured in EPi itself
  2. Via a "special" price that is specific to the currently logged in user of the site, the product sku, and the quantity requested aswell. 
    1. So there is a use whereby if a user has an item in their cart, with a quantity of 2, they may see a different unit price if they changed their quantity. 

The special price in this case is one we have to query via an external service, as the combinations of pricing tiers using the above criteria is so large, that this is not something we can manage via EPiServer itself. 

The idea is that as an authenticated user browses the site they always see the cheapest price from one of the above. 

This above scenario works fine, until we try to accomodate the next requirement

"When a special price is used for a particular line item, no promotions can be applied to that line item". 

This is what I'm having issues with - I've tried the following:

  1. Excluding the items from promotions - https://world.episerver.com/documentation/developer-guides/commerce/marketing/exclude-products-from-promotions/
    • I tried to exclude products by testing if a products cheapest price is the "special" price - this worked fine but then i realised that i needed to cater for quantity requested. So this won't work!
  2. Creating a custom promotion
    • The promotion would enable me to apply the "special" pricing as a discount across the line items that qualify for it as a fixed price
    • Line items that qualify for it would have a custom property added to each of them containing the special price for each
    • The problem I had with this is that the evaluate method in the promotion processor only returns one RewardDescription and the fixed price for each line item would be different in my case - so this won't work either. 

Does anyone else have any options for me?

I've gone down a few different avenues as you can see, but I'm still no closer to a solution for this. 

Thanks very much!

Paul 

how the order promotion is applied?

$
0
0

Hi Team,

I have created order promotion(spend 500 get 5% off), item promotion(buy 20 item get 28% off) and both promotions are applied to one order.

case1: order promotion as a high priority.

I got the promotion price using below method 

        private Money GetDiscountedPrice(ILineItem lineItem, Currency currency)
        {
            return lineItem.GetDiscountedPrice(currency);
        }

But line-item promotion price has some variations.

case2: Item promotion as a high priority.

example: The order total value is the same for 2cases but item promotion value unexpected value in case1.

           unitPrice           qty   promotionPrice      OrderDiscount      SubTotal

case1:    $24.14            21       $372.09              $25.35               $346.74

case2:     $24.14            21        $365.00             $18.25              $346.74

my doubts:

Case 2: i am very clear in that. first, 28% applied then 5% applied.

case1: Expected is first 5% applied next 28% applied but I am doubted on the case2 promotion price calculation. Please anyone help me out,

how the promotion is calculated in the case1?

Advance Thanks,

Server rendering HTML with Javascript

$
0
0

It gets more and more popular for every day to render HTML with JavaScript libraries such as Knockout, React, Angular, etc. It's also getting more popular and viable to execute that JavaScript on the server as well as on the client using Node.js, with Microsoft exploring the field on how to integrate it with ASP.NET (https://github.com/aspnet/NodeServices).

Is this something that Episerver is exploring as well? There are great advantages for dynamic and interactive sites to use these frontend tools to keep the code base under control, but there's very little aid from Episerver today with that approach. You basically end up working aganist Episerver, which is very unfortunate.

Possible to hide block header?

$
0
0

When using a block as a property for a page or another block. Is it possible to hide the header so that the block appears like a just a list of properties?

At the moment I have a blocktype called PagePuffBlock. This blocks has a local block of type ListingBlock. The remaning properties of this block are more like additions to the properties in the ListingBlock so when the customer wants to create a block and sees the heading "Listing" they get confused. 

This is the blocktype

    [ContentType(
        DisplayName = "Sidpuff",
        GUID = "136bac1c-ccea-4a89-be1e-ef9ee6ab7160",
        Description = "",
        GroupName = Global.BlockTypeGroupName.Puff)]
    public class PagePuffBlock : BlockData
    {
        [Display(
            Name = "Sida",
            Description = "Sida att hämta data ifrån ifall de andra listegenskaper inte är satta",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual PageReference Page { get; set; }
        [Display(
            Name = "Länk",
            Description = "Länk för besökaren om inte sidans länk är tillräcklig",
            GroupName = SystemTabNames.Content,
            Order = 2)]
        public virtual Url Link { get; set; }
        [Display(
            Name = "Listning",
            Description = "Egenskaper som skriver över det som annars hämtas från egenskapen \"Sida\"",
            GroupName = SystemTabNames.Content,
            Order = 3)]
        public virtual ListingBlock Listing { get; set; }
    }

    

 

Is this something that's possible or am I working in a way I shouldn't be working? If so, please tell me.


Remove Catalog name from product URL

$
0
0

Hi

Really looking for some help on this one. I followed this post and can't seem to get rid of the catalog-name in the product URL. Is there a different way to do this?

Please help!

Regards

Farhad

Add the "Submitted from" value to email sent by Forms?

$
0
0

Hi!

In the Forms data there is a column called "Submitted from". Is it possible the get that value in the email that is sent?
Or how can you otherwise make sure that you know from which page the form was posted?

Thanks!

/Kristoffer

properties

$
0
0

Hi Does anyone have a COMPLETE example of creating a custom property in CMS? Specifically, this samishleather online store I want to create drop down list of options. Thanks

Convert single page PageType to another PageType programically

$
0
0

Hello,

i found the topic https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2018/5/convert-page-type-to-another-page-type-programmatically/ where there is described that we could migrate single page to another pagetype.

My question is --> there is talking about " List<KeyValuePair<int, int>> propertyTypeMap" . How could get this one? I mean it's strange that we are using int instead of string (since i don't know how to get int of my propertyname in my page).
Is there some kind of epi method that i could get Page property int value ??

Custom file drag and drop property with uploading progress bar in editor page.

$
0
0

Hi developers,

I am a beginner here. I am trying to create a page with custom property where it wants to allows the editor to drag and drop a file. While uploading I need to show the progress bar of uploading status. Help me to do this, any examples please.

Viewing all 6894 articles
Browse latest View live