1

We are in the process of converting Sitecore 9.0.2 MVC project to Sitecore 10.0.3. The following code was used to convert the shorthand like site:$datafolder/Home/Banne to the absolute path in the context of the current location. This way we were able to copy and paste the renderings without making changes in the datasource path.

After moving this code to Sitecore 10.0.3 we are not able to find the following namespace in the Sitecore.Mvc.Analytics.dll version 10.0.3 Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering

<mvc.customizeRendering>
    <processor type="Common.Pipelines.mvc.customizeRendering.DatasourceResolver, Common" patch:after="*"/>
</mvc.customizeRendering>
using Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering;
using Sitecore.Pipelines;
using Sitecore.Pipelines.ResolveRenderingDatasource;

namespace Common.Pipelines.mvc.customizeRendering
{
    public class DatasourceResolver : CustomizeRenderingProcessor
    {
        public override void Process(CustomizeRenderingArgs args)
        {
            var _rootPath = Sitecore.Context.Site.SiteInfo.RootPath.ToString();
            if (!string.IsNullOrEmpty(_rootPath) && _rootPath.StartsWith("/sitecore/content/SiteFolder/SiteCollections"))
            {
                var rendering = args.Rendering;
                var renderingDatasourceArgs = new ResolveRenderingDatasourceArgs(rendering.DataSource);
                CorePipeline.Run("resolveRenderingDatasource", renderingDatasourceArgs);
                rendering.DataSource = renderingDatasourceArgs.Datasource;
            }
        }
    }
}

2 Answers 2

0

You inherit from CustomizeRenderingProcessor but you never call any base method. It means you don't need this inheritance.

Instead, inherit from Sitecore.Mvc.Pipelines.MvcPipelineProcessor<Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.CustomizeRenderingArgs> like:

public class DatasourceResolver : MvcPipelineProcessor<Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.CustomizeRenderingArgs>
{
    public override void Process(CustomizeRenderingArgs args)
    {
        var _rootPath = Sitecore.Context.Site.SiteInfo.RootPath.ToString();
        if (!string.IsNullOrEmpty(_rootPath) && _rootPath.StartsWith("/sitecore/content/SiteFolder/SiteCollections"))
        {
            var rendering = args.Rendering;
            var renderingDatasourceArgs = new ResolveRenderingDatasourceArgs(rendering.DataSource);
            CorePipeline.Run("resolveRenderingDatasource", renderingDatasourceArgs);
            rendering.DataSource = renderingDatasourceArgs.Datasource;
        }
    }
}
3
  • Hi Marek, "CustomizeRenderingArgs" is not available in the "Sitecore.Mvc.Analytics" version 10.0.3. Please know that the code provided in my question working fine in sitecore 9.0.2.
    – Eshu Kumar
    Aug 10, 2023 at 12:27
  • CustomizeRenderingArgs is in namespace Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering in Sitecore.Personalization.Mvc. Answer updated
    – Marek Musielak
    Aug 10, 2023 at 13:00
  • 1
    Hi Marek, thanks
    – Eshu Kumar
    Aug 17, 2023 at 7:47
0

I just quickly decompile 10.3 dlls and it confirms.

enter image description here

Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering Deprecated in Sitecore 10.0. Please use Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.CustomizeRenderingProcessor and it is part of Sitecore.Personalization.Mvc instead.

Hope it helps!

1
  • 1
    Hi Sumit, Thanks
    – Eshu Kumar
    Aug 17, 2023 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.