コード例 #1
0
        private PriceList CreatePriceList(Website webSite, StructureInfo structureInfo)
        {
            var priceList = _priceListService.Get(webSite.Id.Replace(" ", ""));

            if (priceList != null)
            {
                return(priceList);
            }

            var currency = _currencyService.Get(structureInfo.ProductCatalog.CurrencyId) ??
                           _currencyService.GetBaseCurrency();

            priceList = new PriceList(structureInfo.Id(currency.SystemId))
            {
                Id                = webSite.Id.Replace(" ", ""),
                Active            = structureInfo.ProductCatalog.PriceList?.Active ?? true,
                AccessControlList = structureInfo.ProductCatalog.PriceList.AccessControlList.MakeWritable()
            };

            if (structureInfo.ProductCatalog.PriceList?.WebSiteLinks.Any(x => structureInfo.Id(x.WebSiteSystemId) == structureInfo.Website.Website.SystemId) ?? false)
            {
                priceList.WebSiteLinks.Add(new PriceListToWebSiteLink(webSite.SystemId));
            }

            foreach (var language in Solution.Instance.Languages)
            {
                priceList.Localizations[language.Culture].Name = webSite.Localizations[language.Culture].Name;
            }

            _priceListService.Create(priceList);
            if (structureInfo.ProductCatalog.PriceList != null)
            {
                structureInfo.Mappings.Add(structureInfo.ProductCatalog.PriceList.SystemId, priceList.SystemId);
            }

            return(priceList);
        }
コード例 #2
0
        public VariantInfo Build(Guid variantSystemId, Guid channelSystemId, DataFilterBase dataFilter = null)
        {
            if (variantSystemId == Guid.Empty)
            {
                return(null);
            }
            var entity = _variantService.Get(variantSystemId);

            if (entity == null)
            {
                return(null);
            }
            var pageModel = new VariantInfo()
            {
                SystemId = variantSystemId
            };
            var currency = _currencyService.Get(id: ((ProductDataFilter)dataFilter)?.Currency) ?? _currencyService.GetBaseCurrency();

            BuildFields(pageModel, entity, dataFilter?.Culture);
            BuildPrices(pageModel, entity, currency, channelSystemId);
            return(pageModel);
        }