Tuan Truong
Feb 17, 2014
  3281
(2 votes)

Upgrade to EPiServer Commerce 7.5 : Part 1– Allow users to drag and drop catalog node and catalog variant on to content areas.

In our company, we are always given the chances to work with latest and up to date technologies, and EPiServer 7.5 Commerce was one of the cool stuff that my team had the opportunity to explore so far. Kudos to EPiServer team to help me create this blog, on this space.  I will try to share all our experiences on upgrading one of our client EPiServer Commerce site from EPiServer 6 R2 on to EPiServer 7.5 , getting used of latest technology on EPiServer 7.5, Asp.net MVC4, html5/css3 .

Would love to hear any feedback and comments that you guys may have, all for the better community and better product for us all Smile.

On this first blog post, I will describe how we managed to allow user to drag and drop any catalog node and catalog content on to the content areas of the page from the catalog manager component. This is just like how you can drop pages on to different content areas. 
Firstly, we will need a base controller for all our partial content :


namespace Niteco.Web.Cms.Controllers 
{ 
    [TemplateDescriptor(TemplateTypeCategory = TemplateTypeCategories.MvcPartialController, Inherited = true,AvailableWithoutTag = false)] 
    public class BasePartialContentController<T> : PartialContentController<T> where T : IContentData 
    { 
    } 
}

In EPiServer 7.5, there is a base partial content controller to help deliver all partial contents to the pages.
Then for each catalog node content that you want to allow to be dropped on to content area, just need to have it inherit from above base controller:

 public class WineCatalogPartialController : BasePartialContentController<WineCatalogNodeContent>
    {
        public override ActionResult Index(WineCatalogNodeContent currentContent)
        {
            var model =  CatalogNodeViewModelHelpers.BuidWineItemListingModel(currentContent);
            return PartialView("WineItemListingView", model);
        }
    }
 

In our model builder function, we basically get all the catalog entries within this catalog node, .i.e:

var entries = wineItemSearchHelper.SearchEntries(catNodeContent.Code, 0, Int32.MaxValue,out totalCount);

The same apply for product variant content when you want to drag drop it to the content area of the page, you will need to inherit from the base partial content controller:


public class WineItemPartialController : BasePartialContentController<WineItemContent>
    {
        public override ActionResult Index(WineItemContent currentContent)
        {
            var model = new WineItemPartialViewModel(currentContent)
            {
                WineItemDetails = WineItemViewModelHelpers.CreateWineItemContentViewModel(currentContent)
            };
            return PartialView("VariantPartials/WineItemFullPartialView", model);
        }

There was one big issue when we were implementing this was that it causing the site to “stack overflow”, and after many hours of digging, we have found the cause. It was because of the following bit of code in our partial view:

<div class="product_selling_info">
    @Html.Action("Index", "AddToCart", new { reference = Model.CatalogContent.ContentLink})
</div>

Somehow, it is causing the page to keep recall the action within the page, we had to change the page to the following , :

<div class="product_selling_info">
     @Html.Action("Index", "AddToCart", new { reference = Model.CatalogContent.ContentLink, controllerType = typeof(AddToCartController).AssemblyQualifiedName })
</div>

This is for the page to understand that the action is belong to another controller, not the current page controller.

That is all. Hopefully this will help you guys in implementing the drag drop catalog contents on the the content area. In the next coming posts, I will continue to provide more knowledge sharing our process to upgrade an ecommerce site to EPiServer 7.5. If you need the detailed source code or any help, please leave a comment below.

Thanks.

Feb 17, 2014

Comments

Ha Nguyen
Ha Nguyen Feb 17, 2014 11:20 AM

Cool!!!!

Tiến Bùi
Tiến Bùi Feb 17, 2014 11:21 AM

Excellent! Will definitely try it out.

Please login to comment.
Latest blogs
Copy Optimizely SaaS CMS Settings to ENV Format Via Bookmarklet

Do you work with multiple Optimizely SaaS CMS instances? Use a bookmarklet to automatically copy them to your clipboard, ready to paste into your e...

Daniel Isaacs | Dec 22, 2024 | Syndicated blog

Increase timeout for long running SQL queries using SQL addon

Learn how to increase the timeout for long running SQL queries using the SQL addon.

Tomas Hensrud Gulla | Dec 20, 2024 | Syndicated blog

Overriding the help text for the Name property in Optimizely CMS

I recently received a question about how to override the Help text for the built-in Name property in Optimizely CMS, so I decided to document my...

Tomas Hensrud Gulla | Dec 20, 2024 | Syndicated blog

Resize Images on the Fly with Optimizely DXP's New CDN Feature

With the latest release, you can now resize images on demand using the Content Delivery Network (CDN). This means no more storing multiple versions...

Satata Satez | Dec 19, 2024

Simplify Optimizely CMS Configuration with JSON Schema

Optimizely CMS is a powerful and versatile platform for content management, offering extensive configuration options that allow developers to...

Hieu Nguyen | Dec 19, 2024

Useful Optimizely CMS Web Components

A list of useful Optimizely CMS components that can be used in add-ons.

Bartosz Sekula | Dec 18, 2024 | Syndicated blog