Using IProductService on MessageTokenProvider Nop 2.30

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi,
I need to extract some product variant information in MessageTokenProvider, but if I add the IProductService interface to constructor, I receive the error:
No parameterless constructor defined for this object.
If I add other interfaces all works fine.
Can someone help me ?

Thanks, Ivano

This is the constructor:

private readonly ILanguageService _languageService;
        private readonly ILocalizationService _localizationService;
        private readonly IDateTimeHelper _dateTimeHelper;
        private readonly IEmailAccountService _emailAccountService;
        private readonly IPriceFormatter _priceFormatter;
        private readonly ICurrencyService _currencyService;
        private readonly IWebHelper _webHelper;
        private readonly IProductService _productService;

        private readonly StoreInformationSettings _storeSettings;
        private readonly MessageTemplatesSettings _templatesSettings;
        private readonly EmailAccountSettings _emailAccountSettings;
        private readonly CatalogSettings _catalogSettings;
        private readonly TaxSettings _taxSettings;

        #endregion

        #region Ctor

        public MessageTokenProvider(ILanguageService languageService,
            ILocalizationService localizationService, IDateTimeHelper dateTimeHelper,
            IEmailAccountService emailAccountService,
            IPriceFormatter priceFormatter, ICurrencyService currencyService,IWebHelper webHelper,
            IProductService productService,  
            StoreInformationSettings storeSettings, MessageTemplatesSettings templatesSettings,
            EmailAccountSettings emailAccountSettings, CatalogSettings catalogSettings,
            TaxSettings taxSettings)
        {
            this._languageService = languageService;
            this._localizationService = localizationService;
            this._dateTimeHelper = dateTimeHelper;
            this._emailAccountService = emailAccountService;
            this._priceFormatter = priceFormatter;
            this._currencyService = currencyService;
            this._webHelper = webHelper;
            this._productService = productService;
            this._storeSettings = storeSettings;
            this._templatesSettings = templatesSettings;
            this._emailAccountSettings = emailAccountSettings;
            this._catalogSettings = catalogSettings;
            this._taxSettings = taxSettings;
        }
11 years ago
Right. It causes circular reference. Do not inject IProductService. Resolve it right in a method:
var productService = EngineContext.Current.Resolve<IProductService>();
11 years ago
a.m. wrote:
Right. It causes circular reference. Do not inject IProductService. Resolve it right in a method:
var productService = EngineContext.Current.Resolve<IProductService>();


Thank You a lot Andrei, exactly what I was looking for.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.