public ID GetTemplateId(ITreeNodeContent node)
        {
            var productDefinitionId = GetProductDefinitionIdFromProductId(int.Parse(node.ItemId));
            ID  productTemplateId   = _dynamicVariantTemplate.GetTemplateId(productDefinitionId);

            return(productTemplateId ?? FieldIds.Product.ProductBaseTemplateId);
        }
        public bool SaveItem(ITreeNodeContent node, ItemChanges changes)
        {
            if (!changes.HasFieldsChanged)
            {
                return(false);
            }

            var productVariant = Product.Get(Convert.ToInt32(node.ItemId));

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

            foreach (FieldChange fieldChange in changes.FieldChanges)
            {
                UpdateVariantValue(fieldChange, productVariant, changes.Item);
            }

            ObjectFactory.Instance.Resolve <IPipeline <Product> >("SaveProduct").Execute(productVariant.ParentProduct);

            return(true);
        }
        public ContentNodeSitecoreItem Create(ITreeNodeContent node, ID parentId)
        {
            if (!node.ItemGuid.HasValue)
            {
                throw new InvalidOperationException("Create called with node without Guid.");
            }

            var fieldValueProvider = _fieldValueProviders.SingleOrDefault(x => x.Supports(node));

            if (fieldValueProvider != null)
            {
                if (node.NodeType == Constants.DataProvider.NodeType.ProductCategory)
                {
                    return(new CategorySitecoreItem(node, new ID(node.ItemGuid.Value), parentId, fieldValueProvider));
                }

                if (node.NodeType == Constants.DataProvider.NodeType.ProductCatalog)
                {
                    return(new CatalogSitecoreItem(node, new ID(node.ItemGuid.Value), parentId, fieldValueProvider));
                }

                return(new ContentNodeSitecoreItem(node, new ID(node.ItemGuid.Value), parentId, fieldValueProvider));
            }

            // Default. No support for this node.
            throw new InvalidOperationException("Create could not find a field value provider supporting the nodetype: " + node.NodeType);
        }
        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.Log <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);
        }
예제 #5
0
        public bool SaveItem(ITreeNodeContent node, ItemChanges changes)
        {
            if (!changes.HasFieldsChanged)
            {
                return(false);
            }

            var category = Category.Get(int.Parse(node.ItemId));

            if (category == null)
            {
                string message = string.Format("Category with id: {0} not found for ITreeNodeContent.", node.ItemId);
                _loggingService.Debug <ProductCatalogGroupTemplateBuilder>(message);
                throw new InvalidDataException(message);
            }

            foreach (FieldChange fieldChange in changes.FieldChanges)
            {
                UpdateStoreValueFor(fieldChange, category, changes.Item);
            }

            ObjectFactory.Instance.Resolve <IPipeline <Category> >("SaveCategory").Execute(category);

            return(true);
        }
예제 #6
0
        public ID GetTemplateId(ITreeNodeContent node)
        {
            var mapper = ObjectFactory.Instance.Resolve <ICategoryIdToCategoryDefinitionIdMapperService>();

            var categoryDefinitionId = mapper.MapToCategoryDefinitionId(int.Parse(node.ItemId));

            return(_dynamicCategoryTemplate.GetTemplateId(categoryDefinitionId));
        }
        private void AddFieldValuesForProductVariant(ITreeNodeContent node, FieldList list, VersionUri version)
        {
            var product = ReadProductFromDatabase(int.Parse(node.ItemId));

            if (product != null)
            {
                AddFieldValuesForProductVariant(product, list, version);
            }
        }
 public void AddFieldValues(ITreeNodeContent node, FieldList list, VersionUri version)
 {
     switch (node.NodeType)
     {
     case "productVariant":
         AddFieldValuesForProductVariant(node, list, version);
         break;
     }
 }
        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);
            }
        }
        public ContentNodeSitecoreItem(ITreeNodeContent node, ID id, ITemplateFieldValueProvider fieldValueProvider)
        {
            Node = node;
            FieldValueProvider = fieldValueProvider;
            Id = id;

            var templateId = FieldValueProvider.GetTemplateId(node);

            SetItemDefinition(Id, node.Name, templateId, ID.Null);
            ((ICacheable)ItemDefinition).Cacheable = SitecoreConstants.EnableCacheable;
        }
        public ID GetTemplateId(ITreeNodeContent node)
        {
            switch (node.NodeType)
            {
            case Constants.DataProvider.NodeType.ProductCatalog:
                return(FieldIds.Catalog.ProductCatalogTemplateId);

            default:
                return(null);
            }
        }
        public bool Supports(ITreeNodeContent node)
        {
            switch (node.NodeType)
            {
            case Constants.DataProvider.NodeType.ProductCatalog:
                return(true);

            default:
                return(false);
            }
        }
        private string GetEditorPathForNode(ITreeNodeContent node)
        {
            string convertedUrl;

            if (_urlConverter.TryConvert(node, out convertedUrl))
            {
                if (string.IsNullOrEmpty(convertedUrl))
                {
                    return(string.Empty);
                }
                convertedUrl = "/sitecore modules/Shell/" + convertedUrl;
                return(convertedUrl);
            }

            return(string.Empty);
        }
        public virtual NodeItem Convert(ITreeNodeContent node)
        {
            var item = _sitecoreContext.DatabaseForContent.GetItem(ID.Parse(node.ItemId));

            return(new NodeItem()
            {
                Id = item.ID.Guid.ToString(),
                Name = item.DisplayName,
                NodeType = node.NodeType,
                Icon = "/~/icon/" + item.Appearance.Icon,
                HasChildren = item.HasChildren,
                AutoLoad = node.AutoLoad,
                DimNode = false,
                Url = _contentService.GetContent(item.ID.Guid.ToString()).Url
            });
        }
        public FieldList GetFieldList(ITreeNodeContent node, VersionUri version)
        {
            var list = new FieldList();

            list.SafeAdd(FieldIDs.Icon, GetIconForNode(node));

            var builder = _templateBuilders.FirstOrDefault(x => x.Supports(node));

            if (builder == null)
            {
                list.SafeAdd(AppearanceEditorFieldId, GetEditorPathForNode(node));
            }
            else
            {
                builder.AddFieldValues(node, list, version);
            }
            return(list);
        }
 public virtual NodeItem Convert(ITreeNodeContent node)
 {
     return(CreateNodeFromItem(_sitecoreContext.DatabaseForContent.GetItem(ID.Parse(node.ItemId)), node.AutoLoad, node.NodeType));
 }
예제 #17
0
        public void AddFieldValues(ITreeNodeContent node, FieldList list, VersionUri version)
        {
            int categoryId = int.Parse(node.ItemId);

            AddDataFromCategory(categoryId, list, version);
        }
        public bool TryConvert(ITreeNodeContent treeNodeContent, out string url)
        {
            url = string.Empty;

            switch (treeNodeContent.NodeType)
            {
            case "productCatalogGroup":
                url = "ucommerce/catalog/editproductcataloggroup.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "productCatalog":
                url = "ucommerce/catalog/editproductcatalog.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "productCategory":
                url = "ucommerce/catalog/editcategory.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "product":
                url = "ucommerce/catalog/editproduct.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "catalogSearch":
                url = "ucommerce/catalog/searchproduct.aspx?ucid=-1"; break;

            case "orderGroup":
                url = "ucommerce/orders/viewordergroup.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "order":
                url = "ucommerce/orders/editorder.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "ordersSearch":
                url = "ucommerce/orders/search.aspx?ucid=-1"; break;

            case "campaign":
                url = "ucommerce/marketing/editcampaign.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "campaignItem":
                url = "ucommerce/marketing/editcampaignitem.aspx?ucid=" + treeNodeContent.ItemId + "&parent=" + treeNodeContent.ItemContextId; break;

            case "productanalytics":
                url = "ucommerce/analytics/ProductAnalytics.aspx"; break;

            case "orderanalytics":
                url = "ucommerce/analytics/OrderAnalytics.aspx"; break;

            case "settingsCatalogPriceGroup":
                url = "ucommerce/settings/catalog/editpricegroup.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsCatalogProductRelation":
                url = "ucommerce/settings/catalog/editproductrelationtype.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "shippingMethod":
                url = "ucommerce/settings/orders/editshippingmethod.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "paymentMethod":
                url = "ucommerce/settings/orders/editpaymentmethod.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "country":
                url = "ucommerce/settings/orders/editCountry.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "currency":
                url = "ucommerce/settings/orders/editCurrency.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "orderNumber":
                url = "ucommerce/settings/orders/editOrderNumberSerie.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsEmailProfiles":
                url = "ucommerce/settings/email/profiles"; break;

            case "settingsEmailTypes":
                url = "ucommerce/settings/email/types"; break;

            case "settingsEmailProfile":
                url = "ucommerce/settings/email/editemailProfile.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsEmailProfileType":
                url = "ucommerce/settings/email/editEmailProfileType.aspx?ucid=" + treeNodeContent.ItemId + "&parent=" + treeNodeContent.ItemContextId; break;

            case "settingsEmailType":
                url = "ucommerce/settings/email/editemailtype.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsDefinitionsProductDefinition":
                url = "ucommerce/settings/definitions/editproductdefinition.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsDefinitionsProductDefinitionField":
                url = "ucommerce/settings/definitions/editproductdefinitionfield.aspx?ucid=" + treeNodeContent.ItemId + "&parent=" + treeNodeContent.ItemContextId; break;

            case "settingsDefinitionsDynamicDefinition":
                url = "ucommerce/settings/definitions/editdefinition.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsDefinitionsDynamicDefinitionField":
                url = "ucommerce/settings/definitions/editdefinitionfield.aspx?ucid=" + treeNodeContent.ItemId + "&parent=" + treeNodeContent.ItemContextId; break;

            case "settingsDefinitionsDataType":
                url = "ucommerce/settings/definitions/editdatatype.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsDefinitionsDataTypeEnum":
                url = "ucommerce/settings/definitions/editDataTypeEnum.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsSecurityUser":
                url = "ucommerce/settings/security/EditUserAccess.aspx?ucid=" + treeNodeContent.ItemId; break;

            case "settingsSecurityUserGroup":
                url = "ucommerce/settings/security/EditUserGroupAccess.aspx?ucid=" + treeNodeContent.ItemId; break;

            default:
                return(false);
            }

            return(true);
        }
예제 #19
0
 public bool Supports(ITreeNodeContent node)
 {
     return(node.NodeType == Constants.DataProvider.NodeType.ProductCategory);
 }
예제 #20
0
 public CatalogSitecoreItem(ITreeNodeContent node, ID id, ITemplateFieldValueProvider fieldValueProvider) : base(node, id, fieldValueProvider)
 {
 }
 public ID GetTemplateId(ITreeNodeContent node)
 {
     return(BaseProductCatalogGroupTemplate.ProductCatalogGroupBaseTemplateId);
 }
 private string GetIconForNode(ITreeNodeContent node)
 {
     return("/sitecore modules/Shell/ucommerce/shell/Content/Images/ui/" + node.Icon);
 }
 public ContentNodeSitecoreItem(ITreeNodeContent node, ID id, ID parentId, ITemplateFieldValueProvider fieldValueProvider) : this(node, id, fieldValueProvider)
 {
     ParentId = parentId;
 }
 public bool Supports(ITreeNodeContent node)
 {
     return(node.NodeType == "productCatalogGroup");
 }
 public ID GetTemplateId(ITreeNodeContent node)
 {
     return(FieldIds.Common.UCommerceStoresTemplateId);
 }
 public void AddFieldValues(ITreeNodeContent node, FieldList list, VersionUri version)
 {
     list.SafeAdd(FieldIDs.Security, ObjectFactory.Instance.Resolve <ISecurityService>().GetSecurityStringForNodes());
 }
 public bool Supports(ITreeNodeContent node)
 {
     return(node.NodeType == "productVariant");
 }
 public bool SaveItem(ITreeNodeContent node, ItemChanges changes)
 {
     return(false);
 }
 public bool Supports(ITreeNodeContent node)
 {
     return(node.NodeType == Constants.DataProvider.NodeType.Catalog);
 }