Beispiel #1
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="sciRepository">Shopping cart repository</param>
 /// <param name="workContext">Work context</param>
 /// <param name="currencyService">Currency service</param>
 /// <param name="productService">Product settings</param>
 /// <param name="localizationService">Localization service</param>
 /// <param name="productAttributeParser">Product attribute parser</param>
 /// <param name="checkoutAttributeService">Checkout attribute service</param>
 /// <param name="checkoutAttributeParser">Checkout attribute parser</param>
 /// <param name="priceFormatter">Price formatter</param>
 /// <param name="customerService">Customer service</param>
 /// <param name="shoppingCartSettings">Shopping cart settings</param>
 /// <param name="eventPublisher">Event publisher</param>
 /// <param name="permissionService">Permission service</param>
 /// <param name="aclService">ACL service</param>
 public ShoppingCartService(IRepository<ShoppingCartItem> sciRepository,
     IWorkContext workContext, ICurrencyService currencyService,
     IProductService productService, ILocalizationService localizationService,
     IProductAttributeParser productAttributeParser,
     ICheckoutAttributeService checkoutAttributeService,
     ICheckoutAttributeParser checkoutAttributeParser,
     IPriceFormatter priceFormatter,
     ICustomerService customerService,
     ShoppingCartSettings shoppingCartSettings,
     IEventPublisher eventPublisher,
     IPermissionService permissionService, 
     IAclService aclService)
 {
     this._sciRepository = sciRepository;
     this._workContext = workContext;
     this._currencyService = currencyService;
     this._productService = productService;
     this._localizationService = localizationService;
     this._productAttributeParser = productAttributeParser;
     this._checkoutAttributeService = checkoutAttributeService;
     this._checkoutAttributeParser = checkoutAttributeParser;
     this._priceFormatter = priceFormatter;
     this._customerService = customerService;
     this._shoppingCartSettings = shoppingCartSettings;
     this._eventPublisher = eventPublisher;
     this._permissionService = permissionService;
     this._aclService = aclService;
 }
        public new void SetUp()
        {
			_store = new Store() { Id = 1 };
			_storeContext = MockRepository.GenerateMock<IStoreContext>();
			_storeContext.Expect(x => x.CurrentStore).Return(_store);

            _discountService = MockRepository.GenerateMock<IDiscountService>();

            _categoryService = MockRepository.GenerateMock<ICategoryService>();

            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
			_productService = MockRepository.GenerateMock<IProductService>();
			_productAttributeService = MockRepository.GenerateMock<IProductAttributeService>();

			_downloadService = MockRepository.GenerateMock<IDownloadService>();
			_commonServices = MockRepository.GenerateMock<ICommonServices>();
			_commonServices.Expect(x => x.StoreContext).Return(_storeContext);
			_httpRequestBase = MockRepository.GenerateMock<HttpRequestBase>();
			_taxService = MockRepository.GenerateMock<ITaxService>();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings = new CatalogSettings();

			_priceCalcService = new PriceCalculationService(_discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings,
				_productAttributeService, _downloadService, _commonServices, _httpRequestBase, _taxService);
        }
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="shippingMethodRepository">Shipping method repository</param>
 /// <param name="deliveryDateRepository">Delivery date repository</param>
 /// <param name="warehouseRepository">Warehouse repository</param>
 /// <param name="logger">Logger</param>
 /// <param name="productService">Product service</param>
 /// <param name="productAttributeParser">Product attribute parser</param>
 /// <param name="checkoutAttributeParser">Checkout attribute parser</param>
 /// <param name="genericAttributeService">Generic attribute service</param>
 /// <param name="localizationService">Localization service</param>
 /// <param name="addressService">Address service</param>
 /// <param name="shippingSettings">Shipping settings</param>
 /// <param name="pluginFinder">Plugin finder</param>
 /// <param name="eventPublisher">Event published</param>
 /// <param name="shoppingCartSettings">Shopping cart settings</param>
 /// <param name="cacheManager">Cache manager</param>
 public ShippingService(IRepository<ShippingMethod> shippingMethodRepository,
     IRepository<DeliveryDate> deliveryDateRepository,
     IRepository<Warehouse> warehouseRepository,
     ILogger logger,
     IProductService productService,
     IProductAttributeParser productAttributeParser,
     ICheckoutAttributeParser checkoutAttributeParser,
     IGenericAttributeService genericAttributeService,
     ILocalizationService localizationService,
     IAddressService addressService,
     ShippingSettings shippingSettings,
     IPluginFinder pluginFinder,
     IEventPublisher eventPublisher,
     ShoppingCartSettings shoppingCartSettings,
     ICacheManager cacheManager)
 {
     this._shippingMethodRepository = shippingMethodRepository;
     this._deliveryDateRepository = deliveryDateRepository;
     this._warehouseRepository = warehouseRepository;
     this._logger = logger;
     this._productService = productService;
     this._productAttributeParser = productAttributeParser;
     this._checkoutAttributeParser = checkoutAttributeParser;
     this._genericAttributeService = genericAttributeService;
     this._localizationService = localizationService;
     this._addressService = addressService;
     this._shippingSettings = shippingSettings;
     this._pluginFinder = pluginFinder;
     this._eventPublisher = eventPublisher;
     this._shoppingCartSettings = shoppingCartSettings;
     this._cacheManager = cacheManager;
 }
 public PriceCalculationService(IWorkContext workContext,
         IStoreContext storeContext,
         IDiscountService discountService,
         ICategoryService categoryService,
         IProductAttributeParser productAttributeParser,
         IProductService productService,
         ICacheManager cacheManager,
         ShoppingCartSettings shoppingCartSettings,
         CatalogSettings catalogSettings,
         IPriceForSizeService priceForSizeService)
   : base(
   workContext,
   storeContext,
   discountService,
   categoryService,
   productAttributeParser,
   productService,
   cacheManager,
   shoppingCartSettings,
   catalogSettings
   )
 {
   _productAttributeParser = productAttributeParser;
   _productService = productService;
   _priceForSizeService = priceForSizeService;
 }
        public OrderController(IOrderService orderService, 
            IShipmentService shipmentService, IWorkContext workContext,
            ICurrencyService currencyService, IPriceFormatter priceFormatter,
            IOrderProcessingService orderProcessingService, IDateTimeHelper dateTimeHelper,
            IPaymentService paymentService, ILocalizationService localizationService,
            IPdfService pdfService, IShippingService shippingService,
            ICountryService countryService, IProductAttributeParser productAttributeParser,
            IWebHelper webHelper,
            CatalogSettings catalogSettings, OrderSettings orderSettings,
            TaxSettings taxSettings, PdfSettings pdfSettings,
            ShippingSettings shippingSettings, AddressSettings addressSettings)
        {
            this._orderService = orderService;
            this._shipmentService = shipmentService;
            this._workContext = workContext;
            this._currencyService = currencyService;
            this._priceFormatter = priceFormatter;
            this._orderProcessingService = orderProcessingService;
            this._dateTimeHelper = dateTimeHelper;
            this._paymentService = paymentService;
            this._localizationService = localizationService;
            this._pdfService = pdfService;
            this._shippingService = shippingService;
            this._countryService = countryService;
            this._productAttributeParser = productAttributeParser;
            this._webHelper = webHelper;

            this._catalogSettings = catalogSettings;
            this._orderSettings = orderSettings;
            this._taxSettings = taxSettings;
            this._pdfSettings = pdfSettings;
            this._shippingSettings = shippingSettings;
            this._addressSettings = addressSettings;
        }
        public MessageTokenProvider(ILanguageService languageService,
            ILocalizationService localizationService, IDateTimeHelper dateTimeHelper,
            IEmailAccountService emailAccountService,
            IPriceFormatter priceFormatter, ICurrencyService currencyService,IWebHelper webHelper,
            IWorkContext workContext, IDownloadService downloadService,
            IOrderService orderService, IPaymentService paymentService,
            IProductAttributeParser productAttributeParser,
            StoreInformationSettings storeSettings, MessageTemplatesSettings templatesSettings,
            EmailAccountSettings emailAccountSettings, CatalogSettings catalogSettings,
            TaxSettings taxSettings, IEventPublisher eventPublisher)
        {
            this._languageService = languageService;
            this._localizationService = localizationService;
            this._dateTimeHelper = dateTimeHelper;
            this._emailAccountService = emailAccountService;
            this._priceFormatter = priceFormatter;
            this._currencyService = currencyService;
            this._webHelper = webHelper;
            this._workContext = workContext;
            this._downloadService = downloadService;
            this._orderService = orderService;
            this._paymentService = paymentService;
            this._productAttributeParser = productAttributeParser;

            this._storeSettings = storeSettings;
            this._templatesSettings = templatesSettings;
            this._emailAccountSettings = emailAccountSettings;
            this._catalogSettings = catalogSettings;
            this._taxSettings = taxSettings;
            this._eventPublisher = eventPublisher;
        }
 public MobSocialMessageService(IMessageTemplateService messageTemplateService,
                                    IStoreService storeService, IMessageTokenProvider messageTokenProvider,
                                    ILanguageService languageService,
                                    IStoreContext storeContext,
                                    IEventPublisher eventPublisher,
                                    ITokenizer tokenizer, IQueuedEmailService queuedEmailService,
                                    IEmailAccountService emailAccountService,
                                    EmailAccountSettings emailAccountSettings,
                                    ILocalizationService localizationService,
                                    MessageTemplatesSettings messageTemplateSettings,
                                    CatalogSettings catalogSettings,
                                    IProductAttributeParser productAttributeParser, IWorkContext workContext)
 {
     _messageTemplateService = messageTemplateService;
     _storeService = storeService;
     _messageTokenProvider = messageTokenProvider;
     _languageService = languageService;
     _storeContext = storeContext;
     _eventPublisher = eventPublisher;
     _tokenizer = tokenizer;
     _queuedEmailService = queuedEmailService;
     _emailAccountService = emailAccountService;
     _emailAccountSettings = emailAccountSettings;
     _localizationService = localizationService;
     _messageTemplateSettings = messageTemplateSettings;
     _catalogSettings = catalogSettings;
     _productAttributeParser = productAttributeParser;
     _workContext = workContext;
 }
 public CopyProductService(IProductService productService,
     IProductAttributeService productAttributeService,
     ILanguageService languageService,
     ILocalizedEntityService localizedEntityService, 
     IPictureService pictureService,
     ICategoryService categoryService, 
     IManufacturerService manufacturerService,
     ISpecificationAttributeService specificationAttributeService,
     IDownloadService downloadService,
     IProductAttributeParser productAttributeParser,
     IUrlRecordService urlRecordService, 
     IStoreMappingService storeMappingService)
 {
     this._productService = productService;
     this._productAttributeService = productAttributeService;
     this._languageService = languageService;
     this._localizedEntityService = localizedEntityService;
     this._pictureService = pictureService;
     this._categoryService = categoryService;
     this._manufacturerService = manufacturerService;
     this._specificationAttributeService = specificationAttributeService;
     this._downloadService = downloadService;
     this._productAttributeParser = productAttributeParser;
     this._urlRecordService = urlRecordService;
     this._storeMappingService = storeMappingService;
 }
        //private readonly IStoreContext _storeContext;
        //private readonly IDiscountService _discountService;
        //private readonly ICategoryService _categoryService;
        //private readonly IProductAttributeParser _productAttributeParser;
        //private readonly IProductService _productService;
        //private readonly ICacheManager _cacheManager;
        //private readonly ShoppingCartSettings _shoppingCartSettings;
        //private readonly CatalogSettings _catalogSettings;

        #endregion

        #region constructor

        public PromosPriceCalculationService(
            IPromoUtilities promoUtilities,
            IWorkContext workContext,
            IStoreContext storeContext,
            IDiscountService discountService,
            ICategoryService categoryService,
            IManufacturerService manufacturerService,
            IProductAttributeParser productAttributeParser,
            IProductService productService,
            ICacheManager cacheManager,
            ShoppingCartSettings shoppingCartSettings,
            CatalogSettings catalogSettings,
            PromoSettings promoSettings,
            ICurrencyService currencyService,
            IPriceCalculationService priceCalculationService,
            ILocalizationService localizationService,
            ILogger logger)
            : base (workContext, storeContext, discountService,
                    categoryService, manufacturerService, productAttributeParser,
                    productService, cacheManager, shoppingCartSettings,
                    catalogSettings)
        {
            this._promoUtilities = promoUtilities;
            this._promoSettings = promoSettings;
            this._workContext = workContext;
            this._currencyService = currencyService;
            this._priceCalculationService = priceCalculationService;
            this._localizationService = localizationService;
            this._logger = logger;
        }
        public ReturnRequestController(
			IOrderService orderService,
			IWorkContext workContext, IStoreContext storeContext,
            ICurrencyService currencyService, IPriceFormatter priceFormatter,
            IOrderProcessingService orderProcessingService,
            ILocalizationService localizationService,
            ICustomerService customerService,
            IWorkflowMessageService workflowMessageService,
			IProductAttributeParser productAttributeParser,
            LocalizationSettings localizationSettings,
            OrderSettings orderSettings)
        {
            this._orderService = orderService;
            this._workContext = workContext;
            this._storeContext = storeContext;
            this._currencyService = currencyService;
            this._priceFormatter = priceFormatter;
            this._orderProcessingService = orderProcessingService;
            this._localizationService = localizationService;
            this._customerService = customerService;
            this._workflowMessageService = workflowMessageService;
            this._productAttributeParser = productAttributeParser;

            this._localizationSettings = localizationSettings;
            this._orderSettings = orderSettings;
        }
Beispiel #11
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="shippingMethodRepository">Shipping method repository</param>
        /// <param name="logger">Logger</param>
        /// <param name="productAttributeParser">Product attribute parser</param>
        /// <param name="productService">Product service</param>
        /// <param name="checkoutAttributeParser">Checkout attribute parser</param>
        /// <param name="genericAttributeService">Generic attribute service</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="shippingSettings">Shipping settings</param>
        /// <param name="pluginFinder">Plugin finder</param>
        /// <param name="eventPublisher">Event published</param>
        /// <param name="shoppingCartSettings">Shopping cart settings</param>
        /// <param name="settingService">Setting service</param>
        public ShippingService(ICacheManager cacheManager, 
            IRepository<ShippingMethod> shippingMethodRepository,
            ILogger logger,
            IProductAttributeParser productAttributeParser,
			IProductService productService,
            ICheckoutAttributeParser checkoutAttributeParser,
			IGenericAttributeService genericAttributeService,
            ILocalizationService localizationService,
            ShippingSettings shippingSettings,
            IPluginFinder pluginFinder,
            IEventPublisher eventPublisher,
            ShoppingCartSettings shoppingCartSettings,
			ISettingService settingService,
			IProviderManager providerManager)
        {
            this._cacheManager = cacheManager;
            this._shippingMethodRepository = shippingMethodRepository;
            this._logger = logger;
            this._productAttributeParser = productAttributeParser;
            this._productService = productService;
            this._checkoutAttributeParser = checkoutAttributeParser;
            this._genericAttributeService = genericAttributeService;
            this._localizationService = localizationService;
            this._shippingSettings = shippingSettings;
            this._pluginFinder = pluginFinder;
            this._eventPublisher = eventPublisher;
            this._shoppingCartSettings = shoppingCartSettings;
            this._settingService = settingService;
            this._providerManager = providerManager;
        }
        public PriceCalculationService(
            IDiscountService discountService,
			ICategoryService categoryService,
            IProductAttributeParser productAttributeParser,
			IProductService productService,
			ShoppingCartSettings shoppingCartSettings, 
            CatalogSettings catalogSettings,
			IProductAttributeService productAttributeService,
			IDownloadService downloadService,
			ICommonServices services,
			HttpRequestBase httpRequestBase,
			ITaxService taxService)
        {
            this._discountService = discountService;
            this._categoryService = categoryService;
            this._productAttributeParser = productAttributeParser;
            this._productService = productService;
            this._shoppingCartSettings = shoppingCartSettings;
            this._catalogSettings = catalogSettings;
            this._productAttributeService = productAttributeService;
            this._downloadService = downloadService;
            this._services = services;
            this._httpRequestBase = httpRequestBase;
            this._taxService = taxService;
        }
        public new void SetUp()
        {
            _workContext = null;

            _store = new Store() { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _discountService = MockRepository.GenerateMock<IDiscountService>();
            _categoryService = MockRepository.GenerateMock<ICategoryService>();
            _productService = MockRepository.GenerateMock<IProductService>();


            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings = new CatalogSettings();

            _cacheManager = new NopNullCache();

            _priceCalcService = new PriceCalculationService(_workContext,
                _storeContext, 
                _discountService,
                _categoryService,
                _productAttributeParser,
                _productService,
                _cacheManager,
                _shoppingCartSettings, 
                _catalogSettings);
        }
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="workContext">Work context</param>
        /// <param name="storeContext">Store context</param>
        /// <param name="priceCalculationService">Price calculation service</param>
        /// <param name="taxService">Tax service</param>
        /// <param name="shippingService">Shipping service</param>
        /// <param name="paymentService">Payment service</param>
        /// <param name="checkoutAttributeParser">Checkout attribute parser</param>
        /// <param name="discountService">Discount service</param>
        /// <param name="giftCardService">Gift card service</param>
        /// <param name="genericAttributeService">Generic attribute service</param>
        /// <param name="taxSettings">Tax settings</param>
        /// <param name="rewardPointsSettings">Reward points settings</param>
        /// <param name="shippingSettings">Shipping settings</param>
        /// <param name="shoppingCartSettings">Shopping cart settings</param>
        /// <param name="catalogSettings">Catalog settings</param>
        public OrderTotalCalculationService(IWorkContext workContext,
			IStoreContext storeContext,
            IPriceCalculationService priceCalculationService,
            ITaxService taxService,
            IShippingService shippingService,
			IProviderManager providerManager,
            ICheckoutAttributeParser checkoutAttributeParser,
            IDiscountService discountService,
            IGiftCardService giftCardService,
            IGenericAttributeService genericAttributeService,
			IProductAttributeParser productAttributeParser,
            TaxSettings taxSettings,
            RewardPointsSettings rewardPointsSettings,
            ShippingSettings shippingSettings,
            ShoppingCartSettings shoppingCartSettings,
            CatalogSettings catalogSettings)
        {
            this._workContext = workContext;
            this._storeContext = storeContext;
            this._priceCalculationService = priceCalculationService;
            this._taxService = taxService;
            this._shippingService = shippingService;
            this._providerManager = providerManager;
            this._checkoutAttributeParser = checkoutAttributeParser;
            this._discountService = discountService;
            this._giftCardService = giftCardService;
            this._genericAttributeService = genericAttributeService;
            this._productAttributeParser = productAttributeParser;
            this._taxSettings = taxSettings;
            this._rewardPointsSettings = rewardPointsSettings;
            this._shippingSettings = shippingSettings;
            this._shoppingCartSettings = shoppingCartSettings;
            this._catalogSettings = catalogSettings;
        }
Beispiel #15
0
 public PdfService(ILocalizationService localizationService, IOrderService orderService,
     IPaymentService paymentService,
     IDateTimeHelper dateTimeHelper, IPriceFormatter priceFormatter,
     ICurrencyService currencyService, IMeasureService measureService,
     IPictureService pictureService, IProductService productService, 
     IProductAttributeParser productAttributeParser, IWebHelper webHelper, 
     CatalogSettings catalogSettings, CurrencySettings currencySettings,
     MeasureSettings measureSettings, PdfSettings pdfSettings, TaxSettings taxSettings,
     StoreInformationSettings storeInformationSettings, AddressSettings addressSettings)
 {
     this._localizationService = localizationService;
     this._orderService = orderService;
     this._paymentService = paymentService;
     this._dateTimeHelper = dateTimeHelper;
     this._priceFormatter = priceFormatter;
     this._currencyService = currencyService;
     this._measureService = measureService;
     this._pictureService = pictureService;
     this._productService = productService;
     this._productAttributeParser = productAttributeParser;
     this._webHelper = webHelper;
     this._currencySettings = currencySettings;
     this._catalogSettings = catalogSettings;
     this._measureSettings = measureSettings;
     this._pdfSettings = pdfSettings;
     this._taxSettings = taxSettings;
     this._storeInformationSettings = storeInformationSettings;
     this._addressSettings = addressSettings;
 }
Beispiel #16
0
        public CatalogController(ICategoryService categoryService, 
            IManufacturerService manufacturerService, IProductService productService, 
            IProductTemplateService productTemplateService,
            ICategoryTemplateService categoryTemplateService,
            IManufacturerTemplateService manufacturerTemplateService,
            IProductAttributeService productAttributeService, IProductAttributeParser productAttributeParser, 
            IWorkContext workContext, ITaxService taxService, ICurrencyService currencyService,
            IPictureService pictureService, ILocalizationService localizationService,
            IPriceCalculationService priceCalculationService, IPriceFormatter priceFormatter,
            IWebHelper webHelper, ISpecificationAttributeService specificationAttributeService,
            ICustomerContentService customerContentService, IDateTimeHelper dateTimeHelper,
            IShoppingCartService shoppingCartService,
            IRecentlyViewedProductsService recentlyViewedProductsService, ICompareProductsService compareProductsService,
            IWorkflowMessageService workflowMessageService, IProductTagService productTagService,
            IOrderReportService orderReportService, ICustomerService customerService,
            IBackInStockSubscriptionService backInStockSubscriptionService,
            IPermissionService permissionService,
            MediaSettings mediaSetting, CatalogSettings catalogSettings,
            ShoppingCartSettings shoppingCartSettings, StoreInformationSettings storeInformationSettings,
            LocalizationSettings localizationSettings, CustomerSettings customerSettings, ICacheManager cacheManager)
        {
            this._categoryService = categoryService;
            this._manufacturerService = manufacturerService;
            this._productService = productService;
            this._productTemplateService = productTemplateService;
            this._categoryTemplateService = categoryTemplateService;
            this._manufacturerTemplateService = manufacturerTemplateService;
            this._productAttributeService = productAttributeService;
            this._productAttributeParser = productAttributeParser;
            this._workContext = workContext;
            this._taxService = taxService;
            this._currencyService = currencyService;
            this._pictureService = pictureService;
            this._localizationService = localizationService;
            this._priceCalculationService = priceCalculationService;
            this._priceFormatter = priceFormatter;
            this._webHelper = webHelper;
            this._specificationAttributeService = specificationAttributeService;
            this._customerContentService = customerContentService;
            this._dateTimeHelper = dateTimeHelper;
            this._shoppingCartService = shoppingCartService;
            this._recentlyViewedProductsService = recentlyViewedProductsService;
            this._compareProductsService = compareProductsService;
            this._workflowMessageService = workflowMessageService;
            this._productTagService = productTagService;
            this._orderReportService = orderReportService;
            this._customerService = customerService;
            this._backInStockSubscriptionService = backInStockSubscriptionService;
            this._permissionService = permissionService;

            this._mediaSetting = mediaSetting;
            this._catalogSettings = catalogSettings;
            this._shoppingCartSettings = shoppingCartSettings;
            this._storeInformationSettings = storeInformationSettings;
            this._localizationSettings = localizationSettings;
            this._customerSettings = customerSettings;

            this._cacheManager = cacheManager;
        }
        public ProductController(
			ICommonServices services,
			IManufacturerService manufacturerService,
			IProductService productService,
			IProductAttributeService productAttributeService,
			IProductAttributeParser productAttributeParser,
			ITaxService taxService,
			ICurrencyService currencyService,
			IPictureService pictureService,
			IPriceCalculationService priceCalculationService, 
			IPriceFormatter priceFormatter,
			ICustomerContentService customerContentService, 
			ICustomerService customerService,
			IShoppingCartService shoppingCartService,
			IRecentlyViewedProductsService recentlyViewedProductsService, 
			IWorkflowMessageService workflowMessageService, 
			IProductTagService productTagService,
			IOrderReportService orderReportService,
			IBackInStockSubscriptionService backInStockSubscriptionService, 
			IAclService aclService,
			IStoreMappingService storeMappingService,
			MediaSettings mediaSettings, 
			CatalogSettings catalogSettings,
			ShoppingCartSettings shoppingCartSettings,
			LocalizationSettings localizationSettings, 
			CaptchaSettings captchaSettings,
			CatalogHelper helper,
            IDownloadService downloadService,
            ILocalizationService localizationService)
        {
            this._services = services;
            this._manufacturerService = manufacturerService;
            this._productService = productService;
            this._productAttributeService = productAttributeService;
            this._productAttributeParser = productAttributeParser;
            this._taxService = taxService;
            this._currencyService = currencyService;
            this._pictureService = pictureService;
            this._priceCalculationService = priceCalculationService;
            this._priceFormatter = priceFormatter;
            this._customerContentService = customerContentService;
            this._customerService = customerService;
            this._shoppingCartService = shoppingCartService;
            this._recentlyViewedProductsService = recentlyViewedProductsService;
            this._workflowMessageService = workflowMessageService;
            this._productTagService = productTagService;
            this._orderReportService = orderReportService;
            this._backInStockSubscriptionService = backInStockSubscriptionService;
            this._aclService = aclService;
            this._storeMappingService = storeMappingService;
            this._mediaSettings = mediaSettings;
            this._catalogSettings = catalogSettings;
            this._shoppingCartSettings = shoppingCartSettings;
            this._localizationSettings = localizationSettings;
            this._captchaSettings = captchaSettings;
            this._helper = helper;
            this._downloadService = downloadService;
            this._localizationService = localizationService;
        }
 public PdfService(ILocalizationService localizationService,
     ILanguageService languageService,
     IWorkContext workContext,
     IOrderService orderService,
     IPaymentService paymentService,
     IDateTimeHelper dateTimeHelper,
     IPriceFormatter priceFormatter,
     ICurrencyService currencyService,
     IMeasureService measureService,
     IPictureService pictureService,
     IProductService productService,
     IProductAttributeParser productAttributeParser,
     IStoreService storeService,
     IStoreContext storeContext,
     ISettingService settingContext,
     IWebHelper webHelper,
     IAddressAttributeFormatter addressAttributeFormatter,
     CatalogSettings catalogSettings,
     CurrencySettings currencySettings,
     MeasureSettings measureSettings,
     PdfSettings pdfSettings,
     TaxSettings taxSettings,
     AddressSettings addressSettings,
     PromoSettings promoSettings,
     IPromoOrderService promoOrderService)
     : base(localizationService, languageService, workContext, orderService, paymentService, dateTimeHelper, priceFormatter,
                                             currencyService, measureService, pictureService, productService, productAttributeParser, storeService, storeContext,
                                             settingContext, webHelper, addressAttributeFormatter, catalogSettings, currencySettings, measureSettings,
                                             pdfSettings, taxSettings, addressSettings)
 {
     this._localizationService = localizationService;
     this._languageService = languageService;
     this._workContext = workContext;
     this._orderService = orderService;
     this._paymentService = paymentService;
     this._dateTimeHelper = dateTimeHelper;
     this._priceFormatter = priceFormatter;
     this._currencyService = currencyService;
     this._measureService = measureService;
     this._pictureService = pictureService;
     this._productService = productService;
     this._productAttributeParser = productAttributeParser;
     this._storeService = storeService;
     this._storeContext = storeContext;
     this._settingContext = settingContext;
     this._webHelper = webHelper;
     this._addressAttributeFormatter = addressAttributeFormatter;
     this._currencySettings = currencySettings;
     this._catalogSettings = catalogSettings;
     this._measureSettings = measureSettings;
     this._pdfSettings = pdfSettings;
     this._taxSettings = taxSettings;
     this._addressSettings = addressSettings;
     this._promoSettings = promoSettings;
     this._promoOrderService = promoOrderService;
 }
Beispiel #19
0
 public OrderController(IOrderService orderService, 
     IShipmentService shipmentService, 
     IWorkContext workContext,
     ICurrencyService currencyService,
     IPriceFormatter priceFormatter,
     IOrderProcessingService orderProcessingService, 
     IDateTimeHelper dateTimeHelper,
     IPaymentService paymentService, 
     ILocalizationService localizationService,
     IPdfService pdfService, 
     IShippingService shippingService,
     ICountryService countryService, 
     IProductAttributeParser productAttributeParser,
     IWebHelper webHelper,
     IDownloadService downloadService,
     IAddressAttributeFormatter addressAttributeFormatter,
     IStoreContext storeContext,
     IOrderTotalCalculationService orderTotalCalculationService,
     IRewardPointsService rewardPointsService,
     IGiftCardService giftCardService,
     CatalogSettings catalogSettings,
     OrderSettings orderSettings,
     TaxSettings taxSettings,
     ShippingSettings shippingSettings, 
     AddressSettings addressSettings,
     RewardPointsSettings rewardPointsSettings,
     PdfSettings pdfSettings)
 {
     this._orderService = orderService;
     this._shipmentService = shipmentService;
     this._workContext = workContext;
     this._currencyService = currencyService;
     this._priceFormatter = priceFormatter;
     this._orderProcessingService = orderProcessingService;
     this._dateTimeHelper = dateTimeHelper;
     this._paymentService = paymentService;
     this._localizationService = localizationService;
     this._pdfService = pdfService;
     this._shippingService = shippingService;
     this._countryService = countryService;
     this._productAttributeParser = productAttributeParser;
     this._webHelper = webHelper;
     this._downloadService = downloadService;
     this._addressAttributeFormatter = addressAttributeFormatter;
     this._storeContext = storeContext;
     this._rewardPointsService = rewardPointsService;
     this._giftCardService = giftCardService;
     this._orderTotalCalculationService = orderTotalCalculationService;
     this._catalogSettings = catalogSettings;
     this._orderSettings = orderSettings;
     this._taxSettings = taxSettings;
     this._shippingSettings = shippingSettings;
     this._addressSettings = addressSettings;
     this._rewardPointsSettings = rewardPointsSettings;
     this._pdfSettings = pdfSettings;
 }
 public ShoppingCartService(IRepository<ShoppingCartItem> sciRepository,
     IWorkContext workContext, IStoreContext storeContext,
     ICurrencyService currencyService,
     IProductService productService, ILocalizationService localizationService,
     IProductAttributeParser productAttributeParser,
     global::Nop.Services.Orders.ICheckoutAttributeService checkoutAttributeService,
     global::Nop.Services.Orders.ICheckoutAttributeParser checkoutAttributeParser,
     IPriceFormatter priceFormatter,
     ICustomerService customerService,
     ShoppingCartSettings shoppingCartSettings,
     IEventPublisher eventPublisher,
     IPermissionService permissionService,
     IAclService aclService,
     IStoreMappingService storeMappingService,
     IGenericAttributeService genericAttributeService,
     IProductAttributeService productAttributeService,
     PromoSettings promoSettings) :
     base( sciRepository,
         workContext,
         storeContext,
         currencyService,
         productService,
         localizationService,
         productAttributeParser,
         checkoutAttributeService,
         checkoutAttributeParser,
         priceFormatter,
         customerService,
         shoppingCartSettings,
         eventPublisher,
         permissionService,
         aclService,
         storeMappingService,
         genericAttributeService,
         productAttributeService)
 {
     this._sciRepository = sciRepository;
     this._workContext = workContext;
     this._storeContext = storeContext;
     this._currencyService = currencyService;
     this._productService = productService;
     this._localizationService = localizationService;
     this._productAttributeParser = productAttributeParser;
     this._checkoutAttributeService = checkoutAttributeService;
     this._checkoutAttributeParser = checkoutAttributeParser;
     this._priceFormatter = priceFormatter;
     this._customerService = customerService;
     this._shoppingCartSettings = shoppingCartSettings;
     this._eventPublisher = eventPublisher;
     this._permissionService = permissionService;
     this._aclService = aclService;
     this._storeMappingService = storeMappingService;
     this._genericAttributeService = genericAttributeService;
     this._productAttributeService = productAttributeService;
     this._promoSettings = promoSettings;
 }
 public MtProductService(ICacheManager cacheManager,
     IRepository<Product> productRepository,
     IRepository<RelatedProduct> relatedProductRepository,
     IRepository<CrossSellProduct> crossSellProductRepository,
     IRepository<TierPrice> tierPriceRepository,
     IRepository<ProductPicture> productPictureRepository,
     IRepository<LocalizedProperty> localizedPropertyRepository,
     IRepository<AclRecord> aclRepository,
     IRepository<StoreMapping> storeMappingRepository,
     IRepository<ProductSpecificationAttribute> productSpecificationAttributeRepository,
     IRepository<ProductReview> productReviewRepository,
     IRepository<ProductWarehouseInventory> productWarehouseInventoryRepository,
     IProductAttributeService productAttributeService,
     IProductAttributeParser productAttributeParser,
     ILanguageService languageService,
     IWorkflowMessageService workflowMessageService,
     IDataProvider dataProvider,
     IDbContext dbContext,
     IWorkContext workContext,
     IStoreContext storeContext,
     LocalizationSettings localizationSettings,
     CommonSettings commonSettings,
     CatalogSettings catalogSettings,
     IEventPublisher eventPublisher,
     IAclService aclService,
     IStoreMappingService storeMappingService)
 {
     this._cacheManager = cacheManager;
     this._productRepository = productRepository;
     this._relatedProductRepository = relatedProductRepository;
     this._crossSellProductRepository = crossSellProductRepository;
     this._tierPriceRepository = tierPriceRepository;
     this._productPictureRepository = productPictureRepository;
     this._localizedPropertyRepository = localizedPropertyRepository;
     this._aclRepository = aclRepository;
     this._storeMappingRepository = storeMappingRepository;
     this._productSpecificationAttributeRepository = productSpecificationAttributeRepository;
     this._productReviewRepository = productReviewRepository;
     this._productWarehouseInventoryRepository = productWarehouseInventoryRepository;
     this._productAttributeService = productAttributeService;
     this._productAttributeParser = productAttributeParser;
     this._languageService = languageService;
     this._workflowMessageService = workflowMessageService;
     this._dataProvider = dataProvider;
     this._dbContext = dbContext;
     this._workContext = workContext;
     this._storeContext = storeContext;
     this._localizationSettings = localizationSettings;
     this._commonSettings = commonSettings;
     this._catalogSettings = catalogSettings;
     this._eventPublisher = eventPublisher;
     this._aclService = aclService;
     this._storeMappingService = storeMappingService;
 }
 public PriceCalculationService(IWorkContext workContext,
     IDiscountService discountService, ICategoryService categoryService,
     IProductAttributeParser productAttributeParser, ShoppingCartSettings shoppingCartSettings,
     CatalogSettings catalogSettings)
 {
     this._workContext = workContext;
     this._discountService = discountService;
     this._categoryService = categoryService;
     this._productAttributeParser = productAttributeParser;
     this._shoppingCartSettings = shoppingCartSettings;
     this._catalogSettings = catalogSettings;
 }
        public MessageTokenProvider(ILanguageService languageService,
            ILocalizationService localizationService,
            IDateTimeHelper dateTimeHelper,
            IPriceFormatter priceFormatter,
            ICurrencyService currencyService,
            IWorkContext workContext,
            IDownloadService downloadService,
            IOrderService orderService,
            IPaymentService paymentService,
            IStoreService storeService,
            IStoreContext storeContext,
            IProductAttributeParser productAttributeParser,
            IAddressAttributeFormatter addressAttributeFormatter,
            MessageTemplatesSettings templatesSettings,
            CatalogSettings catalogSettings,
            TaxSettings taxSettings,
            CurrencySettings currencySettings,
            ShippingSettings shippingSettings,
            IEventPublisher eventPublisher,
            PromoSettings promoSettings,
            IPromoOrderService promoOrderService
            )
            : base(languageService, localizationService,
            dateTimeHelper, priceFormatter, currencyService, workContext,
            downloadService, orderService, paymentService, storeService,
            storeContext, productAttributeParser,
            addressAttributeFormatter, templatesSettings, catalogSettings,
            taxSettings, currencySettings, shippingSettings, eventPublisher)
        {
            this._languageService = languageService;
            this._localizationService = localizationService;
            this._dateTimeHelper = dateTimeHelper;
            this._priceFormatter = priceFormatter;
            this._currencyService = currencyService;
            this._workContext = workContext;
            this._downloadService = downloadService;
            this._orderService = orderService;
            this._paymentService = paymentService;
            this._productAttributeParser = productAttributeParser;
            this._addressAttributeFormatter = addressAttributeFormatter;
            this._storeService = storeService;
            this._storeContext = storeContext;

            this._templatesSettings = templatesSettings;
            this._catalogSettings = catalogSettings;
            this._taxSettings = taxSettings;
            this._currencySettings = currencySettings;
            this._shippingSettings = shippingSettings;
            this._eventPublisher = eventPublisher;

            this._promoSettings = promoSettings;
            this._promoOrderService = promoOrderService;
        }
        /// <summary>
        /// Formats manufacturer part number
        /// </summary>
        /// <param name="productVariant">Product variant</param>
        /// <param name="selectedAttributes">Selected attributes (XML format)</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>Manufacturer part number</returns>
        public static string FormatMpn(this ProductVariant productVariant, string selectedAttributes = null, IProductAttributeParser productAttributeParser = null)
        {
            if (productVariant == null)
                throw new ArgumentNullException("productVariant");

            string sku = null;
            string manufacturerPartNumber = null;
            string gtin = null;

            productVariant.GetSkuMpnGtin(selectedAttributes, productAttributeParser,
                out sku, out manufacturerPartNumber, out gtin);

            return manufacturerPartNumber;
        }
Beispiel #25
0
        /// <summary>
        /// Formats manufacturer part number
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Attributes in XML format</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>Manufacturer part number</returns>
        public static string FormatMpn(this Product product, string attributesXml = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
                throw new ArgumentNullException("product");

            string sku;
            string manufacturerPartNumber;
            string gtin;

            product.GetSkuMpnGtin(attributesXml, productAttributeParser,
                out sku, out manufacturerPartNumber, out gtin);

            return manufacturerPartNumber;
        }
 public WidgetsGoogleAnalyticsController(IWorkContext workContext,
     IStoreContext storeContext, IStoreService storeService,
     ISettingService settingService, IOrderService orderService, ILogger logger,
     ICategoryService categoryService, IProductAttributeParser productAttributeParser)
 {
     this._workContext = workContext;
     this._storeContext = storeContext;
     this._storeService = storeService;
     this._settingService = settingService;
     this._orderService = orderService;
     this._logger = logger;
     this._categoryService = categoryService;
     this._productAttributeParser = productAttributeParser;
 }
 public WidgetsGoogleAnalyticsController(IWorkContext workContext, ISettingService settingService,
     IOrderService orderService, ILogger logger, 
     ICategoryService categoryService, IProductAttributeParser productAttributeParser,
     GoogleAnalyticsSettings trackingScriptsSettings, StoreInformationSettings storeInformationSettings)
 {
     this._workContext = workContext;
     this._settingService = settingService;
     this._orderService = orderService;
     this._logger = logger;
     this._categoryService = categoryService;
     this._productAttributeParser = productAttributeParser;
     this._googleAnalyticsSettings = trackingScriptsSettings;
     this._storeInformationSettings = storeInformationSettings;
 }
Beispiel #28
0
        /// <summary>
        /// Get product picture (for shopping cart and order details pages)
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Atributes (in XML format)</param>
        /// <param name="pictureService">Picture service</param>
        /// <param name="productAttributeParser">Product attribute service</param>
        /// <returns>Picture</returns>
        public static Picture GetProductPicture(this Product product, string attributesXml,
            IPictureService pictureService,
            IProductAttributeParser productAttributeParser)
        {
            if (product == null)
                throw new ArgumentNullException("product");
            if (pictureService == null)
                throw new ArgumentNullException("pictureService");
            if (productAttributeParser == null)
                throw new ArgumentNullException("productAttributeParser");

            Picture picture = null;

            //first, let's see whether we have some attribute values with custom pictures
            if (!String.IsNullOrEmpty(attributesXml))
            {
                var attributeValues = productAttributeParser.ParseProductAttributeValues(product, attributesXml);
                foreach (var attributeValue in attributeValues)
                {
                    var attributePicture = pictureService.GetPictureById(attributeValue.PictureId);
                    if (attributePicture != null)
                    {
                        picture = attributePicture;
                        break;
                    }
                }
            }
            //now let's load the default product picture
            if (picture == null)
            {
                var pp = product.ProductPictures.FirstOrDefault();
                if (pp != null)
                    picture = pictureService.GetPictureById(pp.PictureId);
            }

            //let's check whether this product has some parent "grouped" product
            if (picture == null && !product.VisibleIndividually && product.ParentGroupedProductId > 0)
            {
                var parentProduct = EngineContext.Current.Resolve<IProductService>().GetProductById(product.ParentGroupedProductId);
                if(parentProduct!=null)
                    if(parentProduct.ProductPictures.Count > 0)
                    {
                        picture = pictureService.GetPictureById(parentProduct.ProductPictures.FirstOrDefault().PictureId);

                    }
            }

            return picture;
        }
 public ProductAttributeFormatter(IWorkContext workContext,
     IProductAttributeService productAttributeService,
     IProductAttributeParser productAttributeParser,
     ICurrencyService currencyService,
     ILocalizationService localizationService,
     ITaxService taxService,
     IPriceFormatter priceFormatter)
 {
     this._workContext = workContext;
     this._productAttributeService = productAttributeService;
     this._productAttributeParser = productAttributeParser;
     this._currencyService = currencyService;
     this._localizationService = localizationService;
     this._taxService = taxService;
     this._priceFormatter = priceFormatter;
 }
Beispiel #30
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _deliveryDateRepository = MockRepository.GenerateMock<IRepository<DeliveryDate>>();
            _warehouseRepository = MockRepository.GenerateMock<IRepository<Warehouse>>();
            _logger = new NullLogger();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            var pluginFinder = new PluginFinder();
            _productService = MockRepository.GenerateMock<IProductService>();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();
            _addressService = MockRepository.GenerateMock<IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();

            _store = new Store { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService = new ShippingService(_shippingMethodRepository,
                _deliveryDateRepository,
                _warehouseRepository,
                _logger,
                _productService,
                _productAttributeParser,
                _checkoutAttributeParser,
                _genericAttributeService,
                _localizationService,
                _addressService,
                _shippingSettings, 
                pluginFinder,
                _storeContext,
                _eventPublisher,
                _shoppingCartSettings,
                cacheManager);
        }
        public void TestInitialize()
        {
            //plugin initialization
            new Grand.Services.Tests.ServiceTest().PluginInitializator();

            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >().Object;
            _deliveryDateRepository   = new Mock <IRepository <DeliveryDate> >().Object;
            _warehouseRepository      = new Mock <IRepository <Warehouse> >().Object;
            _logger = new NullLogger();
            _productAttributeParser  = new Mock <IProductAttributeParser>().Object;
            _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>().Object;
            _pickupPointRepository   = new Mock <IRepository <PickupPoint> >().Object;
            _serviceProvider         = new Mock <IServiceProvider>().Object;

            var cacheManager = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object);

            var pluginFinder = new PluginFinder(_serviceProvider);

            _countryService       = new Mock <ICountryService>().Object;
            _stateProvinceService = new Mock <IStateProvinceService>().Object;
            _currencyService      = new Mock <ICurrencyService>().Object;
            _productService       = new Mock <IProductService>().Object;

            var tempEventPublisher = new Mock <IEventPublisher>();

            {
                tempEventPublisher.Setup(x => x.Publish(It.IsAny <object>()));
                _eventPublisher = tempEventPublisher.Object;
            }

            _localizationService     = new Mock <ILocalizationService>().Object;
            _addressService          = new Mock <IAddressService>().Object;
            _genericAttributeService = new Mock <IGenericAttributeService>().Object;

            _store = new Store {
                Id = "1"
            };
            var tempStoreContext = new Mock <IStoreContext>();

            {
                tempStoreContext.Setup(x => x.CurrentStore).Returns(_store);
                _storeContext = tempStoreContext.Object;
            }

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService      = new ShippingService(_shippingMethodRepository,
                                                        _deliveryDateRepository,
                                                        _warehouseRepository,
                                                        null,
                                                        _logger,
                                                        _productService,
                                                        _productAttributeParser,
                                                        _checkoutAttributeParser,
                                                        _genericAttributeService,
                                                        _localizationService,
                                                        _addressService,
                                                        _countryService,
                                                        _stateProvinceService,
                                                        pluginFinder,
                                                        _storeContext,
                                                        _eventPublisher,
                                                        _currencyService,
                                                        cacheManager,
                                                        null,
                                                        _shoppingCartSettings,
                                                        _shippingSettings);
        }
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="orderService">Order service</param>
        /// <param name="webHelper">Web helper</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="languageService">Language service</param>
        /// <param name="productService">Product service</param>
        /// <param name="paymentService">Payment service</param>
        /// <param name="logger">Logger</param>
        /// <param name="orderTotalCalculationService">Order total calculationservice</param>
        /// <param name="priceCalculationService">Price calculation service</param>
        /// <param name="priceFormatter">Price formatter</param>
        /// <param name="productAttributeParser">Product attribute parser</param>
        /// <param name="productAttributeFormatter">Product attribute formatter</param>
        /// <param name="giftCardService">Gift card service</param>
        /// <param name="shoppingCartService">Shopping cart service</param>
        /// <param name="checkoutAttributeFormatter">Checkout attribute service</param>
        /// <param name="shippingService">Shipping service</param>
        /// <param name="shipmentService">Shipment service</param>
        /// <param name="taxService">Tax service</param>
        /// <param name="customerService">Customer service</param>
        /// <param name="discountService">Discount service</param>
        /// <param name="encryptionService">Encryption service</param>
        /// <param name="workContext">Work context</param>
        /// <param name="workflowMessageService">Workflow message service</param>
        /// <param name="vendorService">Vendor service</param>
        /// <param name="customerActivityService">Customer activity service</param>
        /// <param name="currencyService">Currency service</param>
        /// <param name="affiliateService">Affiliate service</param>
        /// <param name="eventPublisher">Event published</param>
        /// <param name="pdfService">PDF service</param>
        /// <param name="rewardPointService">Reward point service</param>
        /// <param name="genericAttributeService">Generic attribute service</param>
        /// <param name="countryService">Country service</param>
        /// <param name="paymentSettings">Payment settings</param>
        /// <param name="shippingSettings">Shipping settings</param>
        /// <param name="rewardPointsSettings">Reward points settings</param>
        /// <param name="orderSettings">Order settings</param>
        /// <param name="taxSettings">Tax settings</param>
        /// <param name="localizationSettings">Localization settings</param>
        /// <param name="currencySettings">Currency settings</param>
        /// <param name="customNumberFormatter">Custom number formatter</param>
        public BitcoinOrderProcessingService(IOrderService orderService,
                                             IWebHelper webHelper,
                                             ILocalizationService localizationService,
                                             ILanguageService languageService,
                                             IProductService productService,
                                             IPaymentService paymentService,
                                             ILogger logger,
                                             IOrderTotalCalculationService orderTotalCalculationService,
                                             IPriceCalculationService priceCalculationService,
                                             IPriceFormatter priceFormatter,
                                             IProductAttributeParser productAttributeParser,
                                             IProductAttributeFormatter productAttributeFormatter,
                                             IGiftCardService giftCardService,
                                             IShoppingCartService shoppingCartService,
                                             ICheckoutAttributeFormatter checkoutAttributeFormatter,
                                             IShippingService shippingService,
                                             IShipmentService shipmentService,
                                             ITaxService taxService,
                                             ICustomerService customerService,
                                             IDiscountService discountService,
                                             IEncryptionService encryptionService,
                                             IWorkContext workContext,
                                             IWorkflowMessageService workflowMessageService,
                                             IVendorService vendorService,
                                             ICustomerActivityService customerActivityService,
                                             ICurrencyService currencyService,
                                             IAffiliateService affiliateService,
                                             IEventPublisher eventPublisher,
                                             IPdfService pdfService,
                                             IRewardPointService rewardPointService,
                                             IGenericAttributeService genericAttributeService,
                                             ICountryService countryService,
                                             IStateProvinceService stateProvinceService,
                                             ShippingSettings shippingSettings,
                                             PaymentSettings paymentSettings,
                                             RewardPointsSettings rewardPointsSettings,
                                             OrderSettings orderSettings,
                                             TaxSettings taxSettings,
                                             LocalizationSettings localizationSettings,
                                             CurrencySettings currencySettings,
                                             ICustomNumberFormatter customNumberFormatter) : base(orderService, webHelper, localizationService, languageService, productService, paymentService, logger, orderTotalCalculationService, priceCalculationService, priceFormatter, productAttributeParser, productAttributeFormatter, giftCardService, shoppingCartService, checkoutAttributeFormatter, shippingService, shipmentService, taxService, customerService, discountService, encryptionService, workContext, workflowMessageService, vendorService, customerActivityService, currencyService, affiliateService, eventPublisher, pdfService, rewardPointService, genericAttributeService, countryService, stateProvinceService, shippingSettings, paymentSettings, rewardPointsSettings, orderSettings, taxSettings, localizationSettings, currencySettings, customNumberFormatter)
        {
            this._orderService        = orderService;
            this._webHelper           = webHelper;
            this._localizationService = localizationService;
            this._languageService     = languageService;
            this._productService      = productService;
            this._paymentService      = paymentService;
            this._logger = logger;
            this._orderTotalCalculationService = orderTotalCalculationService;
            this._priceCalculationService      = priceCalculationService;
            this._priceFormatter             = priceFormatter;
            this._productAttributeParser     = productAttributeParser;
            this._productAttributeFormatter  = productAttributeFormatter;
            this._giftCardService            = giftCardService;
            this._shoppingCartService        = shoppingCartService;
            this._checkoutAttributeFormatter = checkoutAttributeFormatter;
            this._workContext             = workContext;
            this._workflowMessageService  = workflowMessageService;
            this._vendorService           = vendorService;
            this._shippingService         = shippingService;
            this._shipmentService         = shipmentService;
            this._taxService              = taxService;
            this._customerService         = customerService;
            this._discountService         = discountService;
            this._encryptionService       = encryptionService;
            this._customerActivityService = customerActivityService;
            this._currencyService         = currencyService;
            this._affiliateService        = affiliateService;
            this._eventPublisher          = eventPublisher;
            this._pdfService              = pdfService;
            this._rewardPointService      = rewardPointService;
            this._genericAttributeService = genericAttributeService;
            this._countryService          = countryService;
            this._stateProvinceService    = stateProvinceService;

            this._paymentSettings       = paymentSettings;
            this._shippingSettings      = shippingSettings;
            this._rewardPointsSettings  = rewardPointsSettings;
            this._orderSettings         = orderSettings;
            this._taxSettings           = taxSettings;
            this._localizationSettings  = localizationSettings;
            this._currencySettings      = currencySettings;
            this._customNumberFormatter = customNumberFormatter;
        }
Beispiel #33
0
        public virtual async Task <IActionResult> ProductDetails_WarehouseChange(string productId, string warehouseId, [FromServices] IProductAttributeParser productAttributeParser)
        {
            var product = await _productService.GetProductById(productId);

            if (product == null)
            {
                return(new NullJsonResult());
            }

            var stock = product.FormatStockMessage(warehouseId, "", _localizationService, productAttributeParser);

            return(Json(new
            {
                stockAvailability = stock
            }));
        }
 public FakeProductService(CatalogSettings catalogSettings                                                 = null,
                           CommonSettings commonSettings                                                   = null,
                           IAclService aclService                                                          = null,
                           ICacheKeyService cacheKeyService                                                = null,
                           ICustomerService customerService                                                = null,
                           INopDataProvider dataProvider                                                   = null,
                           IDateRangeService dateRangeService                                              = null,
                           IEventPublisher eventPublisher                                                  = null,
                           ILanguageService languageService                                                = null,
                           ILocalizationService localizationService                                        = null,
                           IProductAttributeParser productAttributeParser                                  = null,
                           IProductAttributeService productAttributeService                                = null,
                           IRepository <AclRecord> aclRepository                                           = null,
                           IRepository <CrossSellProduct> crossSellProductRepository                       = null,
                           IRepository <DiscountProductMapping> discountProductMappingRepository           = null,
                           IRepository <Product> productRepository                                         = null,
                           IRepository <ProductAttributeCombination> productAttributeCombinationRepository = null,
                           IRepository <ProductAttributeMapping> productAttributeMappingRepository         = null,
                           IRepository <ProductCategory> productCategoryRepository                         = null,
                           IRepository <ProductPicture> productPictureRepository                           = null,
                           IRepository <ProductReview> productReviewRepository                             = null,
                           IRepository <ProductReviewHelpfulness> productReviewHelpfulnessRepository       = null,
                           IRepository <ProductWarehouseInventory> productWarehouseInventoryRepository     = null,
                           IRepository <RelatedProduct> relatedProductRepository                           = null,
                           IRepository <Shipment> shipmentRepository                                       = null,
                           IRepository <StockQuantityHistory> stockQuantityHistoryRepository               = null,
                           IRepository <StoreMapping> storeMappingRepository                               = null,
                           IRepository <TierPrice> tierPriceRepository                                     = null,
                           IRepository <Warehouse> warehouseRepository                                     = null,
                           IStaticCacheManager staticCacheManager                                          = null,
                           IStoreService storeService                                                      = null,
                           IStoreMappingService storeMappingService                                        = null,
                           IWorkContext workContext                                                        = null,
                           LocalizationSettings localizationSettings                                       = null) : base(
         catalogSettings ?? new CatalogSettings(),
         commonSettings ?? new CommonSettings(),
         aclService ?? new Mock <IAclService>().Object,
         cacheKeyService ?? new FakeCacheKeyService(),
         customerService ?? new Mock <ICustomerService>().Object,
         dataProvider ?? new Mock <INopDataProvider>().Object,
         dateRangeService ?? new Mock <IDateRangeService>().Object,
         eventPublisher ?? new Mock <IEventPublisher>().Object,
         languageService ?? new Mock <ILanguageService>().Object,
         localizationService ?? new Mock <ILocalizationService>().Object,
         productAttributeParser ?? new Mock <IProductAttributeParser>().Object,
         productAttributeService ?? new Mock <IProductAttributeService>().Object,
         aclRepository.FakeRepoNullPropagation(),
         crossSellProductRepository.FakeRepoNullPropagation(),
         discountProductMappingRepository.FakeRepoNullPropagation(),
         productRepository.FakeRepoNullPropagation(),
         productAttributeCombinationRepository.FakeRepoNullPropagation(),
         productAttributeMappingRepository.FakeRepoNullPropagation(),
         productCategoryRepository.FakeRepoNullPropagation(),
         productPictureRepository.FakeRepoNullPropagation(),
         productReviewRepository.FakeRepoNullPropagation(),
         productReviewHelpfulnessRepository.FakeRepoNullPropagation(),
         productWarehouseInventoryRepository.FakeRepoNullPropagation(),
         relatedProductRepository.FakeRepoNullPropagation(),
         shipmentRepository.FakeRepoNullPropagation(),
         stockQuantityHistoryRepository.FakeRepoNullPropagation(),
         storeMappingRepository.FakeRepoNullPropagation(),
         tierPriceRepository.FakeRepoNullPropagation(),
         warehouseRepository.FakeRepoNullPropagation(),
         staticCacheManager ?? new TestCacheManager(),
         storeService ?? new Mock <IStoreService>().Object,
         storeMappingService ?? new Mock <IStoreMappingService>().Object,
         workContext ?? new Mock <IWorkContext>().Object,
         localizationSettings ?? new LocalizationSettings())
 {
 }
Beispiel #35
0
        /// <summary>
        /// Formats GTIN
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Attributes in XML format</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>GTIN</returns>
        public static string FormatGtin(this Product product, string attributesXml = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            string sku;
            string manufacturerPartNumber;
            string gtin;

            product.GetSkuMpnGtin(attributesXml, productAttributeParser,
                                  out sku, out manufacturerPartNumber, out gtin);

            return(gtin);
        }
Beispiel #36
0
        public new void SetUp()
        {
            #region Test data

            //color (dropdownlist)
            pa1 = new ProductAttribute
            {
                Id   = 1,
                Name = "Color",
            };
            pva1_1 = new ProductVariantAttribute
            {
                Id = 11,
                ProductVariantId     = 1,
                TextPrompt           = "Select color:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.DropdownList,
                DisplayOrder         = 1,
                ProductAttribute     = pa1,
                ProductAttributeId   = pa1.Id
            };
            pvav1_1 = new ProductVariantAttributeValue
            {
                Id                        = 11,
                Name                      = "Green",
                DisplayOrder              = 1,
                ProductVariantAttribute   = pva1_1,
                ProductVariantAttributeId = pva1_1.Id
            };
            pvav1_2 = new ProductVariantAttributeValue
            {
                Id                        = 12,
                Name                      = "Red",
                DisplayOrder              = 2,
                ProductVariantAttribute   = pva1_1,
                ProductVariantAttributeId = pva1_1.Id
            };
            pva1_1.ProductVariantAttributeValues.Add(pvav1_1);
            pva1_1.ProductVariantAttributeValues.Add(pvav1_2);

            //custom option (checkboxes)
            pa2 = new ProductAttribute
            {
                Id   = 2,
                Name = "Some custom option",
            };
            pva2_1 = new ProductVariantAttribute
            {
                Id = 21,
                ProductVariantId     = 1,
                TextPrompt           = "Select at least one option:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.Checkboxes,
                DisplayOrder         = 2,
                ProductAttribute     = pa2,
                ProductAttributeId   = pa2.Id
            };
            pvav2_1 = new ProductVariantAttributeValue
            {
                Id                        = 21,
                Name                      = "Option 1",
                DisplayOrder              = 1,
                ProductVariantAttribute   = pva2_1,
                ProductVariantAttributeId = pva2_1.Id
            };
            pvav2_2 = new ProductVariantAttributeValue
            {
                Id                        = 22,
                Name                      = "Option 2",
                DisplayOrder              = 2,
                ProductVariantAttribute   = pva2_1,
                ProductVariantAttributeId = pva2_1.Id
            };
            pva2_1.ProductVariantAttributeValues.Add(pvav2_1);
            pva2_1.ProductVariantAttributeValues.Add(pvav2_2);

            //custom text
            pa3 = new ProductAttribute
            {
                Id   = 3,
                Name = "Custom text",
            };
            pva3_1 = new ProductVariantAttribute
            {
                Id = 31,
                ProductVariantId     = 1,
                TextPrompt           = "Enter custom text:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.TextBox,
                DisplayOrder         = 1,
                ProductAttribute     = pa1,
                ProductAttributeId   = pa3.Id
            };


            #endregion

            _productAttributeRepo = MockRepository.GenerateMock <IRepository <ProductAttribute> >();
            _productAttributeRepo.Expect(x => x.Table).Return(new List <ProductAttribute>()
            {
                pa1, pa2, pa3
            }.AsQueryable());
            _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1);
            _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2);
            _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3);

            _productVariantAttributeRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttribute> >();
            _productVariantAttributeRepo.Expect(x => x.Table).Return(new List <ProductVariantAttribute>()
            {
                pva1_1, pva2_1, pva3_1
            }.AsQueryable());
            _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1);
            _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1);
            _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1);

            _productVariantAttributeCombinationRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeCombination> >();
            _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeCombination>().AsQueryable());

            _productVariantAttributeValueRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeValue> >();
            _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeValue>()
            {
                pvav1_1, pvav1_2, pvav2_1, pvav2_2
            }.AsQueryable());
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2);

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            var cacheManager = new NopNullCache();

            _productAttributeService = new ProductAttributeService(cacheManager,
                                                                   _productAttributeRepo,
                                                                   _productVariantAttributeRepo,
                                                                   _productVariantAttributeCombinationRepo,
                                                                   _productVariantAttributeValueRepo,
                                                                   _eventPublisher);

            _productAttributeParser = new ProductAttributeParser(_productAttributeService);



            var workingLanguage = new Language();
            _workContext = MockRepository.GenerateMock <IWorkContext>();
            _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage);
            _currencyService     = MockRepository.GenerateMock <ICurrencyService>();
            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For")).Return("For: {0}");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From")).Return("From: {0}");
            _taxService      = MockRepository.GenerateMock <ITaxService>();
            _priceFormatter  = MockRepository.GenerateMock <IPriceFormatter>();
            _downloadService = MockRepository.GenerateMock <IDownloadService>();
            _webHelper       = MockRepository.GenerateMock <IWebHelper>();

            _productAttributeFormatter = new ProductAttributeFormatter(_workContext,
                                                                       _productAttributeService,
                                                                       _productAttributeParser,
                                                                       _currencyService,
                                                                       _localizationService,
                                                                       _taxService,
                                                                       _priceFormatter,
                                                                       _downloadService,
                                                                       _webHelper);
        }
        /// <summary>
        /// Formats the stock availability/quantity message
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Selected product attributes in XML format (if specified)</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="productAttributeParser">Product attribute parser</param>
        /// <param name="dateRangeService">Date range service</param>
        /// <returns>The stock message</returns>
        public static string FormatStockMessage(this Product product, string attributesXml,
                                                ILocalizationService localizationService, IProductAttributeParser productAttributeParser, IDateRangeService dateRangeService)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            if (localizationService == null)
            {
                throw new ArgumentNullException("localizationService");
            }

            if (productAttributeParser == null)
            {
                throw new ArgumentNullException("productAttributeParser");
            }

            if (dateRangeService == null)
            {
                throw new ArgumentNullException("dateRangeService");
            }

            string stockMessage = string.Empty;

            switch (product.ManageInventoryMethod)
            {
            case ManageInventoryMethod.ManageStock:
            {
                #region Manage stock

                if (!product.DisplayStockAvailability)
                {
                    return(stockMessage);
                }

                var stockQuantity = product.GetTotalStockQuantity();
                if (stockQuantity > 0)
                {
                    stockMessage = product.DisplayStockQuantity ?
                                   //display "in stock" with stock quantity
                                   string.Format(localizationService.GetResource("Products.Availability.InStockWithQuantity"), stockQuantity) :
                                   //display "in stock" without stock quantity
                                   localizationService.GetResource("Products.Availability.InStock");
                }
                else
                {
                    //out of stock
                    var productAvailabilityRange = dateRangeService.GetProductAvailabilityRangeById(product.ProductAvailabilityRangeId);
                    switch (product.BackorderMode)
                    {
                    case BackorderMode.NoBackorders:
                        stockMessage = productAvailabilityRange == null?localizationService.GetResource("Products.Availability.OutOfStock")
                                           : string.Format(localizationService.GetResource("Products.Availability.AvailabilityRange"),
                                                           productAvailabilityRange.GetLocalized(range => range.Name));

                        break;

                    case BackorderMode.AllowQtyBelow0:
                        stockMessage = localizationService.GetResource("Products.Availability.InStock");
                        break;

                    case BackorderMode.AllowQtyBelow0AndNotifyCustomer:
                        stockMessage = productAvailabilityRange == null?localizationService.GetResource("Products.Availability.Backordering")
                                           : string.Format(localizationService.GetResource("Products.Availability.BackorderingWithDate"),
                                                           productAvailabilityRange.GetLocalized(range => range.Name));

                        break;

                    default:
                        break;
                    }
                }

                #endregion
            }
            break;

            case ManageInventoryMethod.ManageStockByAttributes:
            {
                #region Manage stock by attributes

                if (!product.DisplayStockAvailability)
                {
                    return(stockMessage);
                }

                var combination = productAttributeParser.FindProductAttributeCombination(product, attributesXml);
                if (combination != null)
                {
                    //combination exists
                    var stockQuantity = combination.StockQuantity;
                    if (stockQuantity > 0)
                    {
                        stockMessage = product.DisplayStockQuantity ?
                                       //display "in stock" with stock quantity
                                       string.Format(localizationService.GetResource("Products.Availability.InStockWithQuantity"), stockQuantity) :
                                       //display "in stock" without stock quantity
                                       localizationService.GetResource("Products.Availability.InStock");
                    }
                    else if (combination.AllowOutOfStockOrders)
                    {
                        stockMessage = localizationService.GetResource("Products.Availability.InStock");
                    }
                    else
                    {
                        var productAvailabilityRange = dateRangeService.GetProductAvailabilityRangeById(product.ProductAvailabilityRangeId);
                        stockMessage = productAvailabilityRange == null?localizationService.GetResource("Products.Availability.OutOfStock")
                                           : string.Format(localizationService.GetResource("Products.Availability.AvailabilityRange"),
                                                           productAvailabilityRange.GetLocalized(range => range.Name));
                    }
                }
                else
                {
                    //no combination configured
                    if (product.AllowAddingOnlyExistingAttributeCombinations)
                    {
                        var productAvailabilityRange = dateRangeService.GetProductAvailabilityRangeById(product.ProductAvailabilityRangeId);
                        stockMessage = productAvailabilityRange == null?localizationService.GetResource("Products.Availability.OutOfStock")
                                           : string.Format(localizationService.GetResource("Products.Availability.AvailabilityRange"),
                                                           productAvailabilityRange.GetLocalized(range => range.Name));
                    }
                    else
                    {
                        stockMessage = localizationService.GetResource("Products.Availability.InStock");
                    }
                }

                #endregion
            }
            break;

            case ManageInventoryMethod.DontManageStock:
            default:
                return(stockMessage);
            }
            return(stockMessage);
        }
        /// <summary>
        /// Gets SKU, Collection part number and GTIN
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Attributes</param>
        /// <param name="productAttributeParser">Product attribute service</param>
        /// <param name="sku">SKU</param>
        /// <param name="Mpn">MPN</param>
        /// <param name="gtin">GTIN</param>
        private static void GetSkuMpnGtin(this Product product, IList <CustomAttribute> attributes, IProductAttributeParser productAttributeParser,
                                          out string sku, out string Mpn, out string gtin)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            sku  = null;
            Mpn  = null;
            gtin = null;

            if (attributes != null &&
                product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)
            {
                if (productAttributeParser == null)
                {
                    throw new ArgumentNullException(nameof(productAttributeParser));
                }

                var combination = productAttributeParser.FindProductAttributeCombination(product, attributes);
                if (combination != null)
                {
                    sku  = combination.Sku;
                    Mpn  = combination.Mpn;
                    gtin = combination.Gtin;
                }
            }

            if (string.IsNullOrEmpty(sku))
            {
                sku = product.Sku;
            }
            if (string.IsNullOrEmpty(Mpn))
            {
                Mpn = product.Mpn;
            }
            if (string.IsNullOrEmpty(gtin))
            {
                gtin = product.Gtin;
            }
        }
        /// <summary>
        /// GTIN
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Attributes</param>
        /// <param name="productAttributeParser">Product attribute service</param>
        /// <returns>GTIN</returns>
        public static string FormatGtin(this Product product, IList <CustomAttribute> attributes = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            string gtin;

            product.GetSkuMpnGtin(attributes, productAttributeParser,
                                  out _, out _, out gtin);

            return(gtin);
        }
        /// <summary>
        /// Formats manufacturer part number
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Attributes</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>Manufacturer part number</returns>
        public static string FormatMpn(this Product product, IList <CustomAttribute> attributes = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            string manufacturerPartNumber;

            product.GetSkuMpnGtin(attributes, productAttributeParser,
                                  out _, out manufacturerPartNumber, out _);

            return(manufacturerPartNumber);
        }
        /// <summary>
        /// Formats the stock availability/quantity message
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Selected product attributes (if specified)</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="productAttributeParser">Product attribute parser</param>
        /// <returns>The stock message</returns>
        public static string FormatStockMessage(this Product product, string warehouseId, IList <CustomAttribute> attributes,
                                                ILocalizationService localizationService, IProductAttributeParser productAttributeParser)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            if (localizationService == null)
            {
                throw new ArgumentNullException("localizationService");
            }

            if (productAttributeParser == null)
            {
                throw new ArgumentNullException("productAttributeParser");
            }

            string stockMessage = string.Empty;

            switch (product.ManageInventoryMethod)
            {
            case ManageInventoryMethod.ManageStock:
            {
                #region Manage stock

                if (!product.DisplayStockAvailability)
                {
                    return(stockMessage);
                }

                var stockQuantity = product.GetTotalStockQuantity(warehouseId: warehouseId);
                if (stockQuantity > 0)
                {
                    stockMessage = product.DisplayStockQuantity ?
                                   //display "in stock" with stock quantity
                                   string.Format(localizationService.GetResource("Products.Availability.InStockWithQuantity"), stockQuantity) :
                                   //display "in stock" without stock quantity
                                   localizationService.GetResource("Products.Availability.InStock");
                }
                else
                {
                    //out of stock
                    switch (product.BackorderMode)
                    {
                    case BackorderMode.NoBackorders:
                        stockMessage = localizationService.GetResource("Products.Availability.OutOfStock");
                        break;

                    case BackorderMode.AllowQtyBelow0:
                        stockMessage = localizationService.GetResource("Products.Availability.InStock");
                        break;

                    case BackorderMode.AllowQtyBelow0AndNotifyCustomer:
                        stockMessage = localizationService.GetResource("Products.Availability.Backordering");
                        break;

                    default:
                        break;
                    }
                }

                #endregion
            }
            break;

            case ManageInventoryMethod.ManageStockByAttributes:
            {
                #region Manage stock by attributes

                if (!product.DisplayStockAvailability)
                {
                    return(stockMessage);
                }

                var combination = productAttributeParser.FindProductAttributeCombination(product, attributes);
                if (combination != null)
                {
                    //combination exists
                    var stockQuantity = product.GetTotalStockQuantityForCombination(combination, warehouseId: warehouseId);
                    if (stockQuantity > 0)
                    {
                        stockMessage = product.DisplayStockQuantity ?
                                       //display "in stock" with stock quantity
                                       string.Format(localizationService.GetResource("Products.Availability.InStockWithQuantity"), stockQuantity) :
                                       //display "in stock" without stock quantity
                                       localizationService.GetResource("Products.Availability.InStock");
                    }
                    else
                    {
                        //out of stock
                        switch (product.BackorderMode)
                        {
                        case BackorderMode.NoBackorders:
                            stockMessage = localizationService.GetResource("Products.Availability.Attributes.OutOfStock");
                            break;

                        case BackorderMode.AllowQtyBelow0:
                            stockMessage = localizationService.GetResource("Products.Availability.Attributes.InStock");
                            break;

                        case BackorderMode.AllowQtyBelow0AndNotifyCustomer:
                            stockMessage = localizationService.GetResource("Products.Availability.Attributes.Backordering");
                            break;

                        default:
                            break;
                        }
                        if (!combination.AllowOutOfStockOrders)
                        {
                            stockMessage = localizationService.GetResource("Products.Availability.Attributes.OutOfStock");
                        }
                    }
                }
                else
                {
                    //no combination configured
                    stockMessage = localizationService.GetResource("Products.Availability.InStock");
                    if (product.AllowAddingOnlyExistingAttributeCombinations)
                    {
                        stockMessage = localizationService.GetResource("Products.Availability.AllowAddingOnlyExistingAttributeCombinations.Yes");
                    }
                    else
                    {
                        stockMessage = localizationService.GetResource("Products.Availability.AllowAddingOnlyExistingAttributeCombinations.No");
                    }
                }

                #endregion
            }
            break;

            case ManageInventoryMethod.DontManageStock:
            case ManageInventoryMethod.ManageStockByBundleProducts:
            default:
                return(stockMessage);
            }
            return(stockMessage);
        }
        /// <summary>
        /// Formats SKU
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Attributes</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>SKU</returns>
        public static string FormatSku(this Product product, IList <CustomAttribute> attributes = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            string sku;

            product.GetSkuMpnGtin(attributes, productAttributeParser,
                                  out sku, out _, out _);

            return(sku);
        }
        /// <summary>
        /// Gets SKU, Manufacturer part number and GTIN
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Attributes</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <param name="sku">SKU</param>
        /// <param name="manufacturerPartNumber">Manufacturer part number</param>
        /// <param name="gtin">GTIN</param>
        private static void GetSkuMpnGtin(this Product product, IList <CustomAttribute> attributes, IProductAttributeParser productAttributeParser,
                                          out string sku, out string manufacturerPartNumber, out string gtin)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            sku = null;
            manufacturerPartNumber = null;
            gtin = null;

            if (attributes != null &&
                product.ManageInventoryMethod == ManageInventoryMethod.ManageStockByAttributes)
            {
                //manage stock by attribute combinations
                if (productAttributeParser == null)
                {
                    throw new ArgumentNullException("productAttributeParser");
                }

                //let's find appropriate record
                var combination = productAttributeParser.FindProductAttributeCombination(product, attributes);
                if (combination != null)
                {
                    sku = combination.Sku;
                    manufacturerPartNumber = combination.ManufacturerPartNumber;
                    gtin = combination.Gtin;
                }
            }

            if (string.IsNullOrEmpty(sku))
            {
                sku = product.Sku;
            }
            if (string.IsNullOrEmpty(manufacturerPartNumber))
            {
                manufacturerPartNumber = product.ManufacturerPartNumber;
            }
            if (string.IsNullOrEmpty(gtin))
            {
                gtin = product.Gtin;
            }
        }
Beispiel #44
0
 public ProductController(
     ICommonServices services,
     IManufacturerService manufacturerService,
     IProductService productService,
     IProductAttributeService productAttributeService,
     IProductAttributeParser productAttributeParser,
     ITaxService taxService,
     ICurrencyService currencyService,
     IPictureService pictureService,
     IPriceCalculationService priceCalculationService,
     IPriceFormatter priceFormatter,
     ICustomerContentService customerContentService,
     ICustomerService customerService,
     IShoppingCartService shoppingCartService,
     IRecentlyViewedProductsService recentlyViewedProductsService,
     IWorkflowMessageService workflowMessageService,
     IProductTagService productTagService,
     IOrderReportService orderReportService,
     IBackInStockSubscriptionService backInStockSubscriptionService,
     IAclService aclService,
     IStoreMappingService storeMappingService,
     MediaSettings mediaSettings,
     SeoSettings seoSettings,
     CatalogSettings catalogSettings,
     ShoppingCartSettings shoppingCartSettings,
     LocalizationSettings localizationSettings,
     CaptchaSettings captchaSettings,
     CatalogHelper helper,
     IDownloadService downloadService,
     ILocalizationService localizationService,
     IBreadcrumb breadcrumb)
 {
     _services                       = services;
     _manufacturerService            = manufacturerService;
     _productService                 = productService;
     _productAttributeService        = productAttributeService;
     _productAttributeParser         = productAttributeParser;
     _taxService                     = taxService;
     _currencyService                = currencyService;
     _pictureService                 = pictureService;
     _priceCalculationService        = priceCalculationService;
     _priceFormatter                 = priceFormatter;
     _customerContentService         = customerContentService;
     _customerService                = customerService;
     _shoppingCartService            = shoppingCartService;
     _recentlyViewedProductsService  = recentlyViewedProductsService;
     _workflowMessageService         = workflowMessageService;
     _productTagService              = productTagService;
     _orderReportService             = orderReportService;
     _backInStockSubscriptionService = backInStockSubscriptionService;
     _aclService                     = aclService;
     _storeMappingService            = storeMappingService;
     _mediaSettings                  = mediaSettings;
     _seoSettings                    = seoSettings;
     _catalogSettings                = catalogSettings;
     _shoppingCartSettings           = shoppingCartSettings;
     _localizationSettings           = localizationSettings;
     _captchaSettings                = captchaSettings;
     _helper              = helper;
     _downloadService     = downloadService;
     _localizationService = localizationService;
     _breadcrumb          = breadcrumb;
 }
Beispiel #45
0
        public CommodityModelFactory(CatalogSettings catalogSettings,
                                     CurrencySettings currencySettings,
                                     IAclSupportedModelFactory aclSupportedModelFactory,
                                     IBaseAdminModelFactory baseAdminModelFactory,
                                     ICategoryService categoryService,
                                     ICurrencyService currencyService,
                                     ICustomerService customerService,
                                     IDateTimeHelper dateTimeHelper,
                                     IDiscountService discountService,
                                     IDiscountSupportedModelFactory discountSupportedModelFactory,
                                     ILocalizationService localizationService,
                                     ILocalizedModelFactory localizedModelFactory,
                                     IManufacturerService manufacturerService,
                                     IMeasureService measureService,
                                     IOrderService orderService,
                                     IPictureService pictureService,
                                     IProductAttributeFormatter productAttributeFormatter,
                                     IProductAttributeParser productAttributeParser,
                                     IProductAttributeService productAttributeService,
                                     IProductService productService,
                                     IProductTagService productTagService,
                                     IProductTemplateService productTemplateService,
                                     ISettingModelFactory settingModelFactory,
                                     IShipmentService shipmentService,
                                     IShippingService shippingService,
                                     IShoppingCartService shoppingCartService,
                                     ISpecificationAttributeService specificationAttributeService,
                                     IStaticCacheManager cacheManager,
                                     IStoreMappingSupportedModelFactory storeMappingSupportedModelFactory,
                                     IStoreService storeService,
                                     IUrlRecordService urlRecordService,
                                     IWorkContext workContext,
                                     MeasureSettings measureSettings,
                                     TaxSettings taxSettings,
                                     VendorSettings vendorSettings,

                                     ICommodityService commodityService
                                     )
        {
            _catalogSettings                   = catalogSettings;
            _currencySettings                  = currencySettings;
            _aclSupportedModelFactory          = aclSupportedModelFactory;
            _baseAdminModelFactory             = baseAdminModelFactory;
            _cacheManager                      = cacheManager;
            _categoryService                   = categoryService;
            _currencyService                   = currencyService;
            _customerService                   = customerService;
            _dateTimeHelper                    = dateTimeHelper;
            _discountService                   = discountService;
            _discountSupportedModelFactory     = discountSupportedModelFactory;
            _localizationService               = localizationService;
            _localizedModelFactory             = localizedModelFactory;
            _manufacturerService               = manufacturerService;
            _measureService                    = measureService;
            _measureSettings                   = measureSettings;
            _orderService                      = orderService;
            _pictureService                    = pictureService;
            _productAttributeFormatter         = productAttributeFormatter;
            _productAttributeParser            = productAttributeParser;
            _productAttributeService           = productAttributeService;
            _productService                    = productService;
            _productTagService                 = productTagService;
            _productTemplateService            = productTemplateService;
            _settingModelFactory               = settingModelFactory;
            _shipmentService                   = shipmentService;
            _shippingService                   = shippingService;
            _shoppingCartService               = shoppingCartService;
            _specificationAttributeService     = specificationAttributeService;
            _storeMappingSupportedModelFactory = storeMappingSupportedModelFactory;
            _storeService                      = storeService;
            _urlRecordService                  = urlRecordService;
            _workContext    = workContext;
            _taxSettings    = taxSettings;
            _vendorSettings = vendorSettings;

            _commodityService = commodityService;
        }
Beispiel #46
0
        public new void SetUp()
        {
            #region Test data

            //color (dropdownlist)
            pa1 = new ProductAttribute
            {
                Id   = 1,
                Name = "Color"
            };
            pam1_1 = new ProductAttributeMapping
            {
                Id                   = 11,
                ProductId            = 1,
                TextPrompt           = "Select color:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.DropdownList,
                DisplayOrder         = 1,
                ProductAttributeId   = pa1.Id
            };
            pav1_1 = new ProductAttributeValue
            {
                Id           = 11,
                Name         = "Green",
                DisplayOrder = 1,
                ProductAttributeMappingId = pam1_1.Id
            };
            pav1_2 = new ProductAttributeValue
            {
                Id           = 12,
                Name         = "Red",
                DisplayOrder = 2,
                ProductAttributeMappingId = pam1_1.Id
            };

            //custom option (checkboxes)
            pa2 = new ProductAttribute
            {
                Id   = 2,
                Name = "Some custom option"
            };
            pam2_1 = new ProductAttributeMapping
            {
                Id                   = 21,
                ProductId            = 1,
                TextPrompt           = "Select at least one option:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.Checkboxes,
                DisplayOrder         = 2,
                ProductAttributeId   = pa2.Id
            };
            pav2_1 = new ProductAttributeValue
            {
                Id           = 21,
                Name         = "Option 1",
                DisplayOrder = 1,
                ProductAttributeMappingId = pam2_1.Id
            };
            pav2_2 = new ProductAttributeValue
            {
                Id           = 22,
                Name         = "Option 2",
                DisplayOrder = 2,
                ProductAttributeMappingId = pam2_1.Id
            };

            //custom text
            pa3 = new ProductAttribute
            {
                Id   = 3,
                Name = "Custom text"
            };
            pam3_1 = new ProductAttributeMapping
            {
                Id                   = 31,
                ProductId            = 1,
                TextPrompt           = "Enter custom text:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.TextBox,
                DisplayOrder         = 1,
                ProductAttributeId   = pa3.Id
            };

            //option radio
            pa4 = new ProductAttribute
            {
                Id   = 4,
                Name = "Radio list"
            };
            pam4_1 = new ProductAttributeMapping
            {
                Id                   = 41,
                ProductId            = 1,
                TextPrompt           = "Select option and enter the quantity:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.RadioList,
                DisplayOrder         = 2,
                ProductAttributeId   = pa4.Id
            };
            pav4_1 = new ProductAttributeValue
            {
                Id           = 41,
                Name         = "Option with quantity",
                DisplayOrder = 1,
                ProductAttributeMappingId = pam4_1.Id
            };

            #endregion

            _productAttributeRepo = new Mock <IRepository <ProductAttribute> >();
            _productAttributeRepo.Setup(x => x.Table).Returns(new List <ProductAttribute> {
                pa1, pa2, pa3, pa4
            }.AsQueryable());
            _productAttributeRepo.Setup(x => x.GetById(pa1.Id)).Returns(pa1);
            _productAttributeRepo.Setup(x => x.GetById(pa2.Id)).Returns(pa2);
            _productAttributeRepo.Setup(x => x.GetById(pa3.Id)).Returns(pa3);
            _productAttributeRepo.Setup(x => x.GetById(pa4.Id)).Returns(pa4);

            _productAttributeMappingRepo = new Mock <IRepository <ProductAttributeMapping> >();
            _productAttributeMappingRepo.Setup(x => x.Table).Returns(new List <ProductAttributeMapping> {
                pam1_1, pam2_1, pam3_1, pam4_1
            }.AsQueryable());
            _productAttributeMappingRepo.Setup(x => x.GetById(pam1_1.Id)).Returns(pam1_1);
            _productAttributeMappingRepo.Setup(x => x.GetById(pam2_1.Id)).Returns(pam2_1);
            _productAttributeMappingRepo.Setup(x => x.GetById(pam3_1.Id)).Returns(pam3_1);
            _productAttributeMappingRepo.Setup(x => x.GetById(pam4_1.Id)).Returns(pam4_1);

            _productAttributeCombinationRepo = new Mock <IRepository <ProductAttributeCombination> >();
            _productAttributeCombinationRepo.Setup(x => x.Table).Returns(new List <ProductAttributeCombination>().AsQueryable());

            _productAttributeValueRepo = new Mock <IRepository <ProductAttributeValue> >();
            _productAttributeValueRepo.Setup(x => x.Table).Returns(new List <ProductAttributeValue> {
                pav1_1, pav1_2, pav2_1, pav2_2, pav4_1
            }.AsQueryable());
            _productAttributeValueRepo.Setup(x => x.GetById(pav1_1.Id)).Returns(pav1_1);
            _productAttributeValueRepo.Setup(x => x.GetById(pav1_2.Id)).Returns(pav1_2);
            _productAttributeValueRepo.Setup(x => x.GetById(pav2_1.Id)).Returns(pav2_1);
            _productAttributeValueRepo.Setup(x => x.GetById(pav2_2.Id)).Returns(pav2_2);
            _productAttributeValueRepo.Setup(x => x.GetById(pav4_1.Id)).Returns(pav4_1);

            _predefinedProductAttributeValueRepo = new Mock <IRepository <PredefinedProductAttributeValue> >();

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            _productAttributeService = new ProductAttributeService(_eventPublisher.Object,
                                                                   _predefinedProductAttributeValueRepo.Object,
                                                                   _productAttributeRepo.Object,
                                                                   _productAttributeCombinationRepo.Object,
                                                                   _productAttributeMappingRepo.Object,
                                                                   _productAttributeValueRepo.Object);

            _dataProvider = new Mock <IDataProvider>();

            _productAttributeParser = new ProductAttributeParser(_dataProvider.Object, _productAttributeService);

            _priceCalculationService = new Mock <IPriceCalculationService>();

            var workingLanguage = new Language();
            _workContext = new Mock <IWorkContext>();
            _workContext.Setup(x => x.WorkingLanguage).Returns(workingLanguage);
            _currencyService     = new Mock <ICurrencyService>();
            _localizationService = TestLocalizationService.Init();

            _taxService           = new Mock <ITaxService>();
            _priceFormatter       = new Mock <IPriceFormatter>();
            _downloadService      = new Mock <IDownloadService>();
            _webHelper            = new Mock <IWebHelper>();
            _shoppingCartSettings = new ShoppingCartSettings();

            _productAttributeFormatter = new ProductAttributeFormatter(_currencyService.Object,
                                                                       _downloadService.Object,
                                                                       _localizationService,
                                                                       _priceCalculationService.Object,
                                                                       _priceFormatter.Object,
                                                                       _productAttributeParser,
                                                                       _productAttributeService,
                                                                       _taxService.Object,
                                                                       _webHelper.Object,
                                                                       _workContext.Object,
                                                                       _shoppingCartSettings);
        }
Beispiel #47
0
 /// <summary>
 /// Indicates whether the shopping cart requires shipping
 /// </summary>
 /// <param name="shoppingCart">Shopping cart</param>
 /// <param name="productService">Product service</param>
 /// <param name="productAttributeParser">Product attribute parser</param>
 /// <returns>True if the shopping cart requires shipping; otherwise, false.</returns>
 public static bool RequiresShipping(this IList <ShoppingCartItem> shoppingCart,
                                     IProductService productService = null, IProductAttributeParser productAttributeParser = null)
 {
     return(shoppingCart.Any(shoppingCartItem => shoppingCartItem.IsShipEnabled(productService, productAttributeParser)));
 }
Beispiel #48
0
        /// <summary>
        /// Formats the stock availability/quantity message
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Selected product attributes in XML format (if specified)</param>
        /// <param name="localizationService">Localization service</param>
        /// <param name="productAttributeParser">Product attribute parser</param>
        /// <param name="dateRangeService">Date range service</param>
        /// <param name="productAttributeService">Product attribute service</param>
        /// <returns>The stock message</returns>
        public static string FormatStockMessage(this Product product, string attributesXml,
                                                ILocalizationService localizationService, IProductAttributeParser productAttributeParser, IDateRangeService dateRangeService, IProductAttributeService productAttributeService)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            if (localizationService == null)
            {
                throw new ArgumentNullException(nameof(localizationService));
            }

            if (productAttributeParser == null)
            {
                throw new ArgumentNullException(nameof(productAttributeParser));
            }

            if (dateRangeService == null)
            {
                throw new ArgumentNullException(nameof(dateRangeService));
            }

            var stockMessage = string.Empty;

            switch (product.ManageInventoryMethod)
            {
            case ManageInventoryMethod.ManageStock:
                stockMessage = GetStockMessage(product, localizationService, dateRangeService, stockMessage);
                break;

            case ManageInventoryMethod.ManageStockByAttributes:
                stockMessage = GeStockMessage(product, attributesXml, localizationService, productAttributeParser, dateRangeService, productAttributeService);
                break;
            }

            return(stockMessage);
        }
        /// <summary>
        /// Get product picture (for shopping cart and order details pages)
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributes">Atributes </param>
        /// <param name="pictureService">Picture service</param>
        /// <param name="productAttributeParser">Product attribute service</param>
        /// <returns>Picture</returns>
        public static async Task <Picture> GetProductPicture(this Product product, IList <CustomAttribute> attributes,
                                                             IProductService productService, IPictureService pictureService,
                                                             IProductAttributeParser productAttributeParser)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }
            if (pictureService == null)
            {
                throw new ArgumentNullException(nameof(pictureService));
            }
            if (productAttributeParser == null)
            {
                throw new ArgumentNullException(nameof(productAttributeParser));
            }

            Picture picture = null;

            if (attributes != null && attributes.Any())
            {
                var comb = productAttributeParser.FindProductAttributeCombination(product, attributes);
                if (comb != null)
                {
                    if (!string.IsNullOrEmpty(comb.PictureId))
                    {
                        var combPicture = await pictureService.GetPictureById(comb.PictureId);

                        if (combPicture != null)
                        {
                            picture = combPicture;
                        }
                    }
                }
                if (picture == null)
                {
                    var attributeValues = productAttributeParser.ParseProductAttributeValues(product, attributes);
                    foreach (var attributeValue in attributeValues)
                    {
                        var attributePicture = await pictureService.GetPictureById(attributeValue.PictureId);

                        if (attributePicture != null)
                        {
                            picture = attributePicture;
                            break;
                        }
                    }
                }
            }
            if (picture == null)
            {
                var pp = product.ProductPictures.OrderBy(x => x.DisplayOrder).FirstOrDefault();
                if (pp != null)
                {
                    picture = await pictureService.GetPictureById(pp.PictureId);
                }
            }

            if (picture == null && !product.VisibleIndividually && !string.IsNullOrEmpty(product.ParentGroupedProductId))
            {
                var parentProduct = await productService.GetProductById(product.ParentGroupedProductId);

                if (parentProduct != null)
                {
                    if (parentProduct.ProductPictures.Any())
                    {
                        picture = await pictureService.GetPictureById(parentProduct.ProductPictures.FirstOrDefault().PictureId);
                    }
                }
            }

            return(picture);
        }
Beispiel #50
0
        public new void SetUp()
        {
            #region Test data

            //color (dropdownlist)
            pa1 = new ProductAttribute
            {
                Id   = 1,
                Name = "Color",
            };
            pva1_1 = new ProductVariantAttribute
            {
                Id                   = 11,
                ProductId            = 1,
                TextPrompt           = "Select color:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.DropdownList,
                DisplayOrder         = 1,
                ProductAttribute     = pa1,
                ProductAttributeId   = pa1.Id
            };
            pvav1_1 = new ProductVariantAttributeValue
            {
                Id                        = 11,
                Name                      = "Green",
                DisplayOrder              = 1,
                ProductVariantAttribute   = pva1_1,
                ProductVariantAttributeId = pva1_1.Id
            };
            pvav1_2 = new ProductVariantAttributeValue
            {
                Id                        = 12,
                Name                      = "Red",
                DisplayOrder              = 2,
                ProductVariantAttribute   = pva1_1,
                ProductVariantAttributeId = pva1_1.Id
            };
            pva1_1.ProductVariantAttributeValues.Add(pvav1_1);
            pva1_1.ProductVariantAttributeValues.Add(pvav1_2);

            //custom option (checkboxes)
            pa2 = new ProductAttribute
            {
                Id   = 2,
                Name = "Some custom option",
            };
            pva2_1 = new ProductVariantAttribute
            {
                Id                   = 21,
                ProductId            = 1,
                TextPrompt           = "Select at least one option:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.Checkboxes,
                DisplayOrder         = 2,
                ProductAttribute     = pa2,
                ProductAttributeId   = pa2.Id
            };
            pvav2_1 = new ProductVariantAttributeValue
            {
                Id                        = 21,
                Name                      = "Option 1",
                DisplayOrder              = 1,
                ProductVariantAttribute   = pva2_1,
                ProductVariantAttributeId = pva2_1.Id
            };
            pvav2_2 = new ProductVariantAttributeValue
            {
                Id                        = 22,
                Name                      = "Option 2",
                DisplayOrder              = 2,
                ProductVariantAttribute   = pva2_1,
                ProductVariantAttributeId = pva2_1.Id
            };
            pva2_1.ProductVariantAttributeValues.Add(pvav2_1);
            pva2_1.ProductVariantAttributeValues.Add(pvav2_2);

            //custom text
            pa3 = new ProductAttribute
            {
                Id   = 3,
                Name = "Custom text",
            };
            pva3_1 = new ProductVariantAttribute
            {
                Id                   = 31,
                ProductId            = 1,
                TextPrompt           = "Enter custom text:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.TextBox,
                DisplayOrder         = 1,
                ProductAttribute     = pa1,
                ProductAttributeId   = pa3.Id
            };


            #endregion

            _productAttributeRepo = MockRepository.GenerateMock <IRepository <ProductAttribute> >();
            _productAttributeRepo.Expect(x => x.Table).Return(new List <ProductAttribute> {
                pa1, pa2, pa3
            }.AsQueryable());
            _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1);
            _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2);
            _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3);

            _productAttributeOptionRepo     = MockRepository.GenerateMock <IRepository <ProductAttributeOption> >();
            _productAttributeOptionsSetRepo = MockRepository.GenerateMock <IRepository <ProductAttributeOptionsSet> >();

            _productVariantAttributeRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttribute> >();
            _productVariantAttributeRepo.Expect(x => x.Table).Return(new List <ProductVariantAttribute> {
                pva1_1, pva2_1, pva3_1
            }.AsQueryable());
            _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1);
            _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1);
            _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1);

            _productVariantAttributeCombinationRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeCombination> >();
            _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeCombination>().AsQueryable());

            _productVariantAttributeValueRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeValue> >();
            _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeValue> {
                pvav1_1, pvav1_2, pvav2_1, pvav2_2
            }.AsQueryable());
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1);
            _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2);

            _productBundleItemAttributeFilter = MockRepository.GenerateMock <IRepository <ProductBundleItemAttributeFilter> >();
            _localizedEntityService           = MockRepository.GenerateMock <ILocalizedEntityService>();

            var cacheManager = new NullCache();

            _productAttributeService = new ProductAttributeService(
                NullRequestCache.Instance,
                _productAttributeRepo,
                _productAttributeOptionRepo,
                _productAttributeOptionsSetRepo,
                _productVariantAttributeRepo,
                _productVariantAttributeCombinationRepo,
                _productVariantAttributeValueRepo,
                _productBundleItemAttributeFilter,
                _localizedEntityService);

            _productAttributeParser = new ProductAttributeParser(_productAttributeService, new MemoryRepository <ProductVariantAttributeCombination>(), NullRequestCache.Instance);



            var workingLanguage = new Language();
            _workContext = MockRepository.GenerateMock <IWorkContext>();
            _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage);
            _currencyService     = MockRepository.GenerateMock <ICurrencyService>();
            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}");
            _taxService              = MockRepository.GenerateMock <ITaxService>();
            _priceFormatter          = MockRepository.GenerateMock <IPriceFormatter>();
            _downloadService         = MockRepository.GenerateMock <IDownloadService>();
            _webHelper               = MockRepository.GenerateMock <IWebHelper>();
            _priceCalculationService = MockRepository.GenerateMock <IPriceCalculationService>();
            _shoppingCartSettings    = MockRepository.GenerateMock <ShoppingCartSettings>();
            _catalogSettings         = MockRepository.GenerateMock <CatalogSettings>();

            _productAttributeFormatter = new ProductAttributeFormatter(_workContext,
                                                                       _productAttributeService,
                                                                       _productAttributeParser,
                                                                       _priceCalculationService,
                                                                       _currencyService,
                                                                       _localizationService,
                                                                       _taxService,
                                                                       _priceFormatter,
                                                                       _downloadService,
                                                                       _webHelper,
                                                                       _shoppingCartSettings,
                                                                       _catalogSettings);
        }
Beispiel #51
0
        /// <summary>
        /// Formats GTIN
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="attributesXml">Attributes in XML format</param>
        /// <param name="productAttributeParser">Product attribute service (used when attributes are specified)</param>
        /// <returns>GTIN</returns>
        public static string FormatGtin(this Product product, string attributesXml = null, IProductAttributeParser productAttributeParser = null)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            product.GetSkuMpnGtin(attributesXml, productAttributeParser, out string _, out string _, out string gtin);

            return(gtin);
        }
        public void TestInitialize()
        {
            _productRepo = new MongoDBRepositoryTest <Product>();
            //dropdown list: adding 2 options "atributes" that can be selected via DropDownList
            pa1 = new ProductAttribute {
                Id   = "1",
                Name = "Color"
            };
            pam1_1 = new ProductAttributeMapping {
                Id                   = "11",
                ProductId            = "1",
                TextPrompt           = "Select color:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.DropdownList,
                DisplayOrder         = 1,
                ProductAttributeId   = pa1.Id
            };
            pav1_1 = new ProductAttributeValue {
                Id           = "11",
                Name         = "Green",
                DisplayOrder = 1,
                ProductAttributeMappingId = pam1_1.Id
            };
            pav1_2 = new ProductAttributeValue {
                Id           = "12",
                Name         = "Red",
                DisplayOrder = 2,
                ProductAttributeMappingId = pam1_1.Id
            };
            //adding colors (as product atributes)
            pam1_1.ProductAttributeValues.Add(pav1_1);
            pam1_1.ProductAttributeValues.Add(pav1_2);

            //checkboxes - adding 2 options that can be ticked via CheckBox'es
            pa2 = new ProductAttribute {
                Id   = "2",
                Name = "Some custom option",
            };
            pam2_1 = new ProductAttributeMapping {
                Id                   = "21",
                ProductId            = "1",
                TextPrompt           = "Select at least one option:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.Checkboxes,
                DisplayOrder         = 2,
                ProductAttributeId   = pa2.Id
            };
            pav2_1 = new ProductAttributeValue {
                Id           = "21",
                Name         = "Option 1",
                DisplayOrder = 1,
                ProductAttributeMappingId = pam2_1.Id
            };
            pav2_2 = new ProductAttributeValue {
                Id           = "22",
                Name         = "Option 2",
                DisplayOrder = 2,
                ProductAttributeMappingId = pam2_1.Id
            };
            pam2_1.ProductAttributeValues.Add(pav2_1);
            pam2_1.ProductAttributeValues.Add(pav2_2);

            //adds custom text (user can add its own text)
            pa3 = new ProductAttribute {
                Id   = "3",
                Name = "Custom text",
            };
            pam3_1 = new ProductAttributeMapping {
                Id                   = "31",
                ProductId            = "1",
                TextPrompt           = "Enter custom text:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.TextBox,
                DisplayOrder         = 1,
                ProductAttributeId   = pa3.Id
            };

            _product = new Product();
            _product.ProductAttributeMappings.Add(pam1_1);
            _product.ProductAttributeMappings.Add(pam2_1);
            _product.ProductAttributeMappings.Add(pam3_1);
            _productRepo.Insert(_product); //26 april

            var tempEventPublisher = new Mock <IMediator>();
            {
                //tempEventPublisher.Setup(x => x.Publish(It.IsAny<object>()));
                _eventPublisher = tempEventPublisher.Object;
            }

            var cacheManager = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object);

            _productAttributeRepo = new Mock <IRepository <ProductAttribute> >().Object;

            _productAttributeService = new ProductAttributeService(cacheManager,
                                                                   _productAttributeRepo,
                                                                   _productRepo,
                                                                   _eventPublisher);
            _productAttributeParser  = new ProductAttributeParser();
            _priceCalculationService = new Mock <IPriceCalculationService>().Object;

            var tempWorkContext = new Mock <IWorkContext>();

            {
                var workingLanguage = new Language();
                tempWorkContext.Setup(x => x.WorkingLanguage).Returns(workingLanguage);
                _workContext = tempWorkContext.Object;
            }
            _currencyService = new Mock <ICurrencyService>().Object;
            var tempLocalizationService = new Mock <ILocalizationService>();

            {
                tempLocalizationService.Setup(x => x.GetResource("GiftCardAttribute.For.Virtual")).Returns("For: {0} <{1}>");
                tempLocalizationService.Setup(x => x.GetResource("GiftCardAttribute.From.Virtual")).Returns("From: {0} <{1}>");
                tempLocalizationService.Setup(x => x.GetResource("GiftCardAttribute.For.Physical")).Returns("For: {0}");
                tempLocalizationService.Setup(x => x.GetResource("GiftCardAttribute.From.Physical")).Returns("From: {0}");
                _localizationService = tempLocalizationService.Object;
            }

            _taxService           = new Mock <ITaxService>().Object;
            _priceFormatter       = new Mock <IPriceFormatter>().Object;
            _downloadService      = new Mock <IDownloadService>().Object;
            _webHelper            = new Mock <IWebHelper>().Object;
            _shoppingCartSettings = new Mock <ShoppingCartSettings>().Object;

            _productAttributeFormatter = new ProductAttributeFormatter(_workContext,
                                                                       _productAttributeService,
                                                                       _productAttributeParser,
                                                                       _currencyService,
                                                                       _localizationService,
                                                                       _taxService,
                                                                       _priceFormatter,
                                                                       _downloadService,
                                                                       _webHelper,
                                                                       _priceCalculationService,
                                                                       _shoppingCartSettings);
        }
Beispiel #53
0
        private static string GeStockMessage(Product product, string attributesXml, ILocalizationService localizationService, IProductAttributeParser productAttributeParser, IDateRangeService dateRangeService, IProductAttributeService productAttributeService)
        {
            if (!product.DisplayStockAvailability)
            {
                return(string.Empty);
            }

            string stockMessage;

            var combination = productAttributeParser.FindProductAttributeCombination(product, attributesXml);

            if (combination != null)
            {
                //combination exists
                var stockQuantity = combination.StockQuantity;
                if (stockQuantity > 0)
                {
                    stockMessage = product.DisplayStockQuantity
                        ?
                                   //display "in stock" with stock quantity
                                   string.Format(localizationService.GetResource("Products.Availability.InStockWithQuantity"),
                                                 stockQuantity)
                        :
                                   //display "in stock" without stock quantity
                                   localizationService.GetResource("Products.Availability.InStock");
                }
                else if (combination.AllowOutOfStockOrders)
                {
                    stockMessage = localizationService.GetResource("Products.Availability.InStock");
                }
                else
                {
                    var productAvailabilityRange =
                        dateRangeService.GetProductAvailabilityRangeById(product.ProductAvailabilityRangeId);
                    stockMessage = productAvailabilityRange == null
                        ? localizationService.GetResource("Products.Availability.OutOfStock")
                        : string.Format(localizationService.GetResource("Products.Availability.AvailabilityRange"),
                                        productAvailabilityRange.GetLocalized(range => range.Name));
                }
            }
            else
            {
                //no combination configured
                if (product.AllowAddingOnlyExistingAttributeCombinations)
                {
                    var productAvailabilityRange =
                        dateRangeService.GetProductAvailabilityRangeById(product.ProductAvailabilityRangeId);
                    stockMessage = productAvailabilityRange == null
                        ? localizationService.GetResource("Products.Availability.OutOfStock")
                        : string.Format(localizationService.GetResource("Products.Availability.AvailabilityRange"),
                                        productAvailabilityRange.GetLocalized(range => range.Name));
                }
                else
                {
                    stockMessage = !productAttributeService.GetProductAttributeMappingsByProductId(product.Id)
                                   .Any(pam => pam.IsRequired) ? localizationService.GetResource("Products.Availability.InStock") : localizationService.GetResource("Products.Availability.SelectRequiredAttributes");
                }
            }
            return(stockMessage);
        }
Beispiel #54
0
 public GetShoppingCartHandler(
     ICacheManager cacheManager,
     IPaymentService paymentService,
     IProductService productService,
     IPictureService pictureService,
     IProductAttributeParser productAttributeParser,
     ILocalizationService localizationService,
     ICheckoutAttributeFormatter checkoutAttributeFormatter,
     IOrderProcessingService orderProcessingService,
     ICurrencyService currencyService,
     IDiscountService discountService,
     IShoppingCartService shoppingCartService,
     ICheckoutAttributeService checkoutAttributeService,
     IPermissionService permissionService,
     ITaxService taxService,
     IPriceFormatter priceFormatter,
     ICheckoutAttributeParser checkoutAttributeParser,
     IDownloadService downloadService,
     ICountryService countryService,
     IShippingService shippingService,
     IProductAttributeFormatter productAttributeFormatter,
     IPriceCalculationService priceCalculationService,
     IDateTimeHelper dateTimeHelper,
     IVendorService vendorService,
     IMediator mediator,
     MediaSettings mediaSettings,
     OrderSettings orderSettings,
     ShoppingCartSettings shoppingCartSettings,
     CatalogSettings catalogSettings,
     ShippingSettings shippingSettings,
     CommonSettings commonSettings)
 {
     _cacheManager               = cacheManager;
     _paymentService             = paymentService;
     _productService             = productService;
     _pictureService             = pictureService;
     _productAttributeParser     = productAttributeParser;
     _localizationService        = localizationService;
     _checkoutAttributeFormatter = checkoutAttributeFormatter;
     _orderProcessingService     = orderProcessingService;
     _currencyService            = currencyService;
     _discountService            = discountService;
     _shoppingCartService        = shoppingCartService;
     _checkoutAttributeService   = checkoutAttributeService;
     _permissionService          = permissionService;
     _taxService                = taxService;
     _priceFormatter            = priceFormatter;
     _checkoutAttributeParser   = checkoutAttributeParser;
     _downloadService           = downloadService;
     _countryService            = countryService;
     _shippingService           = shippingService;
     _productAttributeFormatter = productAttributeFormatter;
     _priceCalculationService   = priceCalculationService;
     _dateTimeHelper            = dateTimeHelper;
     _vendorService             = vendorService;
     _mediator             = mediator;
     _mediaSettings        = mediaSettings;
     _orderSettings        = orderSettings;
     _shoppingCartSettings = shoppingCartSettings;
     _catalogSettings      = catalogSettings;
     _shippingSettings     = shippingSettings;
     _commonSettings       = commonSettings;
 }
Beispiel #55
0
 public CategoryImageViewComponent(
     SpecificationAttributesSettings specificationAttributesSettings,
     ICustomerService customerService,
     ILanguageService languageService,
     ISettingService settingService,
     IStoreService storeService,
     IWorkContext workContext,
     ILocalizationService localizationService,
     IGenericAttributeService genericAttributeService,
     IVendorService vendorService,
     IProductService productService,
     IStoreContext storeContext,
     ISpecificationAttributeService specificationAttributeService,
     IWebHelper webHelper,
     IPriceFormatter priceFormatter,
     ICurrencyService currencyService,
     CatalogSettings catalogSettings,
     ICategoryService categoryService,
     ICacheManager cacheManager,
     MediaSettings mediaSettings,
     IPriceCalculationService priceCalculationService,
     IPermissionService permissionService,
     ITaxService taxService,
     IPictureService pictureService,
     IMeasureService measureService,
     IUrlRecordService urlRecordService,
     IProductModelFactory productModelFactory,
     IOrderService orderService,
     OrderSettings orderSettings,
     IOrderProcessingService orderProcessingService,
     IProductAttributeParser productAttributeParser,
     ILogger logger,
     ShoppingCartSettings shoppingCartSettings,
     IShoppingCartModelFactory shoppingCartModelFactory)
 {
     _specificationAttributesSettings = specificationAttributesSettings;
     _customerService               = customerService;
     _languageService               = languageService;
     _settingService                = settingService;
     _storeService                  = storeService;
     _localizationService           = localizationService;
     _workContext                   = workContext;
     _genericAttributeService       = genericAttributeService;
     _vendorService                 = vendorService;
     _productService                = productService;
     _storeContext                  = storeContext;
     _specificationAttributeService = specificationAttributeService;
     _webHelper               = webHelper;
     _priceFormatter          = priceFormatter;
     _currencyService         = currencyService;
     _catalogSettings         = catalogSettings;
     _categoryService         = categoryService;
     _cacheManager            = cacheManager;
     _mediaSettings           = mediaSettings;
     _priceCalculationService = priceCalculationService;
     _permissionService       = permissionService;
     _taxService              = taxService;
     _pictureService          = pictureService;
     _measureService          = measureService;
     _urlRecordService        = urlRecordService;
     _productModelFactory     = productModelFactory;
     _orderSettings           = orderSettings;
     _orderProcessingService  = orderProcessingService;
     _orderService            = orderService;
     _productAttributeParser  = productAttributeParser;
     _logger = logger;
     this._shoppingCartSettings     = shoppingCartSettings;
     this._shoppingCartModelFactory = shoppingCartModelFactory;
 }
 public CustomTokenProvider(
     ILanguageService languageService,
     ILocalizationService localizationService,
     IDateTimeHelper dateTimeHelper,
     IPriceFormatter priceFormatter,
     ICurrencyService currencyService,
     IWorkContext workContext,
     IDownloadService downloadService,
     IOrderService orderService,
     IPaymentService paymentService,
     IStoreService storeService,
     IStoreContext storeContext,
     IProductAttributeParser productAttributeParser,
     IAddressAttributeFormatter addressAttributeFormatter,
     ICustomerAttributeFormatter customerAttributeFormatter,
     IUrlHelperFactory urlHelperFactory,
     IActionContextAccessor actionContextAccessor,
     MessageTemplatesSettings templatesSettings,
     CatalogSettings catalogSettings,
     TaxSettings taxSettings,
     CurrencySettings currencySettings,
     ShippingSettings shippingSettings,
     PaymentSettings paymentSettings,
     IEventPublisher eventPublisher,
     StoreInformationSettings storeInformationSettings,
     IPluginFinder pluginFinder)
     :
     base(languageService,
          localizationService,
          dateTimeHelper,
          priceFormatter,
          currencyService,
          workContext,
          downloadService,
          orderService,
          paymentService,
          storeService,
          storeContext,
          productAttributeParser,
          addressAttributeFormatter,
          customerAttributeFormatter,
          urlHelperFactory,
          actionContextAccessor,
          templatesSettings,
          catalogSettings,
          taxSettings,
          currencySettings,
          shippingSettings,
          paymentSettings,
          eventPublisher,
          storeInformationSettings)
 {
     this._languageService            = languageService;
     this._localizationService        = localizationService;
     this._dateTimeHelper             = dateTimeHelper;
     this._priceFormatter             = priceFormatter;
     this._currencyService            = currencyService;
     this._workContext                = workContext;
     this._downloadService            = downloadService;
     this._orderService               = orderService;
     this._paymentService             = paymentService;
     this._productAttributeParser     = productAttributeParser;
     this._addressAttributeFormatter  = addressAttributeFormatter;
     this._customerAttributeFormatter = customerAttributeFormatter;
     this._storeService               = storeService;
     this._storeContext               = storeContext;
     this._templatesSettings          = templatesSettings;
     this._catalogSettings            = catalogSettings;
     this._taxSettings                = taxSettings;
     this._currencySettings           = currencySettings;
     this._shippingSettings           = shippingSettings;
     this._paymentSettings            = paymentSettings;
     this._eventPublisher             = eventPublisher;
     this._storeInformationSettings   = storeInformationSettings;
     this._pluginFinder               = pluginFinder;
 }
Beispiel #57
0
        public static ProductVariantAttributeCombination MergeWithCombination(this Product product, string selectedAttributes, IProductAttributeParser productAttributeParser)
        {
            Guard.ArgumentNotNull(productAttributeParser, "productAttributeParser");

            if (selectedAttributes.IsNullOrEmpty())
            {
                return(null);
            }

            // let's find appropriate record
            var combination = product
                              .ProductVariantAttributeCombinations
                              .Where(x => x.IsActive == true)
                              .FirstOrDefault(x => productAttributeParser.AreProductAttributesEqual(x.AttributesXml, selectedAttributes));

            if (combination != null)
            {
                product.MergeWithCombination(combination);
            }

            return(combination);
        }
        public void TestInitialize()
        {
            CommonPath.BaseDirectory = "";

            _store = new Store {
                Id = "1"
            };
            tempWorkContext = new Mock <IWorkContext>();
            {
                tempWorkContext.Setup(instance => instance.WorkingCurrency).Returns(_currency);
                tempWorkContext.Setup(c => c.CurrentStore).Returns(_store);
                _workContext = tempWorkContext.Object;
            }

            tempDiscountServiceMock = new Mock <IDiscountService>();
            {
                _discountService = tempDiscountServiceMock.Object;
            }

            _categoryService   = new Mock <ICategoryService>().Object;
            _collectionService = new Mock <ICollectionService>().Object;
            _brandService      = new Mock <IBrandService>().Object;

            tempProductService = new Mock <IProductService>();
            {
                _productService = tempProductService.Object;
            }
            _productAttributeParser = new Mock <IProductAttributeParser>().Object;
            _shoppingCartSettings   = new ShoppingCartSettings();
            _catalogSettings        = new CatalogSettings();
            var eventPublisher = new Mock <IMediator>();

            _eventPublisher = eventPublisher.Object;

            _currencySettings = new CurrencySettings();
            _currencySettings.PrimaryExchangeRateCurrencyId = "1";
            _currencySettings.PrimaryStoreCurrencyId        = "1";
            //_currencyService = new Mock<ICurrencyService>().Object;
            _currency = new Currency {
                Id = "1", CurrencyCode = "USD", Rate = 1, Published = true, MidpointRoundId = System.MidpointRounding.ToEven, RoundingTypeId = RoundingType.Rounding001
            };

            var tempCurrency = new Mock <ICurrencyService>();
            {
                tempCurrency.Setup(instance => instance.GetPrimaryStoreCurrency()).Returns(Task.FromResult(_currency));
                //tempCurrency.Setup(instance => instance.ConvertToPrimaryStoreCurrency(It.IsAny<double>(), _currency)).ReturnsAsync(5);
                //_currencyService = tempCurrency.Object;
            }
            var cacheManager = new Mock <ICacheBase>().Object;
            IRepository <Currency> _currencyRepository;
            var tempCurrencyRepository = new Mock <IRepository <Currency> >();
            {
                var IMongoCollection = new Mock <MongoRepository <Currency> >().Object;
                IMongoCollection.Insert(_currency);


                tempCurrencyRepository.Setup(x => x.Table).Returns(IMongoCollection.Table);
                tempCurrencyRepository.Setup(x => x.GetByIdAsync(_currency.Id)).ReturnsAsync(_currency);
                _currencyRepository = tempCurrencyRepository.Object;
            }

            IAclService _aclService      = new Mock <IAclService>().Object;
            var         _serviceProvider = new Mock <IServiceProvider>().Object;

            _currencyService = new CurrencyService(
                cacheManager, _currencyRepository, _aclService,
                _currencySettings, _eventPublisher);


            _pricingService = new PricingService(
                _workContext,
                _discountService,
                _categoryService,
                _brandService,
                _collectionService,
                _productAttributeParser,
                _productService,
                _eventPublisher,
                _currencyService,
                _shoppingCartSettings,
                _catalogSettings);
        }
Beispiel #59
0
        public new void SetUp()
        {
            _workContext = null;

            _store = new Store()
            {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings      = new CatalogSettings();

            //price calculation service
            _discountService         = MockRepository.GenerateMock <IDiscountService>();
            _categoryService         = MockRepository.GenerateMock <ICategoryService>();
            _manufacturerService     = MockRepository.GenerateMock <IManufacturerService>();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _productAttributeService = MockRepository.GenerateMock <IProductAttributeService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();
            _eventPublisher          = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _settingService      = MockRepository.GenerateMock <ISettingService>();
            _typeFinder          = MockRepository.GenerateMock <ITypeFinder>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _logger = new NullLogger();

            _shippingService = new ShippingService(
                _shippingMethodRepository,
                _productAttributeParser,
                _productService,
                _checkoutAttributeParser,
                _genericAttributeService,
                _shippingSettings,
                _eventPublisher,
                _shoppingCartSettings,
                _settingService,
                this.ProviderManager,
                _typeFinder);

            _shipmentService = MockRepository.GenerateMock <IShipmentService>();

            _paymentService          = MockRepository.GenerateMock <IPaymentService>();
            _providerManager         = MockRepository.GenerateMock <IProviderManager>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();
            _giftCardService         = MockRepository.GenerateMock <IGiftCardService>();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;

            _addressService = MockRepository.GenerateMock <IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address()
            {
                Id = _taxSettings.DefaultTaxAddressId
            });
            _downloadService  = MockRepository.GenerateMock <IDownloadService>();
            _services         = MockRepository.GenerateMock <ICommonServices>();
            _httpRequestBase  = MockRepository.GenerateMock <HttpRequestBase>();
            _geoCountryLookup = MockRepository.GenerateMock <IGeoCountryLookup>();

            _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _geoCountryLookup, this.ProviderManager);

            _rewardPointsSettings = new RewardPointsSettings();

            _priceCalcService = new PriceCalculationService(_discountService, _categoryService, _manufacturerService, _productAttributeParser, _productService,
                                                            _shoppingCartSettings, _catalogSettings, _productAttributeService, _downloadService, _services, _httpRequestBase, _taxService);

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                                                                      _priceCalcService, _taxService, _shippingService, _providerManager,
                                                                      _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _productAttributeParser,
                                                                      _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);

            _orderService                  = MockRepository.GenerateMock <IOrderService>();
            _webHelper                     = MockRepository.GenerateMock <IWebHelper>();
            _languageService               = MockRepository.GenerateMock <ILanguageService>();
            _productService                = MockRepository.GenerateMock <IProductService>();
            _priceFormatter                = MockRepository.GenerateMock <IPriceFormatter>();
            _productAttributeFormatter     = MockRepository.GenerateMock <IProductAttributeFormatter>();
            _shoppingCartService           = MockRepository.GenerateMock <IShoppingCartService>();
            _checkoutAttributeFormatter    = MockRepository.GenerateMock <ICheckoutAttributeFormatter>();
            _customerService               = MockRepository.GenerateMock <ICustomerService>();
            _encryptionService             = MockRepository.GenerateMock <IEncryptionService>();
            _workflowMessageService        = MockRepository.GenerateMock <IWorkflowMessageService>();
            _customerActivityService       = MockRepository.GenerateMock <ICustomerActivityService>();
            _currencyService               = MockRepository.GenerateMock <ICurrencyService>();
            _affiliateService              = MockRepository.GenerateMock <IAffiliateService>();
            _newsLetterSubscriptionService = MockRepository.GenerateMock <INewsLetterSubscriptionService>();

            _paymentSettings = new PaymentSettings()
            {
                ActivePaymentMethodSystemNames = new List <string>()
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _currencySettings = new CurrencySettings();

            _orderProcessingService = new OrderProcessingService(_orderService, _webHelper,
                                                                 _localizationService, _languageService,
                                                                 _productService, _paymentService, _logger,
                                                                 _orderTotalCalcService, _priceCalcService, _priceFormatter,
                                                                 _productAttributeParser, _productAttributeFormatter,
                                                                 _giftCardService, _shoppingCartService, _checkoutAttributeFormatter,
                                                                 _shippingService, _shipmentService, _taxService,
                                                                 _customerService, _discountService,
                                                                 _encryptionService, _workContext, _storeContext, _workflowMessageService,
                                                                 _customerActivityService, _currencyService, _affiliateService,
                                                                 _eventPublisher, _genericAttributeService,
                                                                 _newsLetterSubscriptionService,
                                                                 _paymentSettings, _rewardPointsSettings,
                                                                 _orderSettings, _taxSettings, _localizationSettings,
                                                                 _currencySettings, _shoppingCartSettings);
        }
Beispiel #60
0
        public OrderAmazonController(IWorkContext workContext,
            IStoreContext storeContext,
            IStoreService storeService,
            ISettingService settingService,
            ILocalizationService localizationService,
            IPermissionService permissionService,
            IDateTimeHelper dateTimeHelper,

            IOrderService orderService,
            IOrderReportService orderReportService,
            IVendorService vendorService,
            ICacheManager cacheManager,
            IShippingService shippingService,
            IPaymentService paymentService,
            ICountryService countryService,
            IProductService productService,
            IPriceFormatter priceFormatter,
            ICurrencyService currencyService,
            CurrencySettings currencySettings,
            TaxSettings taxSettings,
            IAffiliateService affiliateService,
            IDiscountService discountService,
            IAddressAttributeFormatter addressAttributeFormatter,
            AddressSettings addressSettings,

            IOrderAmazonService orderAmazonService,

            IRepository<OrderItem> orderItemRepository,
            IRepository<OrderAmazon> orderAmazonRepository,
            IRepository<ProductMapping> productMappingRepository,

            IProductAttributeParser productAttributeParser,
        IPluginFinder pluginFinder)
        {
            this._localizationService = localizationService;
            this._settingService = settingService;
            this._storeContext = storeContext;
            this._storeService = storeService;
            this._workContext = workContext;
            this._permissionService = permissionService;
            this._dateTimeHelper = dateTimeHelper;

            this._orderService = orderService;
            this._orderReportService = orderReportService;
            this._orderAmazonService = orderAmazonService;
            this._vendorService = vendorService;
            this._cacheManager = cacheManager;
            this._shippingService = shippingService;
            this._paymentService = paymentService;
            this._countryService = countryService;
            this._productService = productService;
            this._priceFormatter = priceFormatter;
            this._currencyService = currencyService;
            this._currencySettings = currencySettings;

            this._taxSettings = taxSettings;
            this._affiliateService = affiliateService;
            this._discountService = discountService;
            this._addressAttributeFormatter = addressAttributeFormatter;
            this._addressSettings = addressSettings;

            this._orderItemRepository = orderItemRepository;
            this._orderAmazonRepository = orderAmazonRepository;
            this._productMappingRepository = productMappingRepository;

            this._productAttributeParser = productAttributeParser;
        }