Skip to main content Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Hi everyone,  I'm trying to get a list of page designer pages but had no luck yet. I saw that the dw.content.Content has a page field, that defines if it's a page or not. I was attempting to use the class dw/content/ContentSearchModel to search through content assets and get only the page designer pages. However I always get a count of zero, so none of these searches work.

 

const ContentSearchModel = require("dw/content/ContentSearchModel");

const apiContentSearchModel = new ContentSearchModel();

apiContentSearchModel.setRecursiveFolderSearch(true);

apiContentSearchModel.setFilteredByFolder(false);

apiContentSearchModel.search();

const contentSearchResultIterator = apiContentSearchModel.getContent();

const count = Number(apiContentSearchModel.getCount());

Using apiContentSearchModel.setFolderID() also doesn't work, even if the page designer page is assigned to that folder.

 

Is there a way to do this that works?  Thanks in advance!   #Page Designer@B2C Commerce Developers

7 answers
  1. Jul 29, 2022, 8:28 AM

    Oh, just realizing there were more comments in this thread I didn't see in the first pass. Anyways, currently your only chance of page search is really through the search index. There is no separate functionality that realizes a search outside of the search index. The other option for retrieving pages I would think of would be to either place them into folders (so pick them up via folder traversal) or assign them to categories/products (you can do this for dynamic pages and afterswards retrieve them from categories/products again, see PageMgr.getPageByCategory() and PageMgr.getPageByProducts()).

  2. Jul 29, 2022, 8:12 AM

    @Marcus Lenzneryes I set them to searchable, online wasn't necessary. The content index was reindexed.

    That was my workaround :)  My question now is if there is any other solution that doesn't involve setting it to searchable. Imagining the business doesn't want to do that and that index gets too big. Is there another solution?

  3. Jul 29, 2022, 6:32 AM

    Not sure what else might be going wrong there, but if you take the SFRA code you should have a good starting point (as the content search processes pages there as far as I remember). Aside from that just to be sure - have you set the pages your are looking for to be searchable (see page settings in PD) and online (i.e. hit the publish button) and subsequently reindexed the content index?

  4. Jul 28, 2022, 12:53 PM

    Hi @Florent Benoit, I was able to get a workaround (or maybe this is supposed to be like this). I made my page designer pages searchable and they appeared in the index, which then appeared in my search with the code above + a method call to setFolderID(), this call seems to be mandatory.  I was hoping I could get a list of pages without the index or setting this searchable attribute, but it works for now. Thanks!

0/9000