Skip to content

Demo shops

opencolibri/starter-sales-kit runs the demo shops of a sales kit: the admin calls its sylius:shop:* tasks through castor-api, and they also work from the command line.

A shop is created from a dataset: the dataset is copied into .castor/import/var/<shop>/, so its settings and images can change without touching the dataset, and deleting or rebuilding the dataset leaves it unchanged. Its project.yaml keeps its name, the channel it is loaded into, the password of its demo customer and what the extensions keep.

Terminal window
castor sylius:shop:create cellar # shop "cellar"
castor sylius:shop:create cellar --name="Cave du Port" --description="…" # shop "cave-du-port"
castor sylius:shop:generate cave-du-port # writes its fixtures
castor sylius:shop:load cave-du-port # loads them into Sylius
castor sylius:shop:list # JSON when not run in a terminal
castor sylius:shop:delete cave-du-port # its channel, catalog and files

sylius:shop:generate decides which channel receives the catalog, kept in project.yaml (shop key):

--subdomainChannelHostnameOn load
omitted (the shop slug), or e.g. cavea channel of its own (CAVE_DU_PORT)cave.{domain}the channel is reset and recreated
""the default WEB_STORE channelthe app domainonly the shop catalog is replaced; the channel, its orders and admins are kept

--limit caps the number of products.

  • A demo customer: <shop>@shop.local, with the password of project.yaml (shop_password), shown in the admin.
  • Its images: the logo, header and interstice images uploaded in the admin (media/image_* of the shop). They are copied to the Sylius app as static files, public/media/shops/<CHANNEL>/<role>.<hash>.<ext>, and config/import/shop_images.php lists their URLs per channel; the storefront feeds them to the shared hero and brand slots. The hash changes the URL when an image changes, so browsers cache them for good. On Upsun, public/media is a storage mount: upload public/media/shops/ to it (upsun mount:upload).

The package registers these fixtures extensions: they only handle the demo shops, not the catalog sylius:dataset:load puts into the default channel.

Each shop gets its own storefront theme, among the themes installed with the theme-bundle target:

Terminal window
castor sylius:shop:theme cave-du-port cellar # "default" for the Sylius look

The theme is applied to the channel right away (castor sylius:theme:channel), kept in project.yaml (theme, the theme of the dataset until one is picked), and set again by the import_channel_theme fixture each time the channel is recreated.

Terminal window
castor sylius:shop:visibility cave-du-port private # or public

Only the demo customer of a private shop gets into its storefront and shop API, for a demo shared with one customer. The scaffold adds to the app a private shop field on the channel (ImportPrivateShopAwareTrait, wired onto src/Entity/Channel/Channel.php, and its migration), a voter and its access_control rules in config/packages/security.yaml, a login page, the import_private_shop fixture and the sylius:import:channel:private command. The visibility is kept in project.yaml (private). A shop on the default channel stays public.

Each shop on a channel of its own gets a Sylius admin restricted to that channel: it only sees and edits the catalog of its shop. Its login is the shop slug, its password is generated on the first generation and kept in project.yaml (admin_password). The scaffold adds a channel scope on the admin user (ImportChannelAdminAwareTrait, wired onto src/Entity/User/AdminUser.php, and its migration), the voter, access and menu listeners and product form extension that enforce it, product, variant and taxon repositories filtering by channel (config/sylius/import_channel_admin.yaml), a listener removing the admins of a reset channel, and the import_admin_user fixture.

To load a shop on a remote stack without building it there, copy its directory over SSH with rsync:

Terminal window
castor sylius:shop:push cave-du-port --dry-run # show what would be copied
castor sylius:shop:push cave-du-port # copy it
castor sylius:shop:push cave-du-port --delete # also delete remote files missing locally

Configure the server in the .env.local of the project root:

VariableDefaultDescription
IMPORT_VAR_PUSH_SSH_HOST—SSH host (required)
IMPORT_VAR_PUSH_REMOTE_DIR—Root of the remote project (required)
IMPORT_VAR_PUSH_SSH_USERdebianSSH user
IMPORT_VAR_PUSH_SSH_PORT22SSH port
IMPORT_VAR_PUSH_IDENTITY_FILESSH default keyPrivate key (~/ is expanded)