示例#1
0
        public void Add_Sunglasses_ProductType()
        {
            var productTypeName = "Sunglasses";
            var filter          = string.Format("name eq '{0}'", productTypeName);

            var productTypeHandler = new MozuDataConnector.Domain.Handlers.ProductTypeHandler();

            var productTypes = productTypeHandler.GetProductTypes(_apiContext.TenantId, _apiContext.SiteId,
                                                                  _apiContext.MasterCatalogId, 0, 20, null, null).Result;

            var existingProductType = productTypes.SingleOrDefault(a => a.Name == productTypeName);

            if (existingProductType == null)
            {
                var productType = new ProductType()
                {
                    Name              = productTypeName,
                    GoodsType         = "Physical",
                    MasterCatalogId   = _apiContext.MasterCatalogId,
                    Options           = new System.Collections.Generic.List <AttributeInProductType>(),
                    Properties        = new System.Collections.Generic.List <AttributeInProductType>(),
                    Extras            = null,
                    IsBaseProductType = false,
                    ProductUsages     = new System.Collections.Generic.List <string>
                    {
                        "Standard",
                        "Configurable",
                        "Bundle",
                        "Component"
                    },
                };

                var newProductType = productTypeHandler.AddProductType(_apiContext.TenantId, _apiContext.SiteId,
                                                                       _apiContext.MasterCatalogId, productType).Result;
            }
        }