private void CreateFashionProduct(ContentReference productReference, ContentReference parentReference, FashionProduct fashionProduct, string code) { fashionProduct.Code = code; fashionProduct.DisplayName = "DisplayName"; fashionProduct.ParentLink = parentReference; fashionProduct.ContentLink = productReference; fashionProduct.Created = new DateTime(2012, 4, 4); fashionProduct.Brand = "Brand"; fashionProduct.CommerceMediaCollection = new ItemCollection <CommerceMedia>() { new CommerceMedia(new ContentReference(5, 0), "episerver.core.icontentimage", "default", 0) }; }
public Session Build(Session session, ICart cart, PaymentsConfiguration paymentsConfiguration, IDictionary <string, object> dic = null, bool includePersonalInformation = false) { if (includePersonalInformation && paymentsConfiguration.CustomerPreAssessment) { session.Customer = new Customer { DateOfBirth = "1980-01-01", Gender = "Male", LastFourSsn = "1234" }; } session.MerchantReference2 = "12345"; if (paymentsConfiguration.UseAttachments) { var converter = new IsoDateTimeConverter { DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" }; var customerAccountInfos = new List <Dictionary <string, object> > { new Dictionary <string, object> { { "unique_account_identifier", "Test Testperson" }, { "account_registration_date", DateTime.Now }, { "account_last_modified", DateTime.Now } } }; var emd = new Dictionary <string, object> { { "customer_account_info", customerAccountInfos } }; session.Attachment = new Attachment { ContentType = "application/vnd.klarna.internal.emd-v2+json", Body = JsonConvert.SerializeObject(emd, converter) }; } if (session.OrderLines != null) { foreach (var lineItem in session.OrderLines) { if (lineItem.Type.Equals("physical")) { EntryContentBase entryContent = null; FashionProduct product = null; if (!string.IsNullOrEmpty(lineItem.Reference)) { var contentLink = _referenceConverter.Service.GetContentLink(lineItem.Reference); if (!ContentReference.IsNullOrEmpty(contentLink)) { entryContent = _contentRepository.Service.Get <EntryContentBase>(contentLink); var parentLink = entryContent.GetParentProducts(_relationRepository.Service).SingleOrDefault(); product = _contentRepository.Service.Get <FashionProduct>(parentLink); } } var patchedOrderLine = (PatchedOrderLine)lineItem; if (patchedOrderLine.ProductIdentifiers == null) { patchedOrderLine.ProductIdentifiers = new PatchedProductIdentifiers(); } patchedOrderLine.ProductIdentifiers.Brand = product?.Brand; patchedOrderLine.ProductIdentifiers.GlobalTradeItemNumber = "GlobalTradeItemNumber test"; patchedOrderLine.ProductIdentifiers.ManuFacturerPartNumber = "ManuFacturerPartNumber test"; patchedOrderLine.ProductIdentifiers.CategoryPath = "test / test"; if (paymentsConfiguration.SendProductAndImageUrlField && entryContent != null) { ((PatchedOrderLine)lineItem).ProductUrl = SiteUrlHelper.GetAbsoluteUrl() + entryContent.GetUrl(_linksRepository.Service, _urlResolver.Service); } } } } return(session); }
public CatalogIndexerTests() { var synchronizedObjectInstanceCache = new Mock <ISynchronizedObjectInstanceCache>(); _cheapPriceUSD = new Money(1000, "USD"); _expensivePriceGBP = new Money(2000, "GBP"); _discountPriceUSD = new Money(500, "USD"); _discountPriceGBP = new Money(500, "GBP"); var catalogSystemMock = new Mock <ICatalogSystem>(); _promotionServiceMock = new Mock <IPromotionService>(); _contentLoaderMock = new Mock <IContentLoader>(); _priceServiceMock = new Mock <IPriceService>(); _relationRepositoryMock = new Mock <IRelationRepository>(); _promotionServiceMock = new Mock <IPromotionService>(); _fakeAppContext = new FakeAppContext(); _referenceConverterMock = new Mock <ReferenceConverter>( new EntryIdentityResolver(synchronizedObjectInstanceCache.Object), new NodeIdentityResolver(synchronizedObjectInstanceCache.Object)) { CallBase = true }; _urlResolverMock = new Mock <UrlResolver>(); _assetUrlConventionsMock = new Mock <AssetUrlConventions>(); _assetUrlResolverMock = new Mock <AssetUrlResolver>(_urlResolverMock.Object, _assetUrlConventionsMock.Object, _contentLoaderMock.Object); _subject = new CatalogIndexer(catalogSystemMock.Object, _priceServiceMock.Object, new Mock <IInventoryService>().Object, new MetaDataContext(), _contentLoaderMock.Object, _promotionServiceMock.Object, _referenceConverterMock.Object, _assetUrlResolverMock.Object, _relationRepositoryMock.Object, _fakeAppContext, new Mock <ILogger>().Object); var productReference = GetContentReference(444, CatalogContentType.CatalogEntry); var catalogProductReference = GetContentReference(888, CatalogContentType.CatalogEntry); var greenVariantReference = GetContentReference(445, CatalogContentType.CatalogEntry); var bluevariantReference = GetContentReference(446, CatalogContentType.CatalogEntry); var rootNodeReference = GetContentReference(10, CatalogContentType.CatalogNode); var catalogReference = GetContentReference(4, CatalogContentType.Catalog); var variants = new[] { bluevariantReference, greenVariantReference }; var greenCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 1"); var blueCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 2"); _fashionProduct = new FashionProduct(); CreateFashionProduct(productReference, rootNodeReference, _fashionProduct, "ProductCode"); _catalogProduct = new FashionProduct(); CreateFashionProduct(catalogProductReference, catalogReference, _catalogProduct, "CatalogProductCode"); SetupGetContentLink("productCode", productReference); SetupGetContentLink("catalogProductCode", catalogProductReference); var enCultureInfo = CultureInfo.GetCultureInfo("en"); SetupGetFashionProduct(productReference, enCultureInfo, _fashionProduct); SetupGetFashionProduct(catalogProductReference, enCultureInfo, _catalogProduct); SetupGetVariants(productReference, variants); SetupGetRootNode(rootNodeReference, catalogReference); SetupGetCatalog(catalogReference); SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceGBP); SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceUSD); SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceGBP); SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceUSD); SetupGetItems(variants, enCultureInfo, new List <FashionVariant> { new FashionVariant { Code = "Variant 1", Color = "Green", }, new FashionVariant { Code = "Variant 2", Color = "Blue", } }); SetupGetCatalogEntryPrices(new[] { greenCatalogKey, blueCatalogKey }); }
private IEnumerable <string> GetAvailableSizes(FashionProduct product, FashionVariant entry) { return(product != null? _catalogContentService.GetVariants <FashionVariant>(product).Where(x => x.Color.Equals(entry.Color, StringComparison.OrdinalIgnoreCase)).Select(x => x.Size) : Enumerable.Empty <string>()); }
private string GetBrand(FashionProduct product) { return(product?.Brand); }
private static void SetAvailableSizes(FashionProduct product, ItemCollection <string> sizes) { product.AvailableSizes = sizes; }
public async Task <object> GetBy(FashionProduct parameters) { return(await Uow.Repository <FashionProduct>().FindByAsync(t => t.FashionProductId == parameters.FashionProductId)); }
public static string Gender(this FashionProduct fashionProduct) { var topCategory = GetTopCategory(fashionProduct); return(topCategory.DisplayName); }
public IEnumerable <FashionVariant> GetVariants(FashionProduct currentContent) { return(GetAvailableVariants(currentContent.GetVariants(_relationRepository))); }
public HashSet <string> DeleteValidation(FashionProduct parameters) { return(ValidationMessages); }
public Task DeleteAsync(FashionProduct parameters) { throw new NotImplementedException(); }
public async Task UpdateAsync(FashionProduct entity) { await Uow.RegisterDirtyAsync(entity); await Uow.CommitAsync(); }
public HashSet <string> UpdateValidation(FashionProduct entity) { return(ValidationMessages); }
public async Task AddAsync(FashionProduct entity) { await Uow.RegisterNewAsync(entity); await Uow.CommitAsync(); }
private void SetupGetFashionProduct(ContentReference productReference, CultureInfo cultureInfo, FashionProduct fashionProduct) { _contentLoaderMock.Setup( x => x.Get <ProductContent>(productReference)) .Returns(fashionProduct); _contentLoaderMock.Setup(x => x.Get <EntryContentBase>(productReference, cultureInfo)).Returns(fashionProduct); }
private string GetBrand(FashionProduct product) { return(product != null ? product.Brand : null); }
public virtual IEnumerable <T> GetAllVariants <T>(FashionProduct product, string language) where T : VariationContent { return(_contentLoader .GetItems(product.GetVariants(_relationRepository), CultureInfo.GetCultureInfo(language)) .OfType <T>()); }
private IEnumerable <string> GetAvailableSizes(FashionProduct product, VariationContent variant) { return(product != null? _productService.GetVariations(product).Where(x => x.Color.Equals(((FashionVariant)variant).Color, StringComparison.OrdinalIgnoreCase)).Select(x => x.Size) : Enumerable.Empty <string>()); }
private static void SetAvailableColors(FashionProduct product, ItemCollection <string> colors) { product.AvailableColors = colors; }
public async Task <object> GetAsync(FashionProduct parameters) { return(await Uow.Repository <FashionProduct>().AllAsync()); }