Add to Taxonomy on Publish

Posted by Community Admin on 03-Aug-2018 15:55

Add to Taxonomy on Publish

All Replies

Posted by Community Admin on 31-Aug-2011 00:00

Hello, we're working with the products module sample right now and want to do some processing on the publishing of a product module. For the sake of simplicity we basically want to add the name of the newly created product to the Colors taxonomy when someone publishes a new product (not really how we want it to work but you get the idea).

We got some initial code from a support ticket that said we have to create a Global.asax file and subscribe to the ProductsManager_Executed event in there. Is this the only way to do what we're trying to accomplish here? It just seems like it defeats the purpose of keeping a custom module self contained. I would like to just be able to install a module and not have to worry about creating a global.asax file if possible.

If there is another way, what it is? I've tried adding the add to taxonomy code in a few places and it just doesn't work as expected. If I add it in the CreateProduct(Guid id) of the productManager.cs file it doesn't work. If I add it the same to the openaccessprovider.cs it adds the product name three times to the taxonomy.

What are my options here?

Thanks

Posted by Community Admin on 02-Sep-2011 00:00

Hello. Any one have any advice for adding a product name to the colors taxonomy on first publish that doesn't use the Global.asax solution?

Posted by Community Admin on 03-Sep-2011 00:00

Hello Kmac,

You can modify the OpenAccessProvider class and override the following method:

protected virtual TContent ExecuteOnPublish<TContent>(TContent masterItem, Action<TContent, TContent> copy, TContent liveItem) where TContent : Content, IContentLifecycle

There you must call the base implementation and then you can add your taxonomy. You could first check if such taxonomy entry does not exist.

Greetings,
Lubomir Velkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed