Try our conversational search powered by Generative AI!

Any way to hide Suggested Discount Types section?

Vote:
 

When I'm adding a new Discount to a Campaign in the new promotions UI.. is there any way to hide the "Suggested Types" section on that screen?

Thanks,

 - Ken

#174265
Jan 23, 2017 17:37
Vote:
 

Hi

Here is a good blog on how you can modify the "Suggest Types" section, including hiding it completely.

https://talk.alfnilsson.se/2016/04/17/customize-suggested-pageblock-types-when-creating-content/

Regards

Per Gunsarfs

#174309
Jan 24, 2017 11:01
Vote:
 

This would remove the "Suggested Types" section for all types of content, though. That might be a plus on the side - but it is worth to mention.

I guess you can maybe configure your own ContentTypeAdvisor and do some logic there to not show suggestions if the content is children of the campaign root or something?

Regards,
Joel Yourstone

#174326
Jan 24, 2017 15:08
Vote:
 

That's a good point Joel, such modifications will affect the "Suggested Types" for all content types. To only remove it for some types you would as you say have to implement your own IContentTypeAdvisor, and vary the logic depending on the type of the parent IContent that is supplied to the GetSuggestions method.

Regards

Per Gunsarfs

#174332
Jan 24, 2017 15:38
Vote:
 

Good advice, thank you both!

#174348
Jan 24, 2017 21:26
Vote:
 

I've implemented a custom IContentTypeAdvisor that does what I need.

To configure my site to use it:

...

container.EjectAllInstancesOf<IContentTypeAdvisor>();
container.Configure(x => x.For<IContentTypeAdvisor>().Use<CustomContentTypeAdvisor>());

...

But, is there a way to replace only the DefaultContentTypeAdvisor?  I don't want to eject all of them - I only want to replace the default with my custom implementation.  Can it be done?

#174607
Jan 31, 2017 15:45
Vote:
 

Bump.. any ideas?

#174921
Feb 07, 2017 21:50
Vote:
 

Hi

I'm not sure exactly how to do that, I've never had the need to do it. I would suggest looking into StructureMap for more information about how to do more explcit configuration, as we just use that to handle dependency injection (the container object is a type from StructureMap).

However, I'm curious, why do you just want to remove a specific one? Because ejecting all and then adding yours will remove the default one from the system and yours will be used instead. I doubt we even support calling multiple IContentTypeAdvisors, I suspect only the one that is the registered as default in the container will be called.

If you want to replace an existing service, but still have access to an instance of the replaced one, I would suggest using the Intercept pattern. You can read about it here, http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Initialization/dependency-injection/.

Regards

Per Gunsarfs

#174931
Feb 08, 2017 10:48
Vote:
 

Ah, thanks.  To clear things up:

- I had believed that Epi was using two implementations of IContentTypeAdvisor, because I noticed there are 2 built-in types (CatalogContentTypeAdvisor + DefaultContentTypeAdvisor).

- I was concerned about replacing both of those with one custom implementation...

- But I dug into the source code --- and I found that CatalogContentTypeAdvisor uses an instance of DefaultContentTypeAdvisor internally.

- So I decided to follow a similar pattern: my custom implementation will use CatalogContentTypeAdvisor internally:

using System.Collections.Generic;
using EPiServer.Cms.Shell.UI.Rest;
using EPiServer.Commerce.Marketing;
using EPiServer.Commerce.Shell.Rest;
using EPiServer.Core;
using EPiServer.ServiceLocation;

namespace Turn5.Web.CustomEpiTypes
{
    [ServiceConfiguration(typeof(IContentTypeAdvisor))]
    public class CustomContentTypeAdvisor : IContentTypeAdvisor
    {
        private readonly CatalogContentTypeAdvisor _catalogContentTypeAdvisor;

        public CustomContentTypeAdvisor(CatalogContentTypeAdvisor catalogContentTypeAdvisor)
        {
            _catalogContentTypeAdvisor = catalogContentTypeAdvisor;
        }

        public IEnumerable<int> GetSuggestions(IContent parent, bool contentFolder, IEnumerable<string> requestedTypes)
        {
            // To disable the "Suggested Content Types" functionality for Promotions in Episerver:
            if (parent is SalesCampaign)
            {
                return new List<int>();
            }

            // For other content, use Epi's implementation:
            return _catalogContentTypeAdvisor.GetSuggestions(parent, contentFolder, requestedTypes);
        }
    }
}



#174966
Feb 08, 2017 17:47
Vote:
 

Ah, right gotcha.

Glad that you got it working.

/Per

#174989
Feb 09, 2017 9:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.