More in this section

Forums / General Discussions / Add to Taxonomy on Publish

Add to Taxonomy on Publish

3 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    31 Aug 2011
    Link to this post
    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
  2. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    02 Sep 2011
    Link to this post
    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?
  3. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    03 Sep 2011
    Link to this post
    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 >>

3 posts, 0 answered