# B2c Metadata

> Define custom attributes, custom object types, and site preferences for B2C Commerce using metadata XML. Use this skill whenever the user needs to add a field to products, orders, or customers, create a new custom object type, set up site preferences, or extend the B2C data model. Also use when they ask about system-objecttype-extensions.xml, custom-objecttype-definitions.xml, attribute groups in…

- **Type:** Skill
- **Install:** `agentstack add skill-salesforcecommercecloud-b2c-developer-tooling-b2c-metadata`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [SalesforceCommerceCloud](https://agentstack.voostack.com/s/salesforcecommercecloud)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [SalesforceCommerceCloud](https://github.com/SalesforceCommerceCloud)
- **Source:** https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/tree/main/skills/b2c/skills/b2c-metadata
- **Website:** https://salesforcecommercecloud.github.io/b2c-developer-tooling/

## Install

```sh
agentstack add skill-salesforcecommercecloud-b2c-developer-tooling-b2c-metadata
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Metadata Skill

This skill guides you through working with site metadata XML for Salesforce B2C Commerce, including custom attributes, custom objects, and site preferences.

## Overview

Metadata defines the structure of your B2C Commerce data:

| Metadata Type | Purpose |
|---------------|---------|
| **System Object Extensions** | Add custom attributes to Products, Orders, Customers, etc. |
| **Custom Objects** | Define entirely new data types |
| **Site Preferences** | Site-specific configuration values |

## Site Archive Structure

Metadata is organized in site archives:

```
/site-archive
    /meta
        system-objecttype-extensions.xml    # Custom attributes on system objects
        custom-objecttype-definitions.xml   # Custom object definitions
    /sites
        /MySite
            preferences.xml                 # Site preferences
```

## System Object Extensions

Add custom attributes to existing system objects.

### Basic Structure

```xml

    
        
            
                My Custom Attribute
                string
                false
                false
            
        
        
            
                My Custom Group
                
            
        
    

```

### Common System Objects

| Object Type | Use Case |
|-------------|----------|
| `Product` | Product attributes |
| `Order` | Order metadata |
| `Profile` | Customer profile data |
| `Basket` | Cart data |
| `SitePreferences` | Site configuration |
| `Category` | Category attributes |
| `Content` | Content asset attributes |

### Attribute Types

| Type | Description | Example |
|------|-------------|---------|
| `string` | Text (max 4000 chars) | SKU, descriptions |
| `text` | Long text (unlimited) | Rich content |
| `int` | Integer | Quantity, rank |
| `double` | Decimal | Percentage, weight |
| `boolean` | true/false | Flags |
| `date` | Date only | Birth date |
| `datetime` | Date and time | Timestamps |
| `email` | Email address | Contact email |
| `password` | Encrypted | API keys |
| `html` | HTML content | Rich text |
| `enum-of-string` | Single select | Status |
| `enum-of-int` | Numeric enum | Priority level |
| `set-of-string` | Multi-select | Tags |
| `set-of-int` | Numeric multi-select | Categories |
| `image` | Image reference | Thumbnails |

### Enum Value Definitions

Enum types (`enum-of-string`, `enum-of-int`, `set-of-string`, `set-of-int`) require `value-definitions` with **display/value pairs**:

> **Element order matters.** Inside each ``, the `` element must come **before** ``. The `metadata.xsd` schema enforces this strict ordering — putting `` first fails site import validation with `cvc-complex-type.2.4.d: Invalid content was found starting with element 'display'`.

```xml

    Warranty Type
    enum-of-string
    false
    
        
            No Warranty
            none
        
        
            Limited Warranty
            limited
        
        
            Full Warranty
            full
        
    

```

| Element | Purpose |
|---------|---------|
| `` | Human-readable label shown in Business Manager (must appear first) |
| `` | The stored/API value (use lowercase, no spaces) |

## Product Custom Attribute Example

```xml

    
        
            
            
                Vendor SKU
                string
                false
                true
            

            
            
                Product Condition
                enum-of-string
                false
                
                    
                        New
                        new
                    
                    
                        Refurbished
                        refurbished
                    
                    
                        Used
                        used
                    
                
            

            
            
                Hazardous Material
                boolean
                false
                false
            

            
            
                Product Features
                set-of-string
                false
                
                    
                        Waterproof
                        waterproof
                    
                    
                        Recyclable
                        recyclable
                    
                
            
        

        
            
                Custom Product Information
                
                
                
                
            
        
    

```

## Custom Object Definitions

Create entirely new data types.

```xml

    
        Store Locations
        Physical store information
        source-to-target
        site
        
            Store ID
            string
            1
        
        
            
                Store Name
                string
                true
            
            
                Latitude
                double
            
            
                Longitude
                double
            
            
                Phone
                string
            
            
                Active
                boolean
                true
            
        
        
            
                Store Information
                
                
                
                
                
                
            
        
    

```

## Site Preferences

Site-specific configuration via custom attributes on SitePreferences.

### Metadata (system-objecttype-extensions.xml)

```xml

    
        
            
                Enable Feature X
                boolean
                false
            
            
                API Endpoint
                string
            
            
                Max Items Per Page
                int
                20
            
        
        
            
                Custom Settings
                
                
                
            
        
    

```

### Values (sites/MySite/preferences.xml)

Preferences can be set per instance type (development, staging, production) or for all instances:

```xml

    
        
            
            25
        
        
            
            true
            https://dev-api.example.com/v1
        
        
            true
            https://staging-api.example.com/v1
        
        
            false
            https://api.example.com/v1
        
    

```

### Access in Code

```javascript
var Site = require('dw/system/Site');

var enableFeatureX = Site.current.getCustomPreferenceValue('enableFeatureX');
var apiEndpoint = Site.current.getCustomPreferenceValue('apiEndpoint');
var maxItems = Site.current.getCustomPreferenceValue('maxItemsPerPage');
```

## Attribute Definition Options

```xml

    Display Name
    Description for BM tooltip
    string
    false
    false
    false
    true
    false
    false
    false
    0
    256
    default
    none
    kg

```

| Flag | Purpose |
|------|---------|
| `localizable-flag` | Can have different values per locale |
| `mandatory-flag` | Required in BM |
| `externally-managed-flag` | Read-only in BM |
| `visible-flag` | Shown in BM |
| `site-specific-flag` | Different value per site |
| `order-required-flag` | Required for order export |
| `searchable-flag` | Indexed for search |

## Best Practices

1. **Use attribute groups** to organize in Business Manager
2. **Prefix custom attributes** with organization name (e.g., `acme_myAttribute`)
3. **Set externally-managed** for data imported from external systems
4. **Use enums over strings** for controlled vocabularies
5. **Document with descriptions** - they appear as tooltips

## Detailed Reference

- [System Objects Reference](references/SYSTEM-OBJECTS.md) - All system object types
- [XML Examples](references/XML-EXAMPLES.md) - Complete import/export examples

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [SalesforceCommerceCloud](https://github.com/SalesforceCommerceCloud)
- **Source:** [SalesforceCommerceCloud/b2c-developer-tooling](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling)
- **License:** Apache-2.0
- **Homepage:** https://salesforcecommercecloud.github.io/b2c-developer-tooling/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-salesforcecommercecloud-b2c-developer-tooling-b2c-metadata
- Seller: https://agentstack.voostack.com/s/salesforcecommercecloud
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
