b2c-site-import-export
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSite Import/Export Skill
站点导入/导出 Skill
Use the CLI plugin to import and export site archives on Salesforce B2C Commerce instances.
b2cTip: Ifis not installed globally, useb2cinstead (e.g.,npx @salesforce/b2c-cli).npx @salesforce/b2c-cli job import
使用 CLI插件在Salesforce B2C Commerce实例上导入和导出站点归档。
b2c提示: 如果未全局安装,请使用b2c替代(例如:npx @salesforce/b2c-cli)。npx @salesforce/b2c-cli job import
Import Commands
导入命令
Import Local Directory
导入本地目录
bash
undefinedbash
undefinedImport a local directory as a site archive
导入本地目录作为站点归档
b2c job import ./my-site-data
b2c job import ./my-site-data
Import and wait for completion
导入并等待完成
b2c job import ./my-site-data --wait
b2c job import ./my-site-data --wait
Import a local zip file
导入本地压缩文件
b2c job import ./export.zip
b2c job import ./export.zip
Keep the archive on the instance after import
导入后在实例上保留归档文件
b2c job import ./my-site-data --keep-archive
b2c job import ./my-site-data --keep-archive
Show job log if the import fails
若导入失败则显示作业日志
b2c job import ./my-site-data --wait --show-log
undefinedb2c job import ./my-site-data --wait --show-log
undefinedImport Remote Archive
导入远程归档
bash
undefinedbash
undefinedImport an archive that already exists on the instance (in Impex/src/instance/)
导入已存在于实例上的归档文件(位于Impex/src/instance/目录下)
b2c job import existing-archive.zip --remote
undefinedb2c job import existing-archive.zip --remote
undefinedExport Commands
导出命令
bash
undefinedbash
undefinedExport site data
导出站点数据
b2c job export
b2c job export
Export with specific configuration
使用特定配置导出
b2c job export --wait
undefinedb2c job export --wait
undefinedCommon Workflows
常见工作流
Adding a Custom Attribute to Products
为产品添加自定义属性
- Create the metadata XML file:
meta/system-objecttype-extensions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<type-extension type-id="Product">
<custom-attribute-definitions>
<attribute-definition attribute-id="vendorSKU">
<display-name xml:lang="x-default">Vendor SKU</display-name>
<type>string</type>
<mandatory-flag>false</mandatory-flag>
<externally-managed-flag>true</externally-managed-flag>
</attribute-definition>
</custom-attribute-definitions>
<group-definitions>
<attribute-group group-id="CustomAttributes">
<display-name xml:lang="x-default">Custom Attributes</display-name>
<attribute attribute-id="vendorSKU"/>
</attribute-group>
</group-definitions>
</type-extension>
</metadata>- Create the directory structure:
my-import/
└── meta/
└── system-objecttype-extensions.xml- Import:
bash
b2c job import ./my-import --wait- 创建元数据XML文件:
meta/system-objecttype-extensions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<type-extension type-id="Product">
<custom-attribute-definitions>
<attribute-definition attribute-id="vendorSKU">
<display-name xml:lang="x-default">Vendor SKU</display-name>
<type>string</type>
<mandatory-flag>false</mandatory-flag>
<externally-managed-flag>true</externally-managed-flag>
</attribute-definition>
</custom-attribute-definitions>
<group-definitions>
<attribute-group group-id="CustomAttributes">
<display-name xml:lang="x-default">Custom Attributes</display-name>
<attribute attribute-id="vendorSKU"/>
</attribute-group>
</group-definitions>
</type-extension>
</metadata>- 创建目录结构:
my-import/
└── meta/
└── system-objecttype-extensions.xml- 执行导入:
bash
b2c job import ./my-import --waitAdding Site Preferences
添加站点偏好设置
- Create metadata for the preference:
meta/system-objecttype-extensions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<type-extension type-id="SitePreferences">
<custom-attribute-definitions>
<attribute-definition attribute-id="enableFeatureX">
<display-name xml:lang="x-default">Enable Feature X</display-name>
<type>boolean</type>
<default-value>false</default-value>
</attribute-definition>
</custom-attribute-definitions>
</type-extension>
</metadata>- Create preference values:
sites/MySite/preferences.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<preferences xmlns="http://www.demandware.com/xml/impex/preferences/2007-03-31">
<custom-preferences>
<all-instances>
<preference preference-id="enableFeatureX">true</preference>
</all-instances>
</custom-preferences>
</preferences>- Directory structure:
my-import/
├── meta/
│ └── system-objecttype-extensions.xml
└── sites/
└── MySite/
└── preferences.xml- Import:
bash
b2c job import ./my-import --wait- 为偏好设置创建元数据:
meta/system-objecttype-extensions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<type-extension type-id="SitePreferences">
<custom-attribute-definitions>
<attribute-definition attribute-id="enableFeatureX">
<display-name xml:lang="x-default">Enable Feature X</display-name>
<type>boolean</type>
<default-value>false</default-value>
</attribute-definition>
</custom-attribute-definitions>
</type-extension>
</metadata>- 创建偏好设置值:
sites/MySite/preferences.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<preferences xmlns="http://www.demandware.com/xml/impex/preferences/2007-03-31">
<custom-preferences>
<all-instances>
<preference preference-id="enableFeatureX">true</preference>
</all-instances>
</custom-preferences>
</preferences>- 目录结构:
my-import/
├── meta/
│ └── system-objecttype-extensions.xml
└── sites/
└── MySite/
└── preferences.xml- 执行导入:
bash
b2c job import ./my-import --waitCreating a Custom Object Type
创建自定义对象类型
- Define the custom object:
meta/custom-objecttype-definitions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<custom-type type-id="APIConfiguration">
<display-name xml:lang="x-default">API Configuration</display-name>
<staging-mode>source-to-target</staging-mode>
<storage-scope>site</storage-scope>
<key-definition attribute-id="configId">
<display-name xml:lang="x-default">Config ID</display-name>
<type>string</type>
<min-length>1</min-length>
</key-definition>
<attribute-definitions>
<attribute-definition attribute-id="endpoint">
<display-name xml:lang="x-default">API Endpoint</display-name>
<type>string</type>
</attribute-definition>
<attribute-definition attribute-id="apiKey">
<display-name xml:lang="x-default">API Key</display-name>
<type>password</type>
</attribute-definition>
<attribute-definition attribute-id="isActive">
<display-name xml:lang="x-default">Active</display-name>
<type>boolean</type>
<default-value>true</default-value>
</attribute-definition>
</attribute-definitions>
</custom-type>
</metadata>- Import:
bash
b2c job import ./my-import --wait- 定义自定义对象:
meta/custom-objecttype-definitions.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.demandware.com/xml/impex/metadata/2006-10-31">
<custom-type type-id="APIConfiguration">
<display-name xml:lang="x-default">API Configuration</display-name>
<staging-mode>source-to-target</staging-mode>
<storage-scope>site</storage-scope>
<key-definition attribute-id="configId">
<display-name xml:lang="x-default">Config ID</display-name>
<type>string</type>
<min-length>1</min-length>
</key-definition>
<attribute-definitions>
<attribute-definition attribute-id="endpoint">
<display-name xml:lang="x-default">API Endpoint</display-name>
<type>string</type>
</attribute-definition>
<attribute-definition attribute-id="apiKey">
<display-name xml:lang="x-default">API Key</display-name>
<type>password</type>
</attribute-definition>
<attribute-definition attribute-id="isActive">
<display-name xml:lang="x-default">Active</display-name>
<type>boolean</type>
<default-value>true</default-value>
</attribute-definition>
</attribute-definitions>
</custom-type>
</metadata>- 执行导入:
bash
b2c job import ./my-import --waitImporting Custom Object Data
导入自定义对象数据
customobjects/APIConfiguration.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<custom-objects xmlns="http://www.demandware.com/xml/impex/customobject/2006-10-31">
<custom-object type-id="APIConfiguration" object-id="payment-gateway">
<object-attribute attribute-id="endpoint">https://api.payment.com/v2</object-attribute>
<object-attribute attribute-id="isActive">true</object-attribute>
</custom-object>
</custom-objects>customobjects/APIConfiguration.xml:
xml
<?xml version="1.0" encoding="UTF-8"?>
<custom-objects xmlns="http://www.demandware.com/xml/impex/customobject/2006-10-31">
<custom-object type-id="APIConfiguration" object-id="payment-gateway">
<object-attribute attribute-id="endpoint">https://api.payment.com/v2</object-attribute>
<object-attribute attribute-id="isActive">true</object-attribute>
</custom-object>
</custom-objects>Site Archive Structure
站点归档结构
site-archive/
├── services.xml # Service configurations (credentials, profiles, services)
├── meta/
│ ├── system-objecttype-extensions.xml # Custom attributes on system objects
│ └── custom-objecttype-definitions.xml # Custom object type definitions
├── sites/
│ └── {SiteID}/
│ ├── preferences.xml # Site preference values
│ └── library/
│ └── content/
│ └── content.xml # Content assets
├── catalogs/
│ └── {CatalogID}/
│ └── catalog.xml # Products and categories
├── pricebooks/
│ └── {PriceBookID}/
│ └── pricebook.xml # Price definitions
├── customobjects/
│ └── {ObjectTypeID}.xml # Custom object instances
└── inventory-lists/
└── {InventoryListID}/
└── inventory.xml # Inventory recordssite-archive/
├── services.xml # 服务配置(凭据、配置文件、服务)
├── meta/
│ ├── system-objecttype-extensions.xml # 系统对象的自定义属性
│ └── custom-objecttype-definitions.xml # 自定义对象类型定义
├── sites/
│ └── {SiteID}/
│ ├── preferences.xml # 站点偏好设置值
│ └── library/
│ └── content/
│ └── content.xml # 内容资产
├── catalogs/
│ └── {CatalogID}/
│ └── catalog.xml # 商品与分类
├── pricebooks/
│ └── {PriceBookID}/
│ └── pricebook.xml # 价格定义
├── customobjects/
│ └── {ObjectTypeID}.xml # 自定义对象实例
└── inventory-lists/
└── {InventoryListID}/
└── inventory.xml # 库存记录Tips
技巧
Checking Job Status
检查作业状态
bash
undefinedbash
undefinedSearch for recent job executions
搜索最近的作业执行记录
b2c job search
b2c job search
Wait for a specific job execution
等待特定作业执行完成
b2c job wait <execution-id>
b2c job wait <execution-id>
View job logs on failure
查看失败作业的日志
b2c job import ./my-data --wait --show-log
undefinedb2c job import ./my-data --wait --show-log
undefinedBest Practices
最佳实践
- Test imports on sandbox first before importing to staging/production
- Use to ensure import completes before continuing
--wait - Use to debug failed imports
--show-log - Keep archives organized by feature or change type
- Version control your metadata XML files
- 先在沙箱环境测试导入,再导入到预发布/生产环境
- 使用参数,确保导入完成后再继续后续操作
--wait - 使用参数,调试失败的导入任务
--show-log - 按功能或变更类型整理归档文件
- 对元数据XML文件进行版本控制
Configuring External Services
配置外部服务
For service configurations (HTTP, FTP, SOAP services), see the skill which includes:
b2c:b2c-webservices- Complete services.xml examples
- Credential, profile, and service element patterns
- Import/export workflows
Quick example:
bash
undefined有关服务配置(HTTP、FTP、SOAP服务),请查看技能文档,其中包含:
b2c:b2c-webservices- 完整的services.xml示例
- 凭据、配置文件和服务元素模板
- 导入/导出工作流
快速示例:
bash
undefinedImport service configuration
导入服务配置
b2c job import ./services-folder
Where `services-folder/services.xml` follows the patterns in the `b2c:b2c-webservices` skill.b2c job import ./services-folder
其中`services-folder/services.xml`需遵循`b2c:b2c-webservices`技能文档中的模板规范。Detailed Reference
详细参考
- Metadata XML Patterns - Common XML patterns for imports
- 元数据XML模板 - 导入操作常用的XML模板
Related Skills
相关技能
- - Service configurations (HTTP, FTP, SOAP), services.xml format
b2c:b2c-webservices - - System object extensions and custom object definitions
b2c:b2c-metadata - - Running jobs and monitoring import status
b2c-cli:b2c-job
- - 服务配置(HTTP、FTP、SOAP)、services.xml格式
b2c:b2c-webservices - - 系统对象扩展与自定义对象定义
b2c:b2c-metadata - - 运行作业与监控导入状态
b2c-cli:b2c-job