Copied to clipboard

Flag this post as spam?

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


  • Brad Bisgard 4 posts 74 karma points
    Jan 08, 2019 @ 22:50
    Brad Bisgard
    0

    Get List of Content Based on UDI search

    Hi! Spent a lot of time searching for this...

    I have a product page, and am using a Umbraco.ContentPicker2 for selecting a brand as one of the properties. The data is stored as a UDI, i.e. umb://document/fa06e4e2418545b7afe3694e1f8e7724

    Basically, I am looking to create a page with the brand, and all of the products that have the matching UDI in the product record.

    Logic being something like

    Select [product] where DocumentTypeAlias == "productDetail" && getproperty("productBrand") == [thisUDI]
    

    Extremely sloppy pseudo code, but hope the idea is clear?

    Thanks!

  • Alex Skrypnyk 5072 posts 18434 karma points MVP 2x admin c-trib
    Jan 09, 2019 @ 12:57
    Alex Skrypnyk
    0

    Hi Brad

    You can use UmbracoHelper for getting nodes you need, have a look - https://our.umbraco.com/documentation/reference/querying/umbracohelper/

    Be aware with using Descendants method, check out common pitfalls - https://our.umbraco.com/documentation/reference/Common-Pitfalls/

    If you need products directly from the database, use content Service - https://our.umbraco.com/documentation/reference/management/services/contentservice/ This method is pretty slow, but if you need the data from the database this is the only way, I don't recommend to use SQL requests.

    Try to show us the code you have and structure - we will help you with all community!

    Thanks,

    Alex

  • Brad Bisgard 4 posts 74 karma points
    Jan 09, 2019 @ 15:58
    Brad Bisgard
    0

    Hi Alex, thank you. I am a reasonably accomplished Umbraco dev. My question is more about UDI, not overall querying.

    Anyone have an example of how to query a certain docType with property data stored as UDI, getting all those records?

    Maybe it is just that I need to know: would I compare them string on string? Seems like a massive step back vs an Id, so there must certainly be something I am missing.

    Thanks!

  • Mark Bowser 255 posts 840 karma points c-trib
    Jan 09, 2019 @ 16:32
    Mark Bowser
    0

    So your goal is to query umbraco for all nodes that pick other nodes by UDI? Is this a one-off report you need to generate? Or do you actually need Umbraco to be able to run this query?

  • Brad Bisgard 4 posts 74 karma points
    Jan 09, 2019 @ 16:54
    Brad Bisgard
    0

    Hi Mark, thank for taking a look here. I do want to query on it, yes. The example is I have a doctype (product) that uses the picker to select another doctype (brand). Umbraco stores as a UDI.

    When I am on the brand landing page, I want to reverse the lookup and get all the products with that brand UDI. It would be a real-time page, so like to generate from content/ cache.

  • Brad Bisgard 4 posts 74 karma points
    Jan 10, 2019 @ 23:34
    Brad Bisgard
    0

    Hello all: checking in if anyone in Umbraco-world has experience querying on data stored as umb/UDI.

Please Sign in or register to post replies

Write your reply to:

Draft