- Introduction
- Features
- Getting started
- Usage
- Environment Variables
- Multi-Storefront Support
- Input CSV File Format
- Output
- Contributing
- License
Bulk Redirects is a Node.js script designed to streamline the management of URL redirects for BigCommerce stores. It reads a CSV file containing SKU and path information, queries BigCommerce to determine the new URLs, and then either generates a CSV file for the redirects or uploads them directly via the BigCommerce API. The script supports multi-storefront configurations, making it versatile for businesses with multiple online storefronts.
- Bulk Processing: Handle large volumes of redirects efficiently.
- API Integration: Interact with BigCommerce APIs to fetch updated URLs and upload redirects.
- Customizable: Configure the script using command-line options or environment variables.
- Multi-Storefront Support: Manage redirects across multiple storefronts seamlessly.
- Flexible Output: Choose between generating a CSV file or loading redirects via API.
You can run the script directly using npx
without installing it globally:
npx @thebigrick/bulk-redirects
If you don't have npx
installed, you can install it globally using npm:
npm install -g npx
The script can be executed via the command line with various options to customize its behavior.
Options
--load
: (Optional) Load redirects directly into BigCommerce via API. Default: false.-s
,--source <file>
: (Optional) Specify the input CSV source file. Default: redirects.csv.-o
,--output <file>
: (Optional) Specify the output CSV file. Default: output.csv.-b
,--batch <batchSize>
: (Optional) Set the batch size for processing. Default: 50.-c
,--channel <channel>
: (Optional) BigCommerce channel id. Default: 1.-t
,--token <token>
: (Optional) BigCommerce access token. Can be set via the ACCESS_TOKEN environment variable.-h
,--hash <hash>
: (Optional) BigCommerce store hash. Can be set via the STORE_HASH environment variable.
Generate a CSV file for redirects without uploading them to BigCommerce:
npx @thebigrick/bulk-redirects --source my_redirects.csv --output redirects_output.csv --token YOUR_ACCESS_TOKEN --hash YOUR_STORE_HASH
Load redirects directly into BigCommerce using API credentials:
npx @thebigrick/bulk-redirects --load --source my_redirects.csv --token YOUR_ACCESS_TOKEN --hash YOUR_STORE_HASH
Set your API credentials in a .env file:
ACCESS_TOKEN=YOUR_ACCESS_TOKEN
STORE_HASH=YOUR_STORE_HASH
Run the script without specifying --token and --hash:
npx @thebigrick/bulk-redirects --load --source my_redirects.csv
The script can read the following environment variables, which can be set in a .env file or directly in your shell environment:
- ACCESS_TOKEN: Your BigCommerce access token.
- STORE_HASH: Your BigCommerce store hash.
Specify the channel id using the --channel option to manage redirects for different storefronts:
npx @thebigrick/bulk-redirects --source my_redirects.csv --output redirects_output.csv --channel 123 --token YOUR_ACCESS_TOKEN --hash YOUR_STORE_HASH
The input CSV file should contain two columns: sku and path.
Example my_redirects.csv
:
sku,path
SKU123,/old-product-page
SKU456,/another-old-page
Depending on the options used:
- Generate CSV: If
--load
is not specified, the script will generate a CSV file with the new redirects, specified by the--output
option. - Load via API: If
--load
is specified, the script will upload the redirects directly to your BigCommerce store via the API.
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE.md file for details.