Use command-line client (cli) to manage Storefront
Storefront comes with an API that makes all features available via a remote
control. While the API is the receiver, the remote control is e.g. a tool
like sfctl. It is a very small tool that you can download and install to
dig deep into the system and access every little detail about your Storefront
installation.
Whether you want to look inside Storefront without a browser, want to automate
Storefront, or you're simply curious, sfctl is the companion to help you out.
Step 1: Download and install
- Go to GitHub->webridge-dev->storefront-api-go->Releases, download and unpack the newest release.
Step 2: Initial configuration
If you use sfctl for the first time, you can ask it to create a configuration
file in your home directory.
sfctl contexts init
It creates a YAML file in $HOME/.sfctl/config.yml (on Linux/macOS) and
%HOMEDRIVE%%HOMEPATH%\.sfctl (on Windows). A configuration file for
sfctl looks e.g. like this:
current: staging
instances:
staging:
url: https://bigbuy.storefront.live
email: joe@example.com
oauth_client_id: EF1370AA-D275-494A-AE57-75191ECF4B75
oauth_client_secret: QkU3OUU4NTEtNjBFNS00QTdCLUEyQ0ItRjI3REFFNENEMTJFCg==
production:
url: https://bigbuy.storefront.live
email: joe@example.com
oauth_client_id: 7447146C-AA93-40A9-8355-2ADD422A9EBB
oauth_client_secret: NjJBMzdEQzAtNUJEOC00MTJBLThDQzktNzY5MEEzQzJBNzhBCg==
The above config file simply means that you can control two Storefront
installations by the name of staging and production. The current: staging
indicates that all commands run by sfctl by default go to the instance
named staging.
If you want to edit the configuration file, feel free to open it in the editor
of your choice, or use the sfctl contexts edit shortcut.
The configuration file uses YAML as file format. If the configuration file
is not a valid YAML format, sfctl won't work. Either create a new
configuration file from scratch, or create a backup before editing.
Step 3: Manage connection to Storefront instances and tenants
The sfctl contexts list command lists all configured instances and tenants
defined in your configuration file. The asterisk marks the currently selected
target instance:
$ ./sfctl contexts list
* staging joe@example.com https://demo.meplato.live
production joe@example.com https://demo.meplato.live
You can switch between instances by using
sfctl contexts set <new_instance_name>:
# Switch to production instance/tenant
sfctl contexts set production
# Switch to staging instance/tenant
sfctl contexts set staging
Always double check that you've selected the correct instance before running destructive commands like e.g. deleting catalogs or vendors!
Step 4: List all tenants, vendors, and catalogs
The sfctl command has its internal command hierarchy. The logic is:
sfctl <module> <command> <options>
E.g. if you want to list all tenants, do:
sfctl tenants list
The same goes for vendors:
sfctl vendors list
... and catalogs:
sfctl catalogs list
TODO
- Create a new vendor
- Create a new catalog
- List and watch events
- Import a catalog
- List views
- Add a catalog to a view
- Search for products
- Get product details