How to get Catalogue ID based on name?

nhissaria
Is it possible to asset Id of Catalogue item based on name?

Comments

2 comments

  • Comment author
    nhissaria

    Is it possible to asset Id of Catalogue item based on name?

    0
  • Comment author
    William Thompson

    Not directly, however you can query our Catalog API and take 2 different approaches.

    You can query for all items which will return an object you can filter through however you would like. A quick example that I found to work is:

    // Note the catalog variable is not declared here, it is the object returned by our Catalog API when querying for all items. 
    const getCatalogItemByName = function(name) {
     return catalog.products.filter(item => item.name == name)
    };
    
    getCatalogItemByName("Catalog Item Name");
    

    Alternatively, you can get the ID from the catalog item on the platform and query the Catalog API using that ID.

    0

Please sign in to leave a comment.