Skip to content

Datasets

A dataset is a catalog ready to be imported: its products and collections (products.yaml, collections.yaml), their images (media/) and a dataset.yaml describing it. A shop is created from a dataset, then its fixtures are generated and loaded as usual: several shops can share one dataset, and a dataset is built (AI calls, downloads) once.

cellar/
├── dataset.yaml name, description, suggested theme…
├── products.yaml image: media/<code>.webp
├── collections.yaml
└── media/ the images, in WebP

In a dataset, the image of a product or a collection is a path relative to the dataset directory: the fixtures generation copies it instead of downloading it. A URL still works, and is downloaded.

sylius-starter/datasets ships ready-made datasets, images included, so a demo shop needs no AI call nor download:

DatasetCatalogSuggested theme
automotiveEighteen car parts, tyres, tools and workshop equipmentTorque
bloomEighteen beauty products and tools, on six shelvesBloom
cellarSeventeen wines from fictional estates, in seven regionsCellar
cultureEighteen books, games, instruments and collectiblesCulture
depotEighteen trade supplies and equipment, in six aislesDepot
grooveSixteen fictional vinyl records, in six genresGroove
homeEighteen pieces of furniture, lighting, linen and tablewareHearth
outdoorEighteen pieces of hiking, climbing and camping gearSummit
petsEighteen foods, treats, toys, beds and care products for petsPaws
retro-gamingSixteen retro consoles, games and accessories, on six shelvesRetro Gaming
roasterySixteen specialty coffees and brewing tools, on six shelvesRoastery
supermarketNine everyday groceries, one per supermarket aisleDrive
teahouseSixteen fine teas and pieces of teaware, on six shelvesTeahouse
techSixteen devices from fictional brands, in six departmentsTech
video-gamesSixteen fictional video games, in six genresArena

To add one, drop its directory in src/Datasets/datasets/ (a downloaded dataset has that layout). Every product needs a local image, a collection may have one (shown on the homepage category tiles): the package tests check them. Another package can ship its own datasets by registering its directory from an autoloaded file:

use SyliusStarter\Core\Dataset\DatasetDirectories;
DatasetDirectories::register('my-datasets', __DIR__ . '/../datasets');
Terminal window
castor sylius:import:dataset:build --name="Tea House" --description="Loose leaf teas and tea ware"
castor sylius:import:dataset:build --source=existing --name="Tea House" --url=https://www.example-tea.com

The ai source generates the catalog with AI (--limit, 20 products at most); other sources are registered by the project, such as existing (the fetch of an existing site) in the Sales Kit. The dataset is written to .castor/import/datasets/<slug>/ (the slug of the name, or --dataset), then the image of every product and collection is downloaded or generated into its media/. Building it again replaces its catalog.

Terminal window
castor sylius:import:dataset:list # the datasets, with their number of products and images
castor sylius:import:dataset:images tea-house # download or generate the images still missing
castor sylius:import:dataset:delete tea-house # built datasets only, the shops created from it are kept

A source is a callable that writes the catalog of the slug it receives, in an import context whose var dir is the datasets one (the shop import functions then write to the dataset):

use SyliusStarter\Import\Dataset\DatasetBuilders;
DatasetBuilders::register('existing', static function (string $slug, string $name, string $description, ?string $url, int $limit): void {
fetch_import_data($url, $name, $description, $slug);
});
Terminal window
castor sylius:import:dataset:export cellar # .castor/import/exports/cellar.zip
castor sylius:import:dataset:export tea-house --output=tea.zip

The zip holds a <slug>/ directory: unzipped in src/Datasets/datasets/, it becomes a ready-made dataset.

Terminal window
castor sylius:import:shop:create cellar # shop "cellar"
castor sylius:import:shop:create cellar --name="Cave du Port" --description="…" # shop "cave-du-port"
castor sylius:import:fixtures:generate --project=cave-du-port
castor sylius:import:fixtures:load --project=cave-du-port

The dataset is copied into .castor/import/var/<shop>/, and project.yaml records the dataset it comes from (dataset: cellar). The shop then lives on its own: deleting or rebuilding the dataset leaves it unchanged.