Exemple #1
0
        public async Task <IActionResult> ProductTemplates(DataSourceRequest command)
        {
            var templatesModel = (await _productTemplateService.GetAllProductTemplates())
                                 .Select(x => x.ToModel())
                                 .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = templatesModel,
                Total = templatesModel.Count
            };

            return(Json(gridModel));
        }
        /// <summary>
        /// Prepare paged product template list model
        /// </summary>
        /// <param name="searchModel">Product template search model</param>
        /// <returns>Product template list model</returns>
        public virtual ProductTemplateListModel PrepareProductTemplateListModel(ProductTemplateSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get product templates
            var productTemplates = _productTemplateService.GetAllProductTemplates().ToPagedList(searchModel);

            //prepare grid model
            var model = new ProductTemplateListModel().PrepareToGrid(searchModel, productTemplates,
                                                                     () => productTemplates.Select(template => template.ToModel <ProductTemplateModel>()));

            return(model);
        }
        public virtual ActionResult ProductTemplates(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedKendoGridJson());
            }

            var templatesModel = _productTemplateService.GetAllProductTemplates()
                                 .Select(x => x.ToModel())
                                 .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = templatesModel,
                Total = templatesModel.Count
            };

            return(Json(gridModel));
        }
        /// <summary>
        /// Prepare paged product template list model
        /// </summary>
        /// <param name="searchModel">Product template search model</param>
        /// <returns>Product template list model</returns>
        public virtual ProductTemplateListModel PrepareProductTemplateListModel(ProductTemplateSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get product templates
            var productTemplates = _productTemplateService.GetAllProductTemplates();

            //prepare grid model
            var model = new ProductTemplateListModel
            {
                //fill in model values from the entity
                Data  = productTemplates.PaginationByRequestModel(searchModel).Select(template => template.ToModel <ProductTemplateModel>()),
                Total = productTemplates.Count
            };

            return(model);
        }
        /// <summary>
        /// Prepare available product templates
        /// </summary>
        /// <param name="items">Product template items</param>
        /// <param name="withSpecialDefaultItem">Whether to insert the first special item for the default value</param>
        /// <param name="defaultItemText">Default item text; pass null to use default value of the default item text</param>
        public virtual void PrepareProductTemplates(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            //prepare available product templates
            var availableTemplates = _productTemplateService.GetAllProductTemplates();

            foreach (var template in availableTemplates)
            {
                items.Add(new SelectListItem {
                    Value = template.Id.ToString(), Text = template.Name
                });
            }

            //insert special item for the default value
            PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText);
        }
        /// <summary>
        /// Export products to XLSX
        /// </summary>
        /// <param name="products">Products</param>
        public virtual byte[] ExportProductsToXlsx(IEnumerable <Product> products)
        {
            var properties = new[]
            {
                new PropertyByName <Product>("ProductType", p => p.ProductTypeId, IgnoreExportPoductProperty(p => p.ProductType))
                {
                    DropDownElements = ProductType.SimpleProduct.ToSelectList(useLocalization: false)
                },
                new PropertyByName <Product>("ParentGroupedProductId", p => p.ParentGroupedProductId, IgnoreExportPoductProperty(p => p.ProductType)),
                new PropertyByName <Product>("VisibleIndividually", p => p.VisibleIndividually, IgnoreExportPoductProperty(p => p.VisibleIndividually)),
                new PropertyByName <Product>("Name", p => p.Name),
                new PropertyByName <Product>("ShortDescription", p => p.ShortDescription),
                new PropertyByName <Product>("FullDescription", p => p.FullDescription),

                new PropertyByName <Product>("ProductTemplate", p => p.ProductTemplateId, IgnoreExportPoductProperty(p => p.ProductTemplate))
                {
                    DropDownElements = _productTemplateService.GetAllProductTemplates().Select(pt => pt as BaseEntity).ToSelectList(p => (p as ProductTemplate).Return(pt => pt.Name, String.Empty)),
                },
                new PropertyByName <Product>("ShowOnHomePage", p => p.ShowOnHomePage, IgnoreExportPoductProperty(p => p.ShowOnHomePage)),
                new PropertyByName <Product>("MetaKeywords", p => p.MetaKeywords, IgnoreExportPoductProperty(p => p.Seo)),
                new PropertyByName <Product>("MetaDescription", p => p.MetaDescription, IgnoreExportPoductProperty(p => p.Seo)),
                new PropertyByName <Product>("MetaTitle", p => p.MetaTitle, IgnoreExportPoductProperty(p => p.Seo)),
                new PropertyByName <Product>("SeName", p => p.GetSeName(0), IgnoreExportPoductProperty(p => p.Seo)),
                new PropertyByName <Product>("AllowCustomerReviews", p => p.AllowCustomerReviews, IgnoreExportPoductProperty(p => p.AllowCustomerReviews)),
                new PropertyByName <Product>("Published", p => p.Published, IgnoreExportPoductProperty(p => p.Published)),
                new PropertyByName <Product>("SKU", p => p.Sku),
                new PropertyByName <Product>("MarkAsNew", p => p.MarkAsNew, IgnoreExportPoductProperty(p => p.MarkAsNew)),
                new PropertyByName <Product>("MarkAsNewStartDateTimeUtc", p => p.MarkAsNewStartDateTimeUtc, IgnoreExportPoductProperty(p => p.MarkAsNewStartDate)),
                new PropertyByName <Product>("MarkAsNewEndDateTimeUtc", p => p.MarkAsNewEndDateTimeUtc, IgnoreExportPoductProperty(p => p.MarkAsNewEndDate)),
                new PropertyByName <Product>("Categories", GetCategories),
                new PropertyByName <Product>("ProductTags", GetProductTags, IgnoreExportPoductProperty(p => p.ProductTags)),
                new PropertyByName <Product>("Picture1", p => GetPictures(p)[0]),
                new PropertyByName <Product>("Picture2", p => GetPictures(p)[1]),
                new PropertyByName <Product>("Picture3", p => GetPictures(p)[2])
            };

            var productList         = products.ToList();
            var productAdvancedMode = _workContext.CurrentCustomer.GetAttribute <bool>("product-advanced-mode");

            return(ExportToXlsx(properties, productList));
        }
Exemple #7
0
        public ActionResult ProductTemplates(GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            var templatesModel = _productTemplateService.GetAllProductTemplates()
                                 .Select(x => x.ToModel())
                                 .ToList();
            var model = new GridModel <ProductTemplateModel>
            {
                Data  = templatesModel,
                Total = templatesModel.Count
            };

            return(new JsonResult
            {
                Data = model
            });
        }
Exemple #8
0
        public async Task <string> Handle(GetProductTemplateViewPath request, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(request.ProductTemplateId))
            {
                throw new ArgumentNullException("ProductTemplateId");
            }

            var templateCacheKey        = string.Format(ModelCacheEventConst.PRODUCT_TEMPLATE_MODEL_KEY, request.ProductTemplateId);
            var productTemplateViewPath = await _cacheManager.GetAsync(templateCacheKey, async() =>
            {
                var template = await _productTemplateService.GetProductTemplateById(request.ProductTemplateId);
                if (template == null)
                {
                    template = (await _productTemplateService.GetAllProductTemplates()).FirstOrDefault();
                }
                if (template == null)
                {
                    throw new Exception("No default template could be loaded");
                }
                return(template.ViewPath);
            });

            return(productTemplateViewPath);
        }
        public virtual string PrepareProductTemplateViewPath(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            var templateCacheKey        = string.Format(ModelCacheEventConsumer.PRODUCT_TEMPLATE_MODEL_KEY, product.ProductTemplateId);
            var productTemplateViewPath = _cacheManager.Get(templateCacheKey, () =>
            {
                var template = _productTemplateService.GetProductTemplateById(product.ProductTemplateId);
                if (template == null)
                {
                    template = _productTemplateService.GetAllProductTemplates().FirstOrDefault();
                }
                if (template == null)
                {
                    throw new Exception("No default template could be loaded");
                }
                return(template.ViewPath);
            });

            return(productTemplateViewPath);
        }
        public void can_export_products_to_xlsx()
        {
            var replacePairse = new Dictionary <string, string>
            {
                { "ProductId", "Id" },
                { "ProductType", "ProductTypeId" },
                { "GiftCardType", "GiftCardTypeId" },
                { "Vendor", "VendorId" },
                { "ProductTemplate", "ProductTemplateId" },
                { "DeliveryDate", "DeliveryDateId" },
                { "TaxCategory", "TaxCategoryId" },
                { "ManageInventoryMethod", "ManageInventoryMethodId" },
                { "ProductAvailabilityRange", "ProductAvailabilityRangeId" },
                { "LowStockActivity", "LowStockActivityId" },
                { "BackorderMode", "BackorderModeId" },
                { "BasepriceUnit", "BasepriceUnitId" },
                { "BasepriceBaseUnit", "BasepriceBaseUnitId" },
                { "SKU", "Sku" },
                { "DownloadActivationType", "DownloadActivationTypeId" },
                { "RecurringCyclePeriod", "RecurringCyclePeriodId" },
                { "RentalPricePeriod", "RentalPricePeriodId" }
            };

            var products = new List <Product>
            {
                new Product
                {
                    Id                               = 1,
                    ProductTypeId                    = (int)ProductType.SimpleProduct,
                    ParentGroupedProductId           = 0,
                    VisibleIndividually              = true,
                    Name                             = "TestProduct",
                    ShortDescription                 = "TestShortDescription",
                    FullDescription                  = "TestFullDescription",
                    VendorId                         = 1,
                    ProductTemplateId                = 1,
                    ShowOnHomePage                   = true,
                    MetaKeywords                     = "TestMetaKeywords",
                    MetaDescription                  = "TestMetaDescription",
                    MetaTitle                        = "TestMetaTitle",
                    AllowCustomerReviews             = true,
                    Published                        = true,
                    Sku                              = "TestSku",
                    ManufacturerPartNumber           = "TestManufacturerPartNumber",
                    Gtin                             = "TestGtin",
                    IsGiftCard                       = false,
                    GiftCardTypeId                   = (int)GiftCardType.Virtual,
                    OverriddenGiftCardAmount         = 0,
                    RequireOtherProducts             = false,
                    RequiredProductIds               = "0",
                    AutomaticallyAddRequiredProducts = true,
                    IsDownload                       = false,
                    DownloadId                       = 0,
                    UnlimitedDownloads               = true,
                    MaxNumberOfDownloads             = 100,
                    DownloadActivationTypeId         = (int)DownloadActivationType.WhenOrderIsPaid,
                    HasSampleDownload                = false,
                    SampleDownloadId                 = 0,
                    HasUserAgreement                 = false,
                    UserAgreementText                = string.Empty,
                    IsRecurring                      = false,
                    RecurringCycleLength             = 1,
                    RecurringCyclePeriodId           = (int)RecurringProductCyclePeriod.Years,
                    RecurringTotalCycles             = 10,
                    IsRental                         = false,
                    RentalPriceLength                = 1,
                    RentalPricePeriodId              = (int)RentalPricePeriod.Years,
                    IsShipEnabled                    = true,
                    IsFreeShipping                   = true,
                    ShipSeparately                   = false,
                    AdditionalShippingCharge         = 0,
                    DeliveryDateId                   = 1,
                    IsTaxExempt                      = false,
                    TaxCategoryId                    = 0,
                    IsTelecommunicationsOrBroadcastingOrElectronicServices = false,
                    ManageInventoryMethodId    = (int)ManageInventoryMethod.DontManageStock,
                    ProductAvailabilityRangeId = 1,
                    UseMultipleWarehouses      = false,
                    WarehouseId                          = 0,
                    StockQuantity                        = 100,
                    DisplayStockAvailability             = true,
                    DisplayStockQuantity                 = true,
                    MinStockQuantity                     = 1,
                    LowStockActivityId                   = (int)LowStockActivity.Nothing,
                    NotifyAdminForQuantityBelow          = 5,
                    BackorderModeId                      = (int)BackorderMode.NoBackorders,
                    AllowBackInStockSubscriptions        = true,
                    OrderMinimumQuantity                 = 1,
                    OrderMaximumQuantity                 = 10,
                    AllowedQuantities                    = "1;5;10",
                    NotReturnable                        = true,
                    DisableBuyButton                     = true,
                    DisableWishlistButton                = true,
                    AvailableForPreOrder                 = true,
                    PreOrderAvailabilityStartDateTimeUtc = new DateTime(2010, 01, 04),
                    CallForPrice                         = true,
                    Price                       = 40,
                    OldPrice                    = 50,
                    ProductCost                 = 40,
                    CustomerEntersPrice         = true,
                    MinimumCustomerEnteredPrice = 40,
                    MaximumCustomerEnteredPrice = 60,
                    BasepriceEnabled            = true,
                    BasepriceAmount             = 40,
                    BasepriceBaseUnitId         = 0,
                    BasepriceBaseAmount         = 40,
                    BasepriceUnitId             = 0,
                    MarkAsNew                   = true,
                    MarkAsNewStartDateTimeUtc   = new DateTime(2010, 01, 04),
                    MarkAsNewEndDateTimeUtc     = new DateTime(2020, 01, 04),
                    Weight                      = 10,
                    Length                      = 10,
                    Width                       = 10,
                    Height                      = 10
                }
            };

            var ignore = new List <string> {
                "Categories", "Manufacturers", "AdminComment",
                "ProductType", "BackorderMode", "DownloadActivationType", "GiftCardType", "LowStockActivity",
                "ManageInventoryMethod", "RecurringCyclePeriod", "RentalPricePeriod", "ProductCategories",
                "ProductManufacturers", "ProductPictures", "ProductReviews", "ProductSpecificationAttributes",
                "ProductTags", "ProductAttributeMappings", "ProductAttributeCombinations", "TierPrices",
                "AppliedDiscounts", "ProductWarehouseInventory", "ApprovedRatingSum", "NotApprovedRatingSum",
                "ApprovedTotalReviews", "NotApprovedTotalReviews", "SubjectToAcl", "LimitedToStores", "Deleted",
                "DownloadExpirationDays", "HasTierPrices", "HasDiscountsApplied", "AvailableStartDateTimeUtc",
                "AvailableEndDateTimeUtc", "DisplayOrder", "CreatedOnUtc", "UpdatedOnUtc"
            };

            ignore.AddRange(replacePairse.Values);

            var excelData = _exportManager.ExportProductsToXlsx(products);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Product>(worksheet);

            manager.SetSelectList("ProductType", ProductType.SimpleProduct.ToSelectList(useLocalization: false));
            manager.SetSelectList("GiftCardType", GiftCardType.Virtual.ToSelectList(useLocalization: false));
            manager.SetSelectList("DownloadActivationType", DownloadActivationType.Manually.ToSelectList(useLocalization: false));
            manager.SetSelectList("ManageInventoryMethod", ManageInventoryMethod.DontManageStock.ToSelectList(useLocalization: false));
            manager.SetSelectList("LowStockActivity", LowStockActivity.Nothing.ToSelectList(useLocalization: false));
            manager.SetSelectList("BackorderMode", BackorderMode.NoBackorders.ToSelectList(useLocalization: false));
            manager.SetSelectList("RecurringCyclePeriod", RecurringProductCyclePeriod.Days.ToSelectList(useLocalization: false));
            manager.SetSelectList("RentalPricePeriod", RentalPricePeriod.Days.ToSelectList(useLocalization: false));

            manager.SetSelectList("Vendor", _vendorService.GetAllVendors(showHidden: true).Select(v => v as BaseEntity).ToSelectList(p => (p as Vendor)?.Name ?? string.Empty));
            manager.SetSelectList("ProductTemplate", _productTemplateService.GetAllProductTemplates().Select(pt => pt as BaseEntity).ToSelectList(p => (p as ProductTemplate)?.Name ?? string.Empty));
            manager.SetSelectList("DeliveryDate", _dateRangeService.GetAllDeliveryDates().Select(dd => dd as BaseEntity).ToSelectList(p => (p as DeliveryDate)?.Name ?? string.Empty));
            manager.SetSelectList("ProductAvailabilityRange", _dateRangeService.GetAllProductAvailabilityRanges().Select(range => range as BaseEntity).ToSelectList(p => (p as ProductAvailabilityRange)?.Name ?? string.Empty));
            manager.SetSelectList("TaxCategory", _taxCategoryService.GetAllTaxCategories().Select(tc => tc as BaseEntity).ToSelectList(p => (p as TaxCategory)?.Name ?? string.Empty));
            manager.SetSelectList("BasepriceUnit", _measureService.GetAllMeasureWeights().Select(mw => mw as BaseEntity).ToSelectList(p => (p as MeasureWeight)?.Name ?? string.Empty));
            manager.SetSelectList("BasepriceBaseUnit", _measureService.GetAllMeasureWeights().Select(mw => mw as BaseEntity).ToSelectList(p => (p as MeasureWeight)?.Name ?? string.Empty));

            manager.Remove("ProductTags");

            manager.ReadFromXlsx(worksheet, 2);
            var product = products.First();

            AreAllObjectPropertiesPresent(product, manager, ignore.ToArray());
            PropertiesShouldEqual(product, manager, replacePairse);
        }
Exemple #11
0
        public void CanExportProductsToXlsx()
        {
            var replacePairs = new Dictionary <string, string>
            {
                { "ProductId", "Id" },
                { "ProductType", "ProductTypeId" },
                { "GiftCardType", "GiftCardTypeId" },
                { "Vendor", "VendorId" },
                { "ProductTemplate", "ProductTemplateId" },
                { "DeliveryDate", "DeliveryDateId" },
                { "TaxCategory", "TaxCategoryId" },
                { "ManageInventoryMethod", "ManageInventoryMethodId" },
                { "ProductAvailabilityRange", "ProductAvailabilityRangeId" },
                { "LowStockActivity", "LowStockActivityId" },
                { "BackorderMode", "BackorderModeId" },
                { "BasepriceUnit", "BasepriceUnitId" },
                { "BasepriceBaseUnit", "BasepriceBaseUnitId" },
                { "SKU", "Sku" },
                { "DownloadActivationType", "DownloadActivationTypeId" },
                { "RecurringCyclePeriod", "RecurringCyclePeriodId" },
                { "RentalPricePeriod", "RentalPricePeriodId" }
            };

            var ignore = new List <string> {
                "Categories", "Manufacturers", "AdminComment",
                "ProductType", "BackorderMode", "DownloadActivationType", "GiftCardType", "LowStockActivity",
                "ManageInventoryMethod", "RecurringCyclePeriod", "RentalPricePeriod", "ProductCategories",
                "ProductManufacturers", "ProductPictures", "ProductReviews", "ProductSpecificationAttributes",
                "ProductTags", "ProductAttributeMappings", "ProductAttributeCombinations", "TierPrices",
                "AppliedDiscounts", "ProductWarehouseInventory", "ApprovedRatingSum", "NotApprovedRatingSum",
                "ApprovedTotalReviews", "NotApprovedTotalReviews", "SubjectToAcl", "LimitedToStores", "Deleted",
                "DownloadExpirationDays", "HasTierPrices", "HasDiscountsApplied", "AvailableStartDateTimeUtc",
                "AvailableEndDateTimeUtc", "DisplayOrder", "CreatedOnUtc", "UpdatedOnUtc", "ProductProductTagMappings",
                "DiscountProductMappings", "EntityCacheKey"
            };

            ignore.AddRange(replacePairs.Values);

            var products = _productRepository.Table.ToList();

            var excelData = _exportManager.ExportProductsToXlsx(products);
            var worksheet = GetWorksheets(excelData);
            var manager   = GetPropertyManager <Product>(worksheet);

            manager.SetSelectList("ProductType", ProductType.SimpleProduct.ToSelectList(useLocalization: false));
            manager.SetSelectList("GiftCardType", GiftCardType.Virtual.ToSelectList(useLocalization: false));
            manager.SetSelectList("DownloadActivationType", DownloadActivationType.Manually.ToSelectList(useLocalization: false));
            manager.SetSelectList("ManageInventoryMethod", ManageInventoryMethod.DontManageStock.ToSelectList(useLocalization: false));
            manager.SetSelectList("LowStockActivity", LowStockActivity.Nothing.ToSelectList(useLocalization: false));
            manager.SetSelectList("BackorderMode", BackorderMode.NoBackorders.ToSelectList(useLocalization: false));
            manager.SetSelectList("RecurringCyclePeriod", RecurringProductCyclePeriod.Days.ToSelectList(useLocalization: false));
            manager.SetSelectList("RentalPricePeriod", RentalPricePeriod.Days.ToSelectList(useLocalization: false));

            manager.SetSelectList("Vendor", _vendorService.GetAllVendors(showHidden: true).Select(v => v as BaseEntity).ToSelectList(p => (p as Vendor)?.Name ?? string.Empty));
            manager.SetSelectList("ProductTemplate", _productTemplateService.GetAllProductTemplates().Select(pt => pt as BaseEntity).ToSelectList(p => (p as ProductTemplate)?.Name ?? string.Empty));
            manager.SetSelectList("DeliveryDate", _dateRangeService.GetAllDeliveryDates().Select(dd => dd as BaseEntity).ToSelectList(p => (p as DeliveryDate)?.Name ?? string.Empty));
            manager.SetSelectList("ProductAvailabilityRange", _dateRangeService.GetAllProductAvailabilityRanges().Select(range => range as BaseEntity).ToSelectList(p => (p as ProductAvailabilityRange)?.Name ?? string.Empty));
            manager.SetSelectList("TaxCategory", _taxCategoryService.GetAllTaxCategories().Select(tc => tc as BaseEntity).ToSelectList(p => (p as TaxCategory)?.Name ?? string.Empty));
            manager.SetSelectList("BasepriceUnit", _measureService.GetAllMeasureWeights().Select(mw => mw as BaseEntity).ToSelectList(p => (p as MeasureWeight)?.Name ?? string.Empty));
            manager.SetSelectList("BasepriceBaseUnit", _measureService.GetAllMeasureWeights().Select(mw => mw as BaseEntity).ToSelectList(p => (p as MeasureWeight)?.Name ?? string.Empty));

            manager.Remove("ProductTags");

            manager.ReadFromXlsx(worksheet, 2);
            var product = products.First();

            AreAllObjectPropertiesPresent(product, manager, ignore.ToArray());
            PropertiesShouldEqual(product, manager, replacePairs);
        }
Exemple #12
0
        /// <summary>
        /// Prepare product model
        /// </summary>
        /// <param name="model">Product model</param>
        /// <param name="product">Product</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Product model</returns>
        public virtual ProductModel PrepareProductModel(ProductModel model, Product product, bool excludeProperties = false)
        {
            Action <ProductLocalizedModel, int> localizedModelConfiguration = null;

            if (product != null)
            {
                //fill in model values from the entity
                model = model ?? product.ToModel <ProductModel>();

                var parentGroupedProduct = _productService.GetProductById(product.ParentGroupedProductId);
                if (parentGroupedProduct != null)
                {
                    model.AssociatedToProductId   = product.ParentGroupedProductId;
                    model.AssociatedToProductName = parentGroupedProduct.Name;
                }

                model.CreatedOn   = _dateTimeHelper.ConvertToUserTime(product.CreatedOnUtc, DateTimeKind.Utc);
                model.UpdatedOn   = _dateTimeHelper.ConvertToUserTime(product.UpdatedOnUtc, DateTimeKind.Utc);
                model.ProductTags = string.Join(", ", _productTagService.GetAllProductTagsByProductId(product.Id).Select(tag => tag.Name));

                if (!excludeProperties)
                {
                    model.SelectedCategoryIds = _categoryService.GetProductCategoriesByProductId(product.Id, true)
                                                .Select(productCategory => productCategory.CategoryId).ToList();
                }

                //prepare copy product model
                PrepareCopyProductModel(model.CopyProductModel, product);


                //prepare nested search model
                PrepareRelatedProductSearchModel(model.RelatedProductSearchModel, product);
                PrepareAssociatedProductSearchModel(model.AssociatedProductSearchModel, product);
                PrepareProductPictureSearchModel(model.ProductPictureSearchModel, product);

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    locale.Name             = _localizationService.GetLocalized(product, entity => entity.Name, languageId, false, false);
                    locale.FullDescription  = _localizationService.GetLocalized(product, entity => entity.FullDescription, languageId, false, false);
                    locale.ShortDescription = _localizationService.GetLocalized(product, entity => entity.ShortDescription, languageId, false, false);
                    locale.MetaKeywords     = _localizationService.GetLocalized(product, entity => entity.MetaKeywords, languageId, false, false);
                    locale.MetaDescription  = _localizationService.GetLocalized(product, entity => entity.MetaDescription, languageId, false, false);
                    locale.MetaTitle        = _localizationService.GetLocalized(product, entity => entity.MetaTitle, languageId, false, false);
                    locale.SeName           = _urlRecordService.GetSeName(product, languageId, false, false);
                };
            }

            //set default values for the new model
            if (product == null)
            {
                model.AllowCustomerReviews = true;
                model.Published            = true;
                model.VisibleIndividually  = true;
            }

            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            //prepare editor settings
            model.ProductEditorSettingsModel = _settingModelFactory.PrepareProductEditorSettingsModel();

            //prepare available product templates
            _baseAdminModelFactory.PrepareProductTemplates(model.AvailableProductTemplates, false);

            //prepare available product types
            var productTemplates = _productTemplateService.GetAllProductTemplates();

            foreach (var productType in Enum.GetValues(typeof(ProductType)).OfType <ProductType>())
            {
                model.ProductsTypesSupportedByProductTemplates.Add((int)productType, new List <SelectListItem>());
                foreach (var template in productTemplates)
                {
                    var list = (IList <int>)TypeDescriptor.GetConverter(typeof(List <int>)).ConvertFrom(template.IgnoredProductTypes) ?? new List <int>();
                    if (string.IsNullOrEmpty(template.IgnoredProductTypes) || !list.Contains((int)productType))
                    {
                        model.ProductsTypesSupportedByProductTemplates[(int)productType].Add(new SelectListItem
                        {
                            Text  = template.Name,
                            Value = template.Id.ToString()
                        });
                    }
                }
            }


            //prepare available vendors
            _baseAdminModelFactory.PrepareVendors(model.AvailableVendors,
                                                  defaultItemText: _localizationService.GetResource("Admin.Catalog.Products.Fields.Vendor.None"));

            //prepare model categories
            _baseAdminModelFactory.PrepareCategories(model.AvailableCategories, false);
            foreach (var categoryItem in model.AvailableCategories)
            {
                categoryItem.Selected = int.TryParse(categoryItem.Value, out var categoryId) &&
                                        model.SelectedCategoryIds.Contains(categoryId);
            }

            //prepare model customer roles
            _aclSupportedModelFactory.PrepareModelCustomerRoles(model, product, excludeProperties);

            //prepare model stores
            _storeMappingSupportedModelFactory.PrepareModelStores(model, product, excludeProperties);

            return(model);
        }
Exemple #13
0
        private void CreateExampleProducts(CcSettings settings)
        {
            var product = new Product
            {
                ProductType       = ProductType.SimpleProduct,
                ProductTemplateId = _productTemplateService.GetAllProductTemplates().First().Id,
                Name = "Business Card",
                VisibleIndividually  = true,
                ShowOnHomePage       = true,
                AllowCustomerReviews = true,
                Price        = 10,
                Published    = true,
                CreatedOnUtc = DateTime.Now,
                UpdatedOnUtc = DateTime.Now,
                AvailableStartDateTimeUtc = new DateTime(2015, 6, 1),
                OrderMaximumQuantity      = 100,
                OrderMinimumQuantity      = 1
            };

            _productService.InsertProduct(product);
            if (settings.SampleProducts == null)
            {
                settings.SampleProducts = new List <int>();
            }
            settings.SampleProducts.Add(product.Id);

            var productDefinition = new ProductSpecificationAttribute
            {
                AllowFiltering = true,
                AttributeType  = SpecificationAttributeType.CustomText,
                SpecificationAttributeOptionId = settings.EditorDefinitionSpecificationOptionId,
                CustomValue       = @"Default editor",
                DisplayOrder      = 0,
                ProductId         = product.Id,
                ShowOnProductPage = false
            };

            _specificationAttributeService.InsertProductSpecificationAttribute(productDefinition);

            var editorConfiguration = new ProductSpecificationAttribute
            {
                AllowFiltering = true,
                AttributeType  = SpecificationAttributeType.CustomText,
                SpecificationAttributeOptionId = settings.EditorConfigurationSpecificationOptionId,
                CustomValue       = @"Default config",
                DisplayOrder      = 0,
                ProductId         = product.Id,
                ShowOnProductPage = false
            };

            _specificationAttributeService.InsertProductSpecificationAttribute(editorConfiguration);

            #region product attribute mappings
            _productAttributeService.InsertProductAttributeMapping(new ProductAttributeMapping
            {
                AttributeControlType = AttributeControlType.TextBox,
                DefaultValue         = "",
                DisplayOrder         = 100,
                ProductId            = product.Id,
                ProductAttributeId   = settings.CcIdAttributeId
            });
            #endregion

            _urlRecordService.SaveSlug(product, product.ValidateSeName(product.Name, product.Name, true), 0);
        }
Exemple #14
0
        protected ProductDetailsModel PrepareProductDetailsPageModel(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            var model = new ProductDetailsModel()
            {
                Id                   = product.Id,
                Name                 = product.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id),
                ShortDescription     = product.GetLocalized(x => x.ShortDescription, _workContext.WorkingLanguage.Id),
                FullDescription      = product.GetLocalized(x => x.FullDescription, _workContext.WorkingLanguage.Id),
                OrderingComments     = product.GetLocalized(x => x.AdminComment, _workContext.WorkingLanguage.Id, false),
                MetaKeywords         = product.GetLocalized(x => x.MetaKeywords, _workContext.WorkingLanguage.Id),
                MetaDescription      = product.GetLocalized(x => x.MetaDescription, _workContext.WorkingLanguage.Id),
                MetaTitle            = product.GetLocalized(x => x.MetaTitle, _workContext.WorkingLanguage.Id),
                SeName               = product.GetSeName(),
                MinimumOrderQuantity = product.MinimumOrderQuantity.HasValue ? product.MinimumOrderQuantity.Value : 1,
                Favorit              = _favoritsService.IsItemFavorit(_workContext.CurrentCustomer.Id, product.Id)
            };

            //template

            var templateCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_TEMPLATE_MODEL_KEY, product.ProductTemplateId);

            model.ProductTemplateViewPath = _cacheManager.Get(templateCacheKey, () =>
            {
                var template = _productTemplateService.GetProductTemplateById(product.ProductTemplateId);
                if (template == null)
                {
                    template = _productTemplateService.GetAllProductTemplates().FirstOrDefault();
                }
                return(template.ViewPath);
            });

            //pictures
            model.DefaultPictureZoomEnabled = _mediaSettings.DefaultPictureZoomEnabled;
            var pictures = _pictureService.GetPicturesByProductId(product.Id);

            if (pictures.Count > 0)
            {
                //default picture
                model.DefaultPictureModel = new PictureModel()
                {
                    ImageUrl         = _pictureService.GetPictureUrl(pictures.FirstOrDefault()),
                    FullSizeImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault()),
                    Title            = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                    AlternateText    = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                };
                //all pictures
                int i = 0;
                foreach (var picture in pictures)
                {
                    model.PictureModels.Add(new PictureModel()
                    {
                        ImageUrl         = _pictureService.GetPictureUrl(picture),
                        FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
                        Title            = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                        AlternateText    = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                        Default          = i == 0
                    });
                    i++;
                }
            }
            else
            {
                //no images. set the default one
                model.DefaultPictureModel = new PictureModel()
                {
                    ImageUrl         = _pictureService.GetDefaultPictureUrl(_mediaSettings.ProductDetailsPictureSize),
                    FullSizeImageUrl = _pictureService.GetDefaultPictureUrl(),
                    Title            = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                    AlternateText    = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                };
            }

            List <CategoryProductAttributeGroup> _attrGroups         = product.ProductAttributes.Select(x => x.CategoryProductAttribute.CategoryProductGroup).Distinct().ToList();
            List <CategoryAttributeModel>        DisplayedAttributes = new List <CategoryAttributeModel>();

            foreach (var _aG in _attrGroups)
            {
                foreach (var cpa in _aG.CategoryProductAttributes)
                {
                    CategoryAttributeModel cam = new CategoryAttributeModel();
                    cam.Values = new List <CategoryProductAttributeValueModel>();
                    cam.Values.AddRange(cpa.CategoryProductAttributeValues.OrderBy(x => x.DisplayOrder)
                                        .ThenBy(x => x.Name)
                                        .Select(x =>
                    {
                        var md = new CategoryProductAttributeValueModel();
                        if (x.CategoryProductAttribute.AttributeControlType != AttributeControlType.TextBox)
                        {
                            md.Name = x.GetLocalized(z => z.Name, _workContext.WorkingLanguage.Id, false);
                        }
                        else
                        {
                            md.Name = x.Name;
                        }
                        md.IsPreSelected = product.ProductAttributes.Where(p => p.Id == x.Id).Count() > 0;
                        md.CategoryProductAttributeId = x.CategoryProductAttributeId;
                        md.Id                         = x.Id;
                        md.DisplayOrder               = x.DisplayOrder;
                        md.ColorSquaresRgb            = x.ColorSquaresRgb;
                        md.CategoryProductAttributeId = x.CategoryProductAttributeId;
                        return(md);
                    })
                                        .ToList());
                    //cam.Values.ForEach(i =>
                    //{
                    //    i.Name = i.GetLocalized(xi => xi.Name, _workContext.WorkingLanguage.Id, true);
                    //});

                    cam.Name        = cpa.ProductAttribute.GetLocalized(n => n.Name, _workContext.WorkingLanguage.Id, false);
                    cam.ControlType = cpa.AttributeControlType;
                    //cam.Values.ForEach(x =>
                    //{
                    //    x.IsPreSelected = product.ProductAttributes.Where(i => i.Id == x.Id).Count() > 0;
                    //});
                    //foreach (var val in cam.Values)
                    //{
                    //    val.IsPreSelected = product.ProductAttributes.Where(p => p.Id == val.Id).Count() > 0;
                    //}
                    var attrValue = cam.Values.Where(i => i.IsPreSelected).FirstOrDefault();
                    cam.SelectedValue = attrValue;
                    cam.DisplayOrder  = cpa.DisplayOrder;
                    //cam.SelectedValue.Name = attrValue.GetLocalized(v => v.Name, _workContext.WorkingLanguage.Id, true);
                    //cam.Values.ForEach(i => { i.Name = i.GetLocalized(xi => xi.Name, _workContext.WorkingLanguage.Id, true); });
                    DisplayedAttributes.Add(cam);
                }
            }
            model.CategoryAttributes = DisplayedAttributes.OrderBy(x => x.DisplayOrder).ToList();

            //product tags
            foreach (var item in product.ProductTags)
            {
                model.ProductTags.Add(new ProductTagModel()
                {
                    Name         = item.Name,
                    ProductCount = item.ProductCount,
                    Id           = item.Id
                });
            }
            model.CompanyInformationModel               = new CompanyInformationModel();
            model.CompanyInformationModel.CompanyName   = product.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, _workContext.WorkingLanguage.Id, false);
            model.CompanyInformationModel.CompanySeName = product.Customer.CompanyInformation.GetSeName(_workContext.WorkingLanguage.Id);
            if (model.CompanyInformationModel.CompanyName == null)
            {
                var languages = _languageService.GetAllLanguages().ToList();
                model.CompanyInformationModel.CompanyName = product.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, languages.Where(l => l.LanguageCulture == "es-MX").FirstOrDefault().Id, false);
                model.CompanyInformationModel.CompanyName = product.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, languages.Where(l => l.LanguageCulture == "de-DE").FirstOrDefault().Id, false);
                model.CompanyInformationModel.CompanyName = product.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, languages.Where(l => l.LanguageCulture == "en-US").FirstOrDefault().Id, false);
                model.CompanyInformationModel.CompanyName = product.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, languages.Where(l => l.LanguageCulture == "ru-RU").FirstOrDefault().Id, false);
            }

            var prices     = _productPriceService.GetAllProductPrices(model.Id);
            var currencies = _currencyService.GetAllCurrencies().Where(c => c.Published).ToList();

            model.ProductPrices = new List <ProductDetailsModel.ProductPriceModel>();
            var prices_to_delete = prices.Where(p => !currencies.Contains(p.Currency)).ToList();

            prices = prices.Where(p => currencies.Contains(p.Currency)).ToList();
            foreach (var p in prices_to_delete)
            {
                _productPriceService.DeleteProductPriceById(p.Id);
            }
            model.ProductPrices = new List <ProductDetailsModel.ProductPriceModel>();
            foreach (var price in prices)
            {
                model.ProductPrices.Add(new ProductDetailsModel.ProductPriceModel()
                {
                    CurrencyId     = price.CurrencyId,
                    Id             = price.Id,
                    Price          = price.Price,
                    PriceUpdatedOn = price.PriceUpdatedOn,
                    PriceValue     = price.Price.ToString("N2"),
                    ProductId      = price.ProductId,
                    Currency       = new Core.Domain.Directory.Currency()
                    {
                        CurrencyCode = price.Currency.CurrencyCode
                    }
                });
            }

            return(model);
        }
Exemple #15
0
        protected override void Import(IImportExecuteContext context)
        {
            var srcToDestId = new Dictionary <int, ImportProductMapping>();

            var templateViewPaths = _productTemplateService.GetAllProductTemplates()
                                    .GroupBy(x => x.ViewPath, StringComparer.OrdinalIgnoreCase)
                                    .ToDictionary(x => x.Key, x => x.First().Id);

            using (var scope = new DbContextScope(ctx: _productRepository.Context, autoDetectChanges: false, proxyCreation: false, validateOnSave: false))
            {
                var segmenter = context.GetSegmenter <Product>();

                Init(context, _dataExchangeSettings);

                context.Result.TotalRecords = segmenter.TotalRows;

                while (context.Abort == DataExchangeAbortion.None && segmenter.ReadNextBatch())
                {
                    var batch = segmenter.CurrentBatch;

                    // Perf: detach all entities
                    _productRepository.Context.DetachAll(false);

                    context.SetProgress(segmenter.CurrentSegmentFirstRowIndex - 1, segmenter.TotalRows);

                    // ===========================================================================
                    // 1.) Import products
                    // ===========================================================================
                    try
                    {
                        ProcessProducts(context, batch, templateViewPaths, srcToDestId);
                    }
                    catch (Exception exception)
                    {
                        context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessProducts");
                    }

                    // reduce batch to saved (valid) products.
                    // No need to perform import operations on errored products.
                    batch = batch.Where(x => x.Entity != null && !x.IsTransient).ToArray();

                    // update result object
                    context.Result.NewRecords      += batch.Count(x => x.IsNew && !x.IsTransient);
                    context.Result.ModifiedRecords += batch.Count(x => !x.IsNew && !x.IsTransient);

                    // ===========================================================================
                    // 2.) Import SEO Slugs
                    // IMPORTANT: Unlike with Products AutoCommitEnabled must be TRUE,
                    //            as Slugs are going to be validated against existing ones in DB.
                    // ===========================================================================
                    if (segmenter.HasColumn("SeName") || batch.Any(x => x.IsNew || x.NameChanged))
                    {
                        try
                        {
                            _productRepository.Context.AutoDetectChangesEnabled = true;
                            ProcessSlugs(context, batch);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessSlugs");
                        }
                        finally
                        {
                            _productRepository.Context.AutoDetectChangesEnabled = false;
                        }
                    }

                    if (segmenter.HasColumn("LimitedToStores") && segmenter.HasColumn("StoreIds"))
                    {
                        try
                        {
                            _productRepository.Context.AutoDetectChangesEnabled = true;
                            ProcessStoreMappings(context, batch);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessStoreMappings");
                        }
                        finally
                        {
                            _productRepository.Context.AutoDetectChangesEnabled = false;
                        }
                    }

                    // ===========================================================================
                    // 3.) Import Localizations
                    // ===========================================================================
                    try
                    {
                        ProcessLocalizations(context, batch);
                    }
                    catch (Exception exception)
                    {
                        context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessLocalizations");
                    }

                    // ===========================================================================
                    // 4.) Import product category mappings
                    // ===========================================================================
                    if (segmenter.HasColumn("CategoryIds"))
                    {
                        try
                        {
                            ProcessProductCategories(context, batch);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessProductCategories");
                        }
                    }

                    // ===========================================================================
                    // 5.) Import product manufacturer mappings
                    // ===========================================================================
                    if (segmenter.HasColumn("ManufacturerIds"))
                    {
                        try
                        {
                            ProcessProductManufacturers(context, batch);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessProductManufacturers");
                        }
                    }

                    // ===========================================================================
                    // 6.) Import product picture mappings
                    // ===========================================================================
                    if (segmenter.HasColumn("ImageUrls"))
                    {
                        try
                        {
                            ProcessProductPictures(context, batch);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessProductPictures");
                        }
                    }
                }

                // ===========================================================================
                // 7.) Map parent id of inserted products
                // ===========================================================================
                if (srcToDestId.Any() && segmenter.HasColumn("Id") && segmenter.HasColumn("ParentGroupedProductId"))
                {
                    segmenter.Reset();

                    while (context.Abort == DataExchangeAbortion.None && segmenter.ReadNextBatch())
                    {
                        var batch = segmenter.CurrentBatch;

                        _productRepository.Context.DetachAll(false);

                        try
                        {
                            ProcessProductMappings(context, batch, srcToDestId);
                        }
                        catch (Exception exception)
                        {
                            context.Result.AddError(exception, segmenter.CurrentSegment, "ProcessParentMappings");
                        }
                    }
                }
            }
        }
Exemple #16
0
        public ActionResult List(int?orderStatusId   = null,
                                 int?paymentStatusId = null, int?shippingStatusId = null)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            //    return AccessDeniedView();

            //if (_workContext.CurrentVendor != null)
            //{
            var orders = _orderService.SearchOrders();

            //}

            foreach (var order in orders)
            {
                decimal commission = new decimal(0);

                foreach (var item in order.OrderItems)
                {
                    var productTemplates = _productTemplateService.GetAllProductTemplates();
                    foreach (var template in productTemplates)
                    {
                        if (template.Id == item.Product.ProductTemplateId)
                        {
                        }
                    }
                }

                var invoice = new Invoice
                {
                    OrderId          = order.Id,
                    Commission       = order.OrderTotal * new decimal(0.15),
                    StoreId          = order.StoreId,
                    IsCommissionPaid = false,
                    CreatedOnUtc     = DateTime.Now,
                    PaymentStatus    = order.PaymentStatus,
                    ShippingStatus   = order.ShippingStatus,
                    BillingAddress   = order.BillingAddress,
                    OrderStatus      = order.OrderStatus,
                    ProductId        = 0
                };
                if (_invoiceService.GetInvoicesByOrderId(order.Id) == null)
                {
                    _invoiceService.InsertInvoice(invoice);
                }
                else
                {
                    _invoiceService.UpdateInvoice(invoice);
                }
            }

            //order statuses
            var model = new InvoiceListModel();

            model.AvailableOrderStatuses = OrderStatus.Pending.ToSelectList(false).ToList();
            model.AvailableOrderStatuses.Insert(0, new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            if (orderStatusId.HasValue)
            {
                //pre-select value?
                var item = model.AvailableOrderStatuses.FirstOrDefault(x => x.Value == orderStatusId.Value.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }

            //payment statuses
            model.AvailablePaymentStatuses = PaymentStatus.Pending.ToSelectList(false).ToList();
            model.AvailablePaymentStatuses.Insert(0, new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            if (paymentStatusId.HasValue)
            {
                //pre-select value?
                var item = model.AvailablePaymentStatuses.FirstOrDefault(x => x.Value == paymentStatusId.Value.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }

            //shipping statuses
            model.AvailableShippingStatuses = ShippingStatus.NotYetShipped.ToSelectList(false).ToList();
            model.AvailableShippingStatuses.Insert(0, new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            if (shippingStatusId.HasValue)
            {
                //pre-select value?
                var item = model.AvailableShippingStatuses.FirstOrDefault(x => x.Value == shippingStatusId.Value.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            ////vendors
            //model.AvailableVendors.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            //foreach (var v in _vendorService.GetAllVendors(showHidden: true))
            //    model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id.ToString() });

            ////warehouses
            //model.AvailableWarehouses.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
            //foreach (var w in _shippingService.GetAllWarehouses())
            //    model.AvailableWarehouses.Add(new SelectListItem { Text = w.Name, Value = w.Id.ToString() });

            //payment methods
            model.AvailablePaymentMethods.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = ""
            });
            foreach (var pm in _paymentService.LoadAllPaymentMethods())
            {
                model.AvailablePaymentMethods.Add(new SelectListItem {
                    Text = pm.PluginDescriptor.FriendlyName, Value = pm.PluginDescriptor.SystemName
                });
            }

            ////billing countries
            //foreach (var c in _countryService.GetAllCountriesForBilling(true))
            //{
            //    model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString() });
            //}
            //model.AvailableCountries.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });

            //a vendor should have access only to orders with his products
            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;

            return(View(model));
        }