3 Replies Latest reply on Oct 7, 2019 7:50 AM by Darren Wrigley

    Get all object related to a custom attribute using Edc rest api

    Bhupendra Baraiya Seasoned Veteran

      We have attached a custom attribute to each product inside Edc.

      Now we want to let user search by value of the custom attribute and get all the objects which has that value for that custom attribute.

      Fr e.g We will show value as Commercial (custom attribute name is Area) in UI when user clicks on it we need to make an api call to Edc that will return all the object that has custom attribute Area and value as Commercial .

      Plus is there a way to get a value of a custom attribute, because first we will show value of selected custom attribute to User in UI once he clicks on it we will make an call to get all objects related to that value of custom attribute

        • 1. Re: Get all object related to a custom attribute using Edc rest api
          Darren Wrigley Guru

          to get all objects that have an attribute value (custom or out-of-box attribute), you just need to search only in that attribtute.

           

          for custom attributes - you need to use the attribute id (not label) this will start with com.infa.appmodels.ldm.

           

          example:  in my test system i have a custom attribute named Load Frequency.  the id of that attribute is:

          com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d

          to find for any item with a specific value for that field - using the q parameter:-

          com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d:Monthly

          of if you just want to find any objects that have any value in the custom attribute

          com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d:*

          • 2. Re: Get all object related to a custom attribute using Edc rest api
            Bhupendra Baraiya Seasoned Veteran

            Thanks Darren

             

            We first want to display all values of a custom attribute and when User clicks on any of them we want to show all the products having that value

            I am clear on how can I get all objects having a particular value using below approach

            1. com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d:Monthly

             

            But I don't how can I display all values of an custom attribute

             

            Let's say com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d custom attribute has  4 different value across attached to different object, how can I get those 4 values


            • 3. Re: Get all object related to a custom attribute using Edc rest api
              Darren Wrigley Guru

              you can add a facet for the custom attribute(s) that you want to use - for the /1/ version of search - that is done using facet.field.

              e.g

              http://<catalog server>:9085/access/1/catalog/data/search?q=*&offset=0&pageSize=1&hl=false&related=false&rootto=false&facet.field=core.classType&facet.field=core.resourceType&facet.field=core.resourceName&facet.field=com.infa.appmodels.ldm.LDM_3aae3e6f_e59f_4780_867b_7f0e193f9f7d