LearningSalesForceCommerceC.../the_learning_cartridge/cartridge/controllers/Demo.js

44 lines
1.0 KiB
JavaScript

'use strict';
var server = require('server');
var cache = require('*/cartridge/scripts/middleware/cache');
var ProductFactory = require('*/cartridge/scripts/factories/product');
var StoreMgr = require('dw/catalog/StoreMgr');
var Logger = require('dw/system/Logger');
var log = Logger.getLogger('DevTest','Cyborg');
server.get('Start',
cache.applyShortPromotionSensitiveCache,
function (req, res, next) {
var params = {'pid':'sony-kdl-55xbr8M'};
var productModel = ProductFactory.get(params);
var storeModel = StoreMgr.getStore('store1');
var viewData = {
'productModel': productModel,
'storeModel': storeModel
};
log.debug('Loaded demo page');
res.render('demo', viewData);
next();
});
server.get('Designer', function (req, res, next) {
let PageMgr = require('dw/experience/PageMgr');
let page = PageMgr.getPage('testpage');
log.warn('Loaded page designer page');
res.print(PageMgr.renderPage(page.ID, 'testpage'));
next();
});
module.exports = server.exports();