在 Kentico 中创建多个站点?
Creating more than one site in Kentico?
我打算使用 Kentico 创建多个商店(网站)并将每个商店的用户分配给 add/modify/delete 他的产品,我已经创建了 2 家商店,第一个的域名为 localhost:8080第二个是 storeone。localhost:8080 正如 Kentico Doc URL 中的文档所述,我可以毫无问题地打开第一个站点,但是当我尝试切换到第二个站点时,它给了我 错误请求 - 无效主机名 .. 任何人都可以帮助我吗? .. 如果有人帮助我了解如何使用 Kentico API 提取产品数据,我将不胜感激,因为文档仅向我提供来自数据库的 updating/modifying/removing 数据,我想知道如何显示它带有附件,例如我上传的图像 pdf。
最好的方法是使用两个不同的端口。这样做的原因是 IIS 默认绑定到端口 80。所以我要做的是将一个站点保留在 80,然后在 2 处做另一个。在 IIS 中进行这些绑定,然后转到 Kentico 并将您的第二个站点添加到 localhost:2 与 :8080。端口号有冲突。 Kentico 和 IIS 是 "confused",不知道该服务哪一个。它使用同一端口的唯一方法是在 Kentico 中启动和停止站点。
Brenden 是正确的 - 同一域中不能有 2 个站点 运行。您需要做的是配置IIS bindings。我经常做的是配置主机文件 (C:\Windows\System32\drivers\etc) 并添加更多规则,例如:
127.0.0.1 localhost2
127.0.0.1 localhost3
然后我可以使用将我的 Kentico 站点绑定到这些域。不要忘记在 Kentico -> Sites app.
中更改域名
关于你的第二个问题:
这取决于您是只想获取 SKUInfo 对象还是存储自定义数据(页面类型字段)的页面对象。如果您只需要 SKUInfo,您可以使用类似的东西:
// gets only corresponding SKU Info object
var singleProduct = SKUInfoProvider.GetSKUInfo(1); // SKUID from COM_SKU table
if (singleProduct != null)
{
var name = singleProduct.SKUName;
var price = singleProduct.SKUPrice;
}
如果您需要获得包含所有自定义字段的产品,您需要像使用任何其他页面一样使用页面 API。一个简单的例子:
// gets sku with all custom properties
var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
var singleProduct = tree.SelectSingleDocument(2); // DocumentID from CMS_Document table
if (singleProduct != null)
{
// work with product
}
// or for multiple products
var products = tree.SelectNodes("custom.myProductType");
foreach (var product in products)
{
// work with products/pages
}
为了检索页面,我强烈建议检查 this documentation article,其中包含很多示例。
我打算使用 Kentico 创建多个商店(网站)并将每个商店的用户分配给 add/modify/delete 他的产品,我已经创建了 2 家商店,第一个的域名为 localhost:8080第二个是 storeone。localhost:8080 正如 Kentico Doc URL 中的文档所述,我可以毫无问题地打开第一个站点,但是当我尝试切换到第二个站点时,它给了我 错误请求 - 无效主机名 .. 任何人都可以帮助我吗? .. 如果有人帮助我了解如何使用 Kentico API 提取产品数据,我将不胜感激,因为文档仅向我提供来自数据库的 updating/modifying/removing 数据,我想知道如何显示它带有附件,例如我上传的图像 pdf。
最好的方法是使用两个不同的端口。这样做的原因是 IIS 默认绑定到端口 80。所以我要做的是将一个站点保留在 80,然后在 2 处做另一个。在 IIS 中进行这些绑定,然后转到 Kentico 并将您的第二个站点添加到 localhost:2 与 :8080。端口号有冲突。 Kentico 和 IIS 是 "confused",不知道该服务哪一个。它使用同一端口的唯一方法是在 Kentico 中启动和停止站点。
Brenden 是正确的 - 同一域中不能有 2 个站点 运行。您需要做的是配置IIS bindings。我经常做的是配置主机文件 (C:\Windows\System32\drivers\etc) 并添加更多规则,例如:
127.0.0.1 localhost2
127.0.0.1 localhost3
然后我可以使用将我的 Kentico 站点绑定到这些域。不要忘记在 Kentico -> Sites app.
中更改域名关于你的第二个问题:
这取决于您是只想获取 SKUInfo 对象还是存储自定义数据(页面类型字段)的页面对象。如果您只需要 SKUInfo,您可以使用类似的东西:
// gets only corresponding SKU Info object
var singleProduct = SKUInfoProvider.GetSKUInfo(1); // SKUID from COM_SKU table
if (singleProduct != null)
{
var name = singleProduct.SKUName;
var price = singleProduct.SKUPrice;
}
如果您需要获得包含所有自定义字段的产品,您需要像使用任何其他页面一样使用页面 API。一个简单的例子:
// gets sku with all custom properties
var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
var singleProduct = tree.SelectSingleDocument(2); // DocumentID from CMS_Document table
if (singleProduct != null)
{
// work with product
}
// or for multiple products
var products = tree.SelectNodes("custom.myProductType");
foreach (var product in products)
{
// work with products/pages
}
为了检索页面,我强烈建议检查 this documentation article,其中包含很多示例。