0

I am looking for Item Collection Or Class Or Method which can provide all details of specific promotion such as Qualifications, Benefits, Private Coupon etc..

enter image description here

I have tried following syntax but returning null to me

var promotionModel = (commerceContext.Objects.OfType<Promotion>()).FirstOrDefault();

Thanks,

1 Answer 1

1

You can get this by using the IFindEntityPipeline, you can see a dummy implementation on how to achieve that here:

public class Foo
{
    private readonly IFindEntityPipeline _findEntityPipeline;

    public Foo(IFindEntityPipeline findEntityPipeline)
    {
        _findEntityPipeline = findEntityPipeline;
    }

    public async Task<Promotion> GetPromotionById(string id, CommercePipelineExecutionContext context)
    {
        var promotion = await _findEntityPipeline.Run(new FindEntityArgument(typeof(Promotion), id, 1), context))
        return promotion as Promotion;
    }
}

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.