Try our conversational search powered by Generative AI!

Campaign with multiple target markets

Vote:
 

Our customer wants to be able to target multiple markets with one campaign - and not all markets.

I have been working on a solution by making a custom campaign like this:

public class CustomCampaign : SalesCampaign
{
    [ScaffoldColumn(false)]
    public override string TargetMarket { get; set; }

    [Required]
    [SelectMany(SelectionFactoryType = typeof(MarketSelectionFactory))]
    [Display(GroupName = "MarketAndRevenue", Order = 60, Name = "Target markets")]
    public virtual string TargetMarkets { get; set; }
}

public class MarketSelectionFactory : ISelectionFactory
{
    public IEnumerable GetSelections(ExtendedMetadata metadata)
    {
        var markets = ServiceLocator.Current.GetInstance().GetAllMarkets();
        return markets.Where(x => x.IsEnabled).Select(x => new SelectItem { Text = x.MarketName, Value = x.MarketId });
    }
}

Then to get it working I need to override som login in: ShippingMethodSelectionFactory, PromotionDataModelTransform, PromotionEngineContentLoader and GetCampaignsByMarket

I have made a custom version for each but now I get problem registering thier custom version to replace thier existing episerver version. 

I have this in my container configuration:

cfg.For().Singleton().Use();//Does not work - and I can't find what I need to overload to make it work.
cfg.For().Singleton().Use(); //Does not work - it makes sense - it seems like I have to override FacetStore to make it work?
cfg.For().Singleton().Use(); //Works
cfg.For().Transient().Use(); //Does mabye work (not testede directly jet)


Do you have any suggestions to how I will get the last custom verisons applied correctly?

I have one alternativ way to solve it, by making a custom version of all discounts and have them in a Campaign that is for all markets. Then in the custom discounts make the target market filtering. But that is not a prefered solution.

I is actually simple code to change the target market to handle multiple targets, but it is very hard for me to inject - any one knows if Episerver is considering the improvement them self?

#183024
Edited, Oct 03, 2017 13:46
* 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.