private DataTypeEnum GenerateColourDataTypeEnum(string colour, DataType parentDataType)
        {
            var dataTypeEnum = DataTypeEnum.SingleOrDefault(x => x.Value == colour && x.DataType.DataTypeId == parentDataType.DataTypeId) ?? new DataTypeEnumFactory().NewWithDefaults(colour);

            dataTypeEnum.Deleted  = false;
            dataTypeEnum.DataType = DataType.Get(parentDataType.DataTypeId);
            dataTypeEnum.Save();

            GenericHelpers.DoForEachCulture(language =>
            {
                if (dataTypeEnum.GetDescription(language) == null)
                {
                    dataTypeEnum.AddDescription(new DataTypeEnumDescription {
                        CultureCode = language, DisplayName = colour, Description = colour
                    });
                }
            });

            return(dataTypeEnum);
        }
        private static Category CreateCategory(ProductCatalog catalog, string name)
        {
            var definition = Definition.SingleOrDefault(d => d.Name == "Default Category Definition");
            var category   = Category.SingleOrDefault(c => c.Name == name) ?? new CategoryFactory().NewWithDefaults(catalog, definition, name);

            category.DisplayOnSite = true;

            GenericHelpers.DoForEachCulture(language =>
            {
                if (category.GetDescription(language) == null)
                {
                    category.AddCategoryDescription(new CategoryDescription()
                    {
                        CultureCode = language, DisplayName = name
                    });
                }
            });

            category.Save();
            return(category);
        }
        private Product CreateProductOnCategory(Category category, ProductDefinition productDefinition, string sku, string name, decimal price, string shortDescription = "", string longDescription = "")
        {
            var product = CreateBaseProduct(productDefinition, sku, null, name);

            GenericHelpers.DoForEachCulture(
                language =>
            {
                if (!product.HasDescription(language))
                {
                    product.AddProductDescription(new ProductDescription()
                    {
                        CultureCode      = language,
                        DisplayName      = name,
                        ShortDescription = shortDescription,
                        LongDescription  = longDescription
                    });
                }
            });

            Type priceGroupPriceType = Type.GetType("UCommerce.EntitiesV2.PriceGroupPrice, Ucommerce");

            if (priceGroupPriceType != null)
            {
                CreatePriceGroupPricesForProduct(category, price, priceGroupPriceType, product);
            }
            else
            {
                CreateProductPricesForProduct(category, price, product);
            }

            // uCommerce checks whether the product already exists in the create
            // when creating the new relation.
            product.AddCategory(category, 0);

            product.Save();

            return(product);
        }