$npx -y skills add forcedotcom/sf-skills --skill commerce-b2b-store-createInteractive workflow to create Commerce B2B Stores and retrieve storefront metadata. Use when users want to: create B2B Commerce stores, build Commerce storefronts, set up B2B stores from Vibes, retrieve Commerce metadata, deploy Commerce experiences, work with DigitalExperienceB
| 1 | # Commerce B2B Storefront Creation |
| 2 | |
| 3 | Interactive workflow to create a Commerce B2B Store in Salesforce and retrieve the auto-generated storefront metadata to your repository. |
| 4 | |
| 5 | ## Critical Concepts |
| 6 | |
| 7 | Commerce B2B = Store (backend data) + Storefront (frontend metadata). **Store must be created first** in the org to auto-generate the Storefront. Never create storefront metadata manually. |
| 8 | |
| 9 | > See [Store vs Storefront Reference](references/store-vs-storefront.md) |
| 10 | |
| 11 | ## When to Use This Skill |
| 12 | |
| 13 | Trigger when users request: |
| 14 | - "Create a B2B Commerce store" |
| 15 | - "Build a Commerce storefront" |
| 16 | - "Set up Commerce B2B" |
| 17 | - "Create B2B Commerce" |
| 18 | - "Retrieve Commerce storefront metadata" |
| 19 | - "Deploy B2B storefront" |
| 20 | |
| 21 | ## Rules That Always Apply |
| 22 | |
| 23 | 1. **Always follow the interactive flow.** Do NOT skip steps. Each step requires user confirmation before proceeding. |
| 24 | |
| 25 | 2. **Never create storefront metadata manually.** The Commerce setup wizard generates hundreds of configuration values. Manual creation will fail. |
| 26 | |
| 27 | 3. **Always list sites before retrieval.** Store names get underscores and number suffixes (e.g., "My B2B Store" → "My_B2B_Store1"). Let the user select from the actual list. |
| 28 | |
| 29 | 4. **Always use `--json` flag.** Include `--json` on all Salesforce CLI commands for parseable output. |
| 30 | |
| 31 | ## Interactive Workflow: 7 Steps |
| 32 | |
| 33 | ### Step 1: Explain Commerce B2B Concept |
| 34 | |
| 35 | **Agent explains:** Commerce has Store (data) + Storefront (metadata). Store must be created first. |
| 36 | |
| 37 | > See: [Store vs Storefront Reference](references/store-vs-storefront.md) |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ### Step 2: Guide User to Create B2B Store |
| 42 | |
| 43 | **Agent provides these steps:** |
| 44 | |
| 45 | 1. Navigate to **Setup → Commerce → Stores** |
| 46 | - Or: **App Launcher → Commerce → Create Store** |
| 47 | |
| 48 | 2. Click **"Create Store"** or **"Setup New Store"** |
| 49 | |
| 50 | 3. Select **"Commerce Store"** as the store type |
| 51 | |
| 52 | 4. Follow the wizard: |
| 53 | - **Store Name**: Choose descriptive name (e.g., "My B2B Store") |
| 54 | - Important: Spaces become underscores in folder names |
| 55 | - **Site URL**: Unique URL name for the site |
| 56 | |
| 57 | 5. Complete wizard - it creates: |
| 58 | - WebStore record |
| 59 | - Default buyer group and entitlement policies |
| 60 | - Associated Digital Experience (LWR site) |
| 61 | |
| 62 | 6. Optional: Configure payment gateway, tax provider, shipping |
| 63 | |
| 64 | **Agent then asks:** |
| 65 | "Have you completed creating the B2B Store in your org? Reply 'yes' when ready and provide the store name you used." |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ### Step 3: Get User Confirmation |
| 70 | |
| 71 | **Agent waits for:** User confirmation and store name |
| 72 | |
| 73 | **Agent validates:** Store name format (no special characters, spaces will appear as underscores) |
| 74 | |
| 75 | **Agent acknowledges:** "Great! Let me list the available storefronts in your org..." |
| 76 | |
| 77 | --- |
| 78 | |
| 79 | ### Step 4: List Available LWR Sites |
| 80 | |
| 81 | **Agent executes:** |
| 82 | ```bash |
| 83 | sf org list metadata --metadata-type DigitalExperienceConfig --json |
| 84 | ``` |
| 85 | |
| 86 | **Agent should:** |
| 87 | - Parse JSON output to extract site names |
| 88 | - Display as numbered list |
| 89 | - Explain naming (underscores, number suffixes) |
| 90 | |
| 91 | **Example output:** |
| 92 | ``` |
| 93 | Available Digital Experience sites: |
| 94 | 1. My_B2B_Store1 |
| 95 | 2. Partner_Portal |
| 96 | 3. Customer_Community |
| 97 | ``` |
| 98 | |
| 99 | --- |
| 100 | |
| 101 | ### Step 5: Let User Select Storefront |
| 102 | |
| 103 | **Agent asks:** |
| 104 | "Which site corresponds to your B2B Store? Select the site name:" |
| 105 | |
| 106 | **Agent validates:** Selection matches available sites |
| 107 | |
| 108 | **Agent confirms:** "Got it! I'll retrieve metadata for [site-name]..." |
| 109 | |
| 110 | --- |
| 111 | |
| 112 | ### Step 6: Retrieve Storefront Metadata |
| 113 | |
| 114 | **Agent executes:** |
| 115 | ```bash |
| 116 | sf project retrieve start -m DigitalExperienceBundle:site/<selected-store-name> --json |
| 117 | ``` |
| 118 | |
| 119 | **Agent should:** |
| 120 | - Show retrieval progress |
| 121 | - Confirm successful retrieval |
| 122 | - List retrieved directory structure |
| 123 | |
| 124 | **Expected output:** |
| 125 | ``` |
| 126 | Retrieved: force-app/main/default/digitalExperiences/site/My_B2B_Store1/ |
| 127 | ├── My_B2B_Store1.digitalExperience-meta.xml |
| 128 | ├── sfdc_cms__view/ (home, current_cart, detail_*, list_*, etc.) |
| 129 | ├── sfdc_cms__site/ |
| 130 | ├── sfdc_cms__route/ |
| 131 | └── [other sfdc_cms__* directories] |
| 132 | ``` |
| 133 | |
| 134 | --- |
| 135 | |
| 136 | ### Step 7: Provide Next Steps |
| 137 | |
| 138 | **Agent provides:** |
| 139 | |
| 140 | ✅ **Metadata retrieved successfully!** |
| 141 | |
| 142 | **Next steps:** |
| 143 | - Customize with custom LWCs or branding changes |
| 144 | - Deploy: `sf project deploy start --source-dir force-app/main/default/digitalExperiences/site/My_B2B_Store1/ --json` |
| 145 | |
| 146 | **Resources:** [DigitalExperienceBundle Docs](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_digitalexperiencebundle.htm), [B2B Commerce Guide](https://developer.salesforce.com/docs/atlas.en-us.b2b_commerce_dev_guide.meta/b2b_commerce_dev_guide/) |
| 147 | |
| 148 | --- |
| 149 | |
| 150 | ## Reference |
| 151 | |
| 152 | - **[store-vs-storefront.md](references/store-vs-storefront.md)* |