Ejemplo n.º 1
0
        public void ExportProductAssets(ICollection <ProductContent> entries)
        {
            if (entries == null ||
                entries.Count == 0)
            {
                return;
            }

            if (!_configuration.ProductAssetsImportUrl.IsValidProductAssetsImportUrl())
            {
                return;
            }

            foreach (var batch in entries
                     .Batch(BatchSize))
            {
                var assets = new Dictionary <string, ICollection <ProductAsset> >(BatchSize);
                foreach (var entry in batch)
                {
                    if (entry.CommerceMediaCollection?.Count == 0)
                    {
                        continue;
                    }

                    assets.Add(
                        entry.Code.SanitizeKey(),
                        _productFactory.BuildKaChingProductAssets(entry).ToArray());
                }
                APIFacade.Post(
                    new { assets },
                    _configuration.ProductAssetsImportUrl);
            }
        }