Salesforce Commerce Cloud 开发入门

Salesforce Commerce Cloud 是付费的,没找到免费试用的 sandbox 。

环境搭建请参考 Let’s Develop with Salesforce Commerce Cloud — Part 1: Setting Up Your Development Environment

然后 Let’s Develop with Salesforce Commerce Cloud — Part 2: Creating a Development Storefront

下面我们自己写个 helloworld

在 sample_controllers / cartridge / controllers 下新建 HelloWorld.js

/**
* Description of the Controller and the logic it provides
*
* @module  controllers/HelloWorld
*/

'use strict';

/*
* A hello world controller. This file is in cartridge/controllers folder
*
* @module controllers/HelloWord This is used only to generate JSDoc
*/
exports.Start = function() {
    response.setContentType('text/html');
    response.getWriter().println('Hello World!');
};

exports.Start.public = true; //Start becomes the start node

下面我们访问 https://sandboxdomain/on/demandware.store/Sites-SiteGenesis-Site/default/HelloWorld-Start

下面带上 ISML 模板

在 controllers 下新建一个 HelloWorld2.js

/**
* Description of the Controller and the logic it provides
*
* @module  controllers/HelloWorld2
*/

'use strict';

exports.Start = function(){
     var CurrentHttpParameterMap = request.httpParameterMap;
     var myParameter=CurrentHttpParameterMap.param;
//     response.setContentType('text/html');
//     response.getWriter().print(myParameter);

     var ISML = require('dw/template/ISML');
     ISML.renderTemplate('helloworld.isml', {myParameteronISML:myParameter});

};
exports.Start.public = true;

然后在 sample_controllers / cartridge / templates / default 下创建 helloworld.isml

<!--- TEMPLATENAME: hello.isml --->
<html>
    <head>
        <title>Hallo Tag</title>
    </head>
    <body>
        Hello ${pdict.myParameteronISML}
    </body>
</html>

下面我们访问 https://sandboxdomain/on/demandware.store/Sites-SiteGenesis-Site/default/HelloWorld2-Start?param=Jack

发表评论

电子邮件地址不会被公开。 必填项已用*标注