home / skills / salesforcecommercecloud / b2c-developer-tooling / b2c-site-import-export

b2c-site-import-export skill

/skills/b2c-cli/skills/b2c-site-import-export

This skill simplifies importing and exporting Salesforce B2C Commerce site archives, metadata, and configurations to streamline custom attributes, preferences,

npx playbooks add skill salesforcecommercecloud/b2c-developer-tooling --skill b2c-site-import-export

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
8.1 KB
---
name: b2c-site-import-export
description: Work with (B2C/SFCC/Demandware) site archive import archives and metadata XML patterns with the b2c cli. Use when adding custom attributes, system object extensions, site preferences, or understanding import/export XML schemas. Covers directory structure and XML file formats for site archives.
---

# Site Import/Export Skill

Use the `b2c` CLI plugin to import and export site archives on Salesforce B2C Commerce instances.

> **Tip:** If `b2c` is not installed globally, use `npx @salesforce/b2c-cli` instead (e.g., `npx @salesforce/b2c-cli job import`).

## Import Commands

### Import Local Directory

```bash
# Import a local directory as a site archive
b2c job import ./my-site-data

# Import and wait for completion
b2c job import ./my-site-data --wait

# Import a local zip file
b2c job import ./export.zip

# Keep the archive on the instance after import
b2c job import ./my-site-data --keep-archive

# Show job log if the import fails
b2c job import ./my-site-data --wait --show-log
```

### Import Remote Archive

```bash
# Import an archive that already exists on the instance (in Impex/src/instance/)
b2c job import existing-archive.zip --remote
```

## Export Commands

```bash
# Export site data
b2c job export

# Export with specific configuration
b2c job export --wait
```

## Common Workflows

### Adding a Custom Attribute to Products

1. 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>
```

2. Create the directory structure:
```
my-import/
└── meta/
    └── system-objecttype-extensions.xml
```

3. Import:
```bash
b2c job import ./my-import --wait
```

### Adding Site Preferences

1. 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>
```

2. 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>
```

3. Directory structure:
```
my-import/
├── meta/
│   └── system-objecttype-extensions.xml
└── sites/
    └── MySite/
        └── preferences.xml
```

4. Import:
```bash
b2c job import ./my-import --wait
```

### Creating a Custom Object Type

1. 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>
```

2. Import:
```bash
b2c job import ./my-import --wait
```

### Importing 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>
```

## 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 records
```

## Tips

### Checking Job Status

```bash
# Search for recent job executions
b2c job search

# Wait for a specific job execution
b2c job wait <execution-id>

# View job logs on failure
b2c job import ./my-data --wait --show-log
```

### Best Practices

1. **Test imports on sandbox first** before importing to staging/production
2. **Use `--wait`** to ensure import completes before continuing
3. **Use `--show-log`** to debug failed imports
4. **Keep archives organized** by feature or change type
5. **Version control your metadata** XML files

### Configuring External Services

For service configurations (HTTP, FTP, SOAP services), see the `b2c:b2c-webservices` skill which includes:
- Complete services.xml examples
- Credential, profile, and service element patterns
- Import/export workflows

Quick example:
```bash
# Import service configuration
b2c job import ./services-folder
```

Where `services-folder/services.xml` follows the patterns in the `b2c:b2c-webservices` skill.

## Detailed Reference

- [Metadata XML Patterns](references/METADATA-XML.md) - Common XML patterns for imports

## Related Skills

- `b2c:b2c-webservices` - Service configurations (HTTP, FTP, SOAP), services.xml format
- `b2c:b2c-metadata` - System object extensions and custom object definitions
- `b2c-cli:b2c-job` - Running jobs and monitoring import status

Overview

This skill helps you import and export Salesforce B2C Commerce (Demandware) site archives and metadata using the b2c CLI. It explains directory layout, XML metadata patterns, and common commands for site preferences, custom attributes, custom object types, and content. Use it to prepare archives that the platform will accept and to automate imports/exports during development and deployment.

How this skill works

The skill inspects and describes the expected site archive directory structure and the XML schemas used by B2C Commerce (metadata, preferences, custom objects, catalogs, pricebooks, inventory). It documents b2c CLI job commands for importing local directories, zip archives, and remote archives, and shows options like --wait, --keep-archive, and --show-log. It also demonstrates metadata examples for type extensions, custom object definitions, and site preference values.

When to use it

  • Adding or modifying custom attributes on system objects (products, customers)
  • Defining or deploying custom object types and their instances
  • Updating site preferences or site-specific library content
  • Exporting site data for migration, backup, or inspection
  • Automating imports as part of CI/CD or sandbox-to-staging workflows

Best practices

  • Test imports on a sandbox before staging/production
  • Use --wait to block until the import completes and capture status
  • Use --show-log to surface errors when an import fails
  • Keep metadata files version controlled and grouped by feature
  • Organize archives by directory structure matching the platform schema (meta, sites, catalogs, customobjects, etc.)

Example use cases

  • Add a vendorSKU custom attribute to Product via meta/system-objecttype-extensions.xml and import with b2c job import ./my-import --wait
  • Create a site preference and set its value in sites/MySite/preferences.xml, then import the archive to apply it
  • Define a custom object type (APIConfiguration) in meta/custom-objecttype-definitions.xml and import both type definition and customobjects/APIConfiguration.xml
  • Export current site data for review using b2c job export --wait, then inspect catalogs/, pricebooks/, and services.xml
  • Import an existing archive stored on the instance with b2c job import existing-archive.zip --remote

FAQ

Do I need the b2c CLI installed globally?

No. If b2c is not installed globally use npx @salesforce/b2c-cli followed by the job command, for example npx @salesforce/b2c-cli job import ./my-site-data.

How can I debug a failed import?

Run the import with --wait --show-log to see server-side logs and errors. Also run b2c job search and b2c job wait <execution-id> to inspect execution details.

What directory structure must an archive use?

Follow the platform pattern: root files like services.xml, a meta/ folder for metadata XML, sites/{SiteID}/preferences and library, catalogs/{CatalogID}/catalog.xml, pricebooks/, customobjects/, and inventory-lists/.