public void StoreSaved(ProductCatalogGroup store) { foreach (var provider in _providers) { provider.StoreSaved(store); } }
private ProductCatalog CreateProductCatalog(ProductCatalogGroup catalogGroup) { var catalogDefinitionType = DefinitionType.SingleOrDefault(x => x.Name == "Product Catalogs"); var catalogDefinition = Definition.SingleOrDefault(x => x.DefinitionType == catalogDefinitionType); var catalog = catalogGroup.ProductCatalogs.SingleOrDefault(c => c.Name == _catalogName) ?? new ProductCatalogFactory().NewWithDefaults(catalogGroup, _catalogName, catalogDefinition.Guid); catalog.DisplayOnWebSite = true; catalog.Deleted = false; catalog.ShowPricesIncludingVAT = true; // Versions of CatalogFactory prior to 3.6 did not // add catalog to catalog group. Need to do it // if not already done to make sure roles and // permissions are created properly. if (!catalogGroup.ProductCatalogs.Contains(catalog)) { catalogGroup.ProductCatalogs.Add(catalog); } catalog.Save(); var priceGroup = PriceGroup.SingleOrDefault(p => p.Name == "EUR 15 pct"); if (priceGroup != null) { catalog.PriceGroup = priceGroup; } catalog.Save(); return(catalog); }
public bool SaveItem(ITreeNodeContent node, ItemChanges changes) { if (!changes.HasFieldsChanged) { return(false); } var store = ProductCatalogGroup.Get(int.Parse(node.ItemId)); if (store == null) { string message = string.Format("Store with id: {0} not found for ITreeNodeContent. ", node.ItemId); _loggingService.Log <ProductCatalogGroupTemplateBuilder>(message); throw new InvalidDataException(message); } foreach (FieldChange fieldChange in changes.FieldChanges) { UpdateStoreValueFor(fieldChange, store, changes); } ObjectFactory.Instance.Resolve <IPipeline <ProductCatalogGroup> >("SaveProductCatalogGroup").Execute(store); return(true); }
private string GetSecurityPermisionsFor(ProductCatalogGroup store) { var valueBuilder = ObjectFactory.Instance.Resolve <ISecurityFieldValueBuilder>(); var security = valueBuilder.BuildSecurityValue(store); return(security); }
private void DeleteOldUCommerceData() { var group = ProductCatalogGroup.SingleOrDefault(g => g.Name == "uCommerce.dk"); if (group != null) { // Delete products in group foreach ( var relation in CategoryProductRelation.All() .Where(x => group.ProductCatalogs.Contains(x.Category.ProductCatalog)) .ToList()) { var category = relation.Category; var product = relation.Product; category.RemoveProduct(product); product.Delete(); } // Delete catalogs foreach (var catalog in group.ProductCatalogs) { catalog.Deleted = true; } // Delete group itself group.Deleted = true; group.Save(); } }
public virtual string BuildSecurityValue(ProductCatalogGroup shop) { AccessRuleCollection accessRulesForUsers = BuildAccessRuleCollectionForUsers(shop); var serializer = new AccessRuleSerializer(); var value = serializer.Serialize(accessRulesForUsers); return(value); }
public ActionResult SaveReview(ReviewFormSaveReviewViewModel viewModel) { var product = _productRepository.SingleOrDefault(x => x.Guid.ToString() == viewModel.ProductGuid); var catalogGroup = _catalogContext.CurrentCatalogGroup; var catalogGroupV2 = ProductCatalogGroup.FirstOrDefault(x => x.Guid == catalogGroup.Guid); var request = System.Web.HttpContext.Current.Request; var basket = _orderContext.GetBasket(); var name = viewModel.Name; var email = viewModel.Email; var rating = viewModel.Rating * 20; var reviewHeadline = viewModel.Title; var reviewText = viewModel.Comments; if (basket.PurchaseOrder.Customer == null) { basket.PurchaseOrder.Customer = new Customer() { FirstName = name, LastName = String.Empty, EmailAddress = email }; } else { basket.PurchaseOrder.Customer.FirstName = name; if (basket.PurchaseOrder.Customer.LastName == null) { basket.PurchaseOrder.Customer.LastName = String.Empty; } basket.PurchaseOrder.Customer.EmailAddress = email; } basket.PurchaseOrder.Customer.Save(); var review = new ProductReview(); review.ProductCatalogGroup = catalogGroupV2; review.ProductReviewStatus = _productReviewStatusRepository.SingleOrDefault(s => s.Name == "New"); review.CreatedOn = DateTime.Now; review.CreatedBy = "System"; review.Product = product; review.Customer = basket.PurchaseOrder.Customer; review.Rating = rating; review.ReviewHeadline = reviewHeadline; review.ReviewText = reviewText; review.Ip = request.UserHostName; product.AddProductReview(review); _productReviewPipeline.Execute(review); return(Json(new { Rating = review.Rating, ReviewHeadline = review.ReviewHeadline, CreatedBy = review.CreatedBy, CreatedOn = review.CreatedOn.ToString("MMM dd, yyyy"), CreatedOnForMeta = review.CreatedOn.ToString("yyyy-MM-dd"), Comments = review.ReviewText }, JsonRequestBehavior.AllowGet)); }
public void AddFieldValues(ITreeNodeContent node, FieldList list, VersionUri version) { var store = ProductCatalogGroup.Get(int.Parse(node.ItemId)); if (store != null) { _baseProductCatalogGroupTemplate.AddBaseFieldValues(store, list, version); } }
private void UpdateStoreName(ProductCatalogGroup store, string value, ItemChanges changes) { if (ProductCatalogGroup.SingleOrDefault(x => x.Name == value) != null) { _loggingService.Log <ProductCatalogGroupTemplateBuilder>(string.Format("Failed to update store name for store. Store with name: {0} already exists.", value)); return; } store.Name = value; }
private void EnablePaymentMethodForCatalog(ProductCatalogGroup catalogGroup) { var paymentMethods = PaymentMethod.All(); foreach (var method in paymentMethods) { method.ClearEligibleProductCatalogGroups(); method.AddEligibleProductCatalogGroup(catalogGroup); method.Save(); } }
private void EnableShippingMethodForCatalog(ProductCatalogGroup catalogGroup) { var shippingMethods = ShippingMethod.All(); foreach (var method in shippingMethods) { method.ClearEligibleProductCatalogGroups(); method.AddEligibleProductCatalogGroup(catalogGroup); method.Save(); } }
public ProductCatalog Catalog(string name, ProductCatalogGroup catalogGroup, PriceGroup priceGroup) { var catalog = _catalogs.Value.SingleOrDefault(x => x.Name == name) ?? new ProductCatalog(); catalog.Name = name; catalog.DisplayOnWebSite = false; catalog.ProductCatalogGroup = catalogGroup; catalog.PriceGroup = priceGroup; catalog.Deleted = false; return(catalog); }
public void UnassignCategoryFromCatalogs(string name, ProductCatalogGroup group) { var catalogs = _catalogs.Value.Select(c => c.ProductCatalogGroup == group && !c.Deleted); foreach (var catalog in catalogs) { Category toBeUnassigned = catalog.Categories.Single(c => c.Name == name); catalog.Categories.Remove(toBeUnassigned); _categories.Value.Delete(toBeUnassigned); } _catalogs.Value.Save(catalogs); }
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; var model = new IndexModel { //ProductCatalogs = ProductCatalog.All().ToList(), ProductCatalogGroups = ProductCatalogGroup.All().ToList(), //Categories = Category.All().ToList() }; return(View("Index", model)); }
private ProductCatalogGroup CreateCatalogGroup() { var group = ProductCatalogGroup.SingleOrDefault(c => c.Name == _catalogGroupName) ?? new ProductCatalogGroupFactory().NewWithDefaults(_catalogGroupName); group.ProductReviewsRequireApproval = true; group.Deleted = false; group.CreateCustomersAsMembers = false; group.DomainId = null; group.Save(); group.OrderNumberSerie = GetDefaultOrderNumberSeries(); group.EmailProfile = GetDefaultEmailProfile(); group.Save(); return(group); }
private void UpdateStoreMemberType(string value, ProductCatalogGroup store) { var memberService = ObjectFactory.Instance.Resolve <IMemberService>(); foreach (var memberType in memberService.GetMemberTypes()) { if (memberType.SitecoreId().ToString() == value) { store.MemberTypeId = memberType.MemberTypeId; return; } } store.MemberTypeId = "-1"; }
private ProductCatalogGroup CreateProductCatalogGroup(string catalogGroupName, Currency defaultCurrency) { var productCatalogGroup = new ProductCatalogGroup() { Name = catalogGroupName, Currency = defaultCurrency, CreateCustomersAsMembers = true, ProductReviewsRequireApproval = true, Deleted = false, EmailProfile = _session.Query <EmailProfile>() .SingleOrDefault(a => a.Name == "Default") }; return(productCatalogGroup); }
/// <summary> /// Call this method to inform the data provider that a specific store has changed /// </summary> public void StoreSaved(ProductCatalogGroup store) { _log.Log <DataProviderMasterDatabase>("Store saved : " + store.Name); if (_sitecoreDataProviders != null) { foreach (var provider in _sitecoreDataProviders) { provider.StoreSaved(store); } } _fieldsCache.EvictItem(store.Guid); store.Guid.EvictFromSitecoresItemCache(); }
protected virtual AccessRuleCollection BuildAccessRuleCollectionForUsers(ProductCatalogGroup group) { var result = new AccessRuleCollection(); foreach (var user in _userService.GetAllUsers()) { var sitecoreAccount = SitecoreUsers[user.ExternalId]; bool hasAccess = _securityService.UserCanAccess <ProductCatalogGroupRole, ProductCatalogGroup>(group, user); var userCollection = BuildAccessRuleCollectionFull(sitecoreAccount, hasAccess); result.AddRange(userCollection); } return(result); }
public void AssignCategoryToCatalogs(string name, Definition definition, ProductCatalogGroup group) { var catalogs = _catalogs.Value.Select(c => c.ProductCatalogGroup == group && !c.Deleted); foreach (var catalog in catalogs) { Category category = _categories.Value.SingleOrDefault(c => c.Name == name && c.ProductCatalog.Name == catalog.Name) ?? new Category(); category.Name = name; category.Definition = definition; category.Deleted = false; catalog.AddCategory(category); } _catalogs.Value.Save(catalogs); }
public void AddBaseFieldValues(ProductCatalogGroup store, FieldList list, VersionUri version) { var securityPermisions = GetSecurityPermisionsFor(store); list.SafeAdd(FieldIDs.Security, securityPermisions); list.SafeAdd(FieldIds.Store.NameFieldId, store.Name); list.SafeAdd(FieldIds.Store.ProductCatalogGroupIdFieldId, store.ProductCatalogGroupId.ToString()); list.SafeAdd(FieldIds.Store.HostNameFieldId, GetSitecoreItemIdForDomainId(store.DomainId).ToString()); list.SafeAdd(FieldIds.Store.DescriptionFieldId, store.Description); list.SafeAdd(FieldIds.Store.CurrencyFieldId, store.Currency.SitecoreId().ToString()); list.SafeAdd(FieldIds.Store.EmailProfileFieldId, store.EmailProfile.SitecoreId().ToString()); list.SafeAdd(FieldIds.Store.OrderNumberSeriesFieldId, store.OrderNumberSerie.SitecoreId().ToString()); list.SafeAdd(FieldIds.Store.ProductReviewRequiresApprovalFieldId, store.ProductReviewsRequireApproval.ToSitecoreFormat()); list.SafeAdd(FieldIds.Store.CreateCustomersAsMembersFieldId, store.CreateCustomersAsMembers.ToSitecoreFormat()); list.SafeAdd(FieldIds.Store.MemberGroupFieldId, ConvertMemberGroupIdToSitecoreId(store.MemberGroupId)); list.SafeAdd(FieldIds.Store.MemberTypeFieldId, ConvertMemberTypeIdToSitecoreId(store.MemberTypeId)); list.SafeAdd(FieldIDs.Revision, store.Guid.Derived(store.ModifiedOn).ToString()); }
public PipelineExecutionResult Execute(InitializeArgs subject) { if (ProductCatalogGroup.All().Any(x => x.Name == "avenue-clothing.com")) { return(PipelineExecutionResult.Success); } new ConfigurationInstaller().Configure(); new CatalogueInstaller("avenue-clothing.com", "Demo Store").Configure(); var group = ProductCatalogGroup.SingleOrDefault(g => g.Name == "uCommerce.dk"); if (group != null) { // Delete products in group foreach ( var relation in CategoryProductRelation.All() .Where(x => group.ProductCatalogs.Contains(x.Category.ProductCatalog)) .ToList()) { var category = relation.Category; var product = relation.Product; category.RemoveProduct(product); product.Delete(); } // Delete catalogs foreach (var catalog in group.ProductCatalogs) { catalog.Deleted = true; } // Delete group itself group.Deleted = true; group.Save(); } return(PipelineExecutionResult.Success); }
private void UpdateStoreEmailProfile(string value, ProductCatalogGroup store) { ID id; if (ID.TryParse(value, out id)) { var emailProfile = EmailProfile.SingleOrDefault(x => x.Guid == id.Guid); if (emailProfile == null) { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update email profile for store. Could not find email profile with guid: {0}.", id.Guid)); return; } store.EmailProfile = emailProfile; } else { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update email profile for store. Could not find Sitecore ID for email profile with id: {0}.", value)); } }
private void UpdateStoreCurrency(ProductCatalogGroup store, string value) { ID id; if (ID.TryParse(value, out id)) { var currency = Currency.SingleOrDefault(x => x.Guid == id.Guid); if (currency == null) { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update currency for store. Could not find currency with guid: {0}.", id.Guid)); return; } store.Currency = currency; } else { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update currency for store. Could not find Sitecore ID for currency with id: {0}.", value)); } }
public IEnumerable <Product> Execute(TypeInfo input) { switch (input.TypeName) { case "Category": Category category = Category.SingleOrDefault(a => a.CategoryId == input.Id); return(Product.GetForCategory(category).ToList()); case "ProductCatalog": ProductCatalog productCatalog = ProductCatalog.SingleOrDefault(a => a.ProductCatalogId == input.Id); return(productCatalog.Categories.SelectMany(a => a.Products).Distinct().ToList()); case "ProductCatalogGroup": ProductCatalogGroup productCatalogGroup = ProductCatalogGroup.SingleOrDefault(a => a.ProductCatalogGroupId == input.Id); return (productCatalogGroup.ProductCatalogs.SelectMany(a => a.Categories).SelectMany(a => a.Products). Distinct().ToList()); default: throw new NotImplementedException( "Only Category, ProductCatalog and ProductCatalogGroup are allowed."); } }
public ProductCatalogGroup CatalogGroup(string name, string description, Currency defaultCurrency) { ProductCatalogGroup catalogGroup = _catalogGroups.Value.SingleOrDefault(x => x.Name == name); if (catalogGroup == null) { EmailProfile defaultEmailProfile = _emailProfiles.Value.Select(x => x.Name == "Default" && !x.Deleted).First(); var defaultOrderNumbers = _orderNumbers.Value.Select(x => x.OrderNumberName == "Default" && !x.Deleted).First(); catalogGroup = new ProductCatalogGroup { EmailProfile = defaultEmailProfile, OrderNumberSerie = defaultOrderNumbers }; } catalogGroup.Name = name; catalogGroup.Currency = defaultCurrency; catalogGroup.Description = description; catalogGroup.MemberGroupId = "-1"; catalogGroup.MemberTypeId = "-1"; catalogGroup.Deleted = false; return(catalogGroup); }
private void UpdateHostname(string value, ProductCatalogGroup store) { if (string.IsNullOrEmpty(value)) { store.DomainId = string.Empty; return; } ID id; if (ID.TryParse(value, out id)) { if (id == FieldIds.SystemContent.DefaultHostnameId) { store.DomainId = string.Empty; return; } var domainService = ObjectFactory.Instance.Resolve <IDomainService>(); foreach (var domain in domainService.GetDomains()) { if (domain.SitecoreId() == id) { store.DomainId = domain.DomainId; return; } } return; } _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update host name for store. Could not find Sitecore ID for domain with id: {0}.", value)); }
private void UpdateStoreOrderNumbers(string value, ProductCatalogGroup store) { ID id; if (ID.TryParse(value, out id)) { var orderNumbers = OrderNumberSerie.SingleOrDefault(x => x.Guid == id.Guid); if (orderNumbers == null) { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update order number series for store. Could not find order numbers serie with guid: {0}.", id.Guid)); return; } store.OrderNumberSerie = orderNumbers; } else { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Failed to update order number series for store. Could not find Sitecore ID for order numbers serie with id: {0}.", value)); } }
public void Save(ProductCatalogGroup catalogGroup) { _catalogGroups.Value.Save(catalogGroup); }
public ProductCatalogGroup CatalogGroup(string name, string description, Currency defaultCurrency) { ProductCatalogGroup catalogGroup = _catalogGroups.Value.SingleOrDefault(x => x.Name == name); if (catalogGroup == null) { EmailProfile defaultEmailProfile = _emailProfiles.Value.Select(x => x.Name == "Default" && !x.Deleted).First(); var defaultOrderNumbers = _orderNumbers.Value.Select(x => x.OrderNumberName == "Default" && !x.Deleted).First(); catalogGroup = new ProductCatalogGroup { EmailProfile = defaultEmailProfile, OrderNumberSerie = defaultOrderNumbers }; } catalogGroup.Name = name; catalogGroup.Currency = defaultCurrency; catalogGroup.Description = description; catalogGroup.MemberGroupId = "-1"; catalogGroup.MemberTypeId = "-1"; catalogGroup.Deleted = false; return catalogGroup; }
public ProductCatalog Catalog(string name, ProductCatalogGroup catalogGroup, PriceGroup priceGroup) { var catalog = _catalogs.Value.SingleOrDefault(x => x.Name == name) ?? new ProductCatalog(); catalog.Name = name; catalog.DisplayOnWebSite = false; catalog.ProductCatalogGroup = catalogGroup; catalog.PriceGroup = priceGroup; catalog.Deleted = false; return catalog; }
public void StoreSaved(ProductCatalogGroup store) { Clear(); FireItemSavedEvent(store.Guid); }
private void UpdateStoreValueFor(FieldChange fieldChange, ProductCatalogGroup store, ItemChanges changes) { if (this.ValueDidNotChangeFor(fieldChange)) { return; } //We do NOT handle statistics e.g updated at and updated by this way. Underlying Repositories deals with it. if (this.FieldBelongsToStatistics(fieldChange)) { return; } if (fieldChange.FieldID == FieldIds.Store.CreateCustomersAsMembersFieldId) { store.CreateCustomersAsMembers = (fieldChange.Value == "1"); } else if (fieldChange.FieldID == FieldIds.Store.ProductCatalogGroupIdFieldId) { return; } else if (fieldChange.FieldID == FieldIds.Store.CurrencyFieldId) { UpdateStoreCurrency(store, fieldChange.Value); } else if (fieldChange.FieldID == FieldIds.Store.DescriptionFieldId) { store.Description = fieldChange.Value; } else if (fieldChange.FieldID == FieldIds.Store.EmailProfileFieldId) { UpdateStoreEmailProfile(fieldChange.Value, store); } else if (fieldChange.FieldID == FieldIds.Store.HostNameFieldId) { UpdateHostname(fieldChange.Value, store); } else if (fieldChange.FieldID == FieldIds.Store.MemberGroupFieldId) { UpdateStoreMemberGroup(fieldChange.Value, store); } else if (fieldChange.FieldID == FieldIds.Store.MemberTypeFieldId) { UpdateStoreMemberType(fieldChange.Value, store); } else if (fieldChange.FieldID == FieldIds.Store.NameFieldId) { UpdateStoreName(store, fieldChange.Value, changes); } else if (fieldChange.FieldID == FieldIds.Store.OrderNumberSeriesFieldId) { UpdateStoreOrderNumbers(fieldChange.Value, store); } else if (fieldChange.FieldID == FieldIds.Store.ProductReviewRequiresApprovalFieldId) { store.ProductReviewsRequireApproval = (fieldChange.Value == "1"); } else { _loggingService.Log <ProductCatalogGroupTemplateBuilder>( string.Format("Could not find property: {0} for store: {1}.", fieldChange.Definition.Key, store.Name)); } }