{ Hello Magento 2 }

解决 Magento 2 应用问题,更注重深度挖掘。(ง •̀_•́)ง

0%

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* 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

1
2
3
4
5
6
7
8
9
<!--- 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