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);
        }
Beispiel #2
0
        private PriceGroup CreatePriceGroup(string name, Currency currency, decimal vatRate)
        {
            var priceGroup = PriceGroup.SingleOrDefault(c => c.Name == name) ?? new PriceGroupFactory().NewWithDefaults(name);

            priceGroup.Name     = name;
            priceGroup.Currency = currency;
            priceGroup.VATRate  = vatRate;
            priceGroup.Deleted  = false;
            priceGroup.Save();

            return(priceGroup);
        }
        private void UpdatePriceGroup(FieldChange fieldChange, ProductCatalog catalog)
        {
            ID id;

            if (ID.TryParse(fieldChange.Value, out id))
            {
                var priceGroup = PriceGroup.SingleOrDefault(x => x.Guid == id.Guid);

                if (priceGroup == null)
                {
                    _loggingService.Debug <ProductCatalogGroupTemplateBuilder>(
                        string.Format("Failed to update price group for catalog. Could not find price group with guid: {0}.", id.Guid));
                    return;
                }
                catalog.UpdatePriceGroup(priceGroup);
            }
            else
            {
                _loggingService.Debug <ProductCatalogGroupTemplateBuilder>(
                    string.Format("Failed to update price group for catalog. Could not find Sitecore ID for price group with id: {0}.", fieldChange.Value));
            }
        }