Пример #1
0
        public IEnumerable <PropertyData> GetVariantVsfProperties(ContentReference variantReference)
        {
            var key = variantReference.ID.ToString();

            var cachedVariants = (IEnumerable <PropertyData>)VariantsCache.Get(key);

            if (cachedVariants != null)
            {
                return(cachedVariants);
            }

            var variantVsfProperties = _contentLoaderWrapper.GetVariantVsfProperties(variantReference);

            VariantsCache.Add(new CacheItem(key, variantVsfProperties), new CacheItemPolicy
            {
                SlidingExpiration = TimeSpan.FromSeconds(60)
            });

            return(variantVsfProperties);
        }
        public void ReadProperties(ProductContent product)
        {
            var variants = product.GetVariants();

            foreach (var variant in variants)
            {
                var variantProperties = _contentLoaderWrapper.GetVariantVsfProperties(variant);
                foreach (var variantProperty in variantProperties)
                {
                    if (variantProperty.Value == null)
                    {
                        continue;
                    }

                    var existingProperty = _epiContentProperties.FirstOrDefault(x => x.Id == variantProperty.PropertyDefinitionID);

                    if (existingProperty == null)
                    {
                        _epiContentProperties.Add(new EpiContentProperty
                        {
                            Name   = variantProperty.Name,
                            Id     = variantProperty.PropertyDefinitionID,
                            Values = new List <string>()
                            {
                                variantProperty.Value.ToString()
                            }
                        });
                    }
                    else
                    {
                        if (!existingProperty.Values.Contains(variantProperty.Value))
                        {
                            existingProperty.Values.Add(variantProperty.Value.ToString());
                        }
                    }
                }
            }
        }