Copied to clipboard

Flag this post as spam?

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


  • Niels Henriksen 73 posts 276 karma points
    May 02, 2020 @ 10:59
    Niels Henriksen
    0

    How to get all unpublished nodes?

    I have made a mistake on a customers websitet where I need to import 15000 products to different categories.

    The import is working fine but now is the problem that we need to remove all unpublished nodes of a specific type.

    I can get all published nodes like this

    var node = Umbraco.Content(1056);
    var products = node.DescendantsOfType("product");
    

    But I cant see the unpublished like that - any ideas?

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    May 03, 2020 @ 18:46
    Søren Kottal
    0

    Hi Niels

    For unpublished nodes, you have to go either via Examine and the InternalIndex, or loop through nodes using the ContentService.

  • Malthe Petersen 68 posts 383 karma points c-trib
    May 03, 2020 @ 18:50
    Malthe Petersen
    0

    Hi Niels.

    The UmbracoContext.Content.GetById, takes a bool of preview so you should be able to get unpublished nodes with that.

    Hope it helps a little and you can use it.

    Regards Malthe

Please Sign in or register to post replies

Write your reply to:

Draft