Closed zero-luo closed 2 years ago
Hello, this code works for us: `var PageMgr = require('dw/experience/PageMgr'); var CatalogMgr = require('dw/catalog/CatalogMgr');
/**
Serialized one or more page designer pages into JSON */ function serialize() { // construct JSON Array by hand, as PD streams on response which we need to do as well. response.writer.print('['); if (request.httpParameterMap.pageIds.submitted) { var pageIds = request.httpParameterMap.pageIds.stringValue.split(','); pageIds.forEach((pageId, index, all) => { response.writer.print(PageMgr.serializePage(pageId, null)); if (index !== all.length - 1) { response.writer.print(','); } }); }
if (request.httpParameterMap.aspect.submitted && request.httpParameterMap.category.submitted) { var category = CatalogMgr.getCategory(request.httpParameterMap.category.stringValue); var page = PageMgr.getPage(category, true, request.httpParameterMap.aspect.stringValue); if (page) { response.writer.print(PageMgr.serializePage(page.ID, null)); } }
response.addHttpHeader('Content-Type', 'application/json'); response.writer.print(']'); }
serialize.public = true; exports.Serialize = serialize;`
And you can call it: PageDesigner-Serialize?pageIds=homepage-example
@petarm
OH MAN!
We used the method you provided and finally got the PageDesigner json data;
Thank you very much;
We want to use PWA kit to refactor the website; but we now have a problem, OCAPI does not provide an interface to get the content of Page designer.
We tried to use the PageMgr.serializePage(page.ID, null) method, but found an error
Can't compile script '[DEBUGGER EXPR: ]'
wainclude url="/on/demandware.store/Sites-xxx-xxx-Site/en/SYSTEMPage-Include?cid=homepage¶ms=%7b%22custom%22%3a%22%22%2c%22aspect_attributes%22%3anull%7d&ot=JSON"
The existing website uses the SFRA framework, and the home page of the website about us and the FAQ page are all created using Page designer, and customers have been using Page designer to manage and maintain pages. We can't abandon Page designer.
Is there any way to solve the compatibility problem between PWA kit and Page designer