Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Nielsen 99 posts 619 karma points
    Dec 08, 2014 @ 09:34
    Michael Nielsen
    0

    Cannot publish programmatically in 4.11.10

    Have an issue with a solution with uWebshop and CMSImport.

    Sometimes after Import, we get an server error that says "Trying to load multi-store content without a store". 

    We can solve it by publishing the Store nodes, so an easy fix would be to publish the sote nodes once every day. 

    So I have the code below, but it does not seem to work. I unpublished a node to test it, but it does not get published. 

    So I'm guessing I must be missing something or...?

    using umbraco.cms.businesslogic.web 
    
    foreach(var page in Model.NodeById(1393).Children){
      Document d = new Document(page.Id);
    
        umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(0);
    
        d.Publish(u);
        umbraco.library.UpdateDocumentCache(d.Id);
    
    }
  • Michael Nielsen 99 posts 619 karma points
    Dec 10, 2014 @ 13:11
    Michael Nielsen
    100

    This was an easy fix. 

    The problem was that looping through nodes will of course not give me unpublished nodes, use Document instead. :-)

    This is the working code:

    var stores = new Document(1393);
    foreach(var d in stores.Children){      
        umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(0);
        d.Publish(u);
        umbraco.library.UpdateDocumentCache(d.Id);
    }
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies