コード例 #1
0
        public void NodeUpdated(CatalogContentUpdateEventArgs e)
        {
            Logger.Debug("NodeUpdated raised.");

            var configuration = KachingConfiguration.Instance;

            IEnumerable <ContentReference> contentLinks = GetContentLinks(e);

            NodeContent[] nodes = _contentLoader.GetItems(contentLinks, CultureInfo.InvariantCulture)
                                  .OfType <NodeContent>()
                                  .ToArray();

            // If this event was triggered by a move, re-export the complete category structure.
            if (e.HasChangedParent)
            {
                _categoryExportService.StartFullCategoryExport(
                    configuration.TagsImportUrl,
                    configuration.FoldersImportUrl);
            }

            foreach (NodeContent node in nodes)
            {
                _productExportService.ExportChildProducts(node);
            }
        }
コード例 #2
0
        private void OnCreatedContent(object sender, ContentEventArgs e)
        {
            Logger.Debug("OnCreatedContent raised.");

            if (!(e is CopyContentEventArgs))
            {
                // Return now if the was anything other than a copy action.
                return;
            }

            ContentReference newContentLink = e.ContentLink;

            if (ContentReference.IsNullOrEmpty(newContentLink) ||
                newContentLink.ProviderName != ReferenceConverter.CatalogProviderKey ||
                !_contentLoader.TryGet(newContentLink, CultureInfo.InvariantCulture, out CatalogContentBase catalogContentBase))
            {
                Logger.Debug("Copied content is not catalog content.");
                return;
            }

            switch (catalogContentBase)
            {
            case EntryContentBase entryContent:
                ICollection <ProductContent> products = GetProductsAffected(entryContent);

                foreach (ProductContent product in products)
                {
                    _productExportService.ExportProduct(product, null);
                }

                _productExportService.ExportProductAssets(products);
                _productExportService.ExportProductRecommendations(products, null);

                break;

            case NodeContent _:
                // No need to export child entries on a copy/duplicate action, as there will not be any.
                // Only re-publish the category structure.
                _categoryExportService.StartFullCategoryExport();
                break;
            }
        }