IsModified is set for catalog content right after calling CreateWritableClone

Fixed in

EPiServer.Commerce 13.30.0


Jan 22, 2021


Mar 22, 2021


Closed, Fixed and tested


Environment Information

VM n/a
DB n/a
Zendesk 601281

Customer Impact Statement

Fundation bug.
It’s latest Foundation.

<package id="EPiServer.CMS" version="11.20.2" targetFramework="net472" />
<package id="EPiServer.Commerce.Core" version="13.26.0" targetFramework="net472" />

Issue Description

I took the latest Foundation code. Check out the following code sample:

public class HomeController : PageController<HomePage>
    private readonly IContentRepository _contentRepository;
    private readonly ReferenceConverter _referenceConverter;

    public HomeController(IContentRepository contentRepository, ReferenceConverter referenceConverter)
        _contentRepository = contentRepository;
        _referenceConverter = referenceConverter;

    public ActionResult Index(HomePage currentContent)
        var someVariant = _contentRepository.Get<GenericVariant>(_referenceConverter.GetContentLink("SKU-39813617"));
        // someVariant.IsReadOnly = true, someVariant.IsModified = false
        var writable = someVariant.CreateWritableClone<GenericVariant>();
        // writable.IsReadOnly = false, someVariant.IsModified = true

        var readonlyHome = currentContent;
        // readonlyHome.IsReadOnly = true, readonlyHome.IsModified = false
        var writableHome = (HomePage)currentContent.CreateWritableClone();
        // writableHome.IsReadOnly = false, writableHome.IsModified = false

        return View(ContentViewModel.Create<HomePage>(currentContent));

Note that when working with CMS content writable clone IsModified state is False right after creation which is correct, however for catalog content writable clone has IsModified set to True right after creation.
This looks like a bug in CreateWritableClone implementation in CatalogContentBase.

Attachment List