public bool SaveItem(ITreeNodeContent node, ItemChanges changes)
        {
            if (!changes.HasFieldsChanged)
            {
                return(false);
            }

            var catalog = ProductCatalog.Get(Convert.ToInt32(node.ItemId));

            if (catalog == null)
            {
                var message = string.Format("Product Catalog with id: {0} not found for ITreeNodeContent. ", node.ItemId);
                _loggingService.Debug <ProductCatalogTemplateBuilder>(message);
                throw new InvalidDataException(message);
            }

            foreach (FieldChange change in changes.FieldChanges)
            {
                UpdateCatalogValuesFor(change, catalog);
            }

            ObjectFactory.Instance.Resolve <IPipeline <ProductCatalog> >("SaveProductCatalog").Execute(catalog);

            return(true);
        }
        internal void AddDataFromCatalog(int catalogId, FieldList list, VersionUri version)
        {
            var catalog = ProductCatalog.Get(catalogId);

            if (catalog == null)
            {
                return;
            }

            AddDataFromCatalog(catalog, list, version);
        }
Beispiel #3
0
        private void PopulateCacheWithChildrensFieldLists(CatalogSitecoreItem catalogItem)
        {
            if (catalogItem == null)
            {
                return;
            }
            if (AreAllChildrenPresent(catalogItem))
            {
                return;
            }

            int catalogId = int.Parse(catalogItem.Node.ItemId);

            var catalog = ProductCatalog.Get(catalogId);

            var repository = ObjectFactory.Instance.Resolve <IRepository <Category> >();
            var categories = repository.Select(new CategoriesInCatalogQuery(catalog)).ToList();

            foreach (var category in categories)
            {
                var id = new ID(category.Guid);
                if (!_sitecoreItems.ContainsKey(id))
                {
                    continue;                                                  // This can happen, if the parent of this category was deleted.
                }
                var childItem = _sitecoreItems[id] as ContentNodeSitecoreItem;
                if (childItem == null)
                {
                    throw new Exception("Could not find category in list of items. " + category.Guid);
                }

                foreach (VersionUri version in GetItemVersions())
                {
                    var list = new FieldList();
                    list.SafeAdd(FieldIDs.Icon, childItem.GetIcon());
                    list.SafeAdd(FieldIDs.Sortorder, childItem.Node.SortOrder.ToString());
                    list.SafeAdd(FieldIDs.DisplayName, childItem.Node.Name);
                    _categoryValueProvider.AddDataFromCategory(list, version, category);

                    //_log.Log<ContentNodeDataProvider>(string.Format("Storing: {0}", category.Guid));
                    Cache.Store(new ID(category.Guid), version, list);
                }
            }
        }
 private void SetContextForCatalog(int catalogId, ICatalogContext catalogContext)
 {
     catalogContext.CurrentCatalog = ProductCatalog.Get(catalogId);
 }
 private void SetContextForProduct(int catalogId, int productId, ICatalogContext catalogContext)
 {
     catalogContext.CurrentCatalog = ProductCatalog.Get(catalogId);
     catalogContext.CurrentProduct = Product.Get(productId);
 }