Description
In this Sylius Academy episode, we demonstrate how to import and manage taxons programmatically using a CSV-based importer. This approach is ideal for growing e-commerce stores, especially when adding new sales channels (e.g., a B2B portal) powered by ERP or other external systems.
You’ll learn:
- how to parse a CSV file containing taxon data (Code, Name, Description, Locale, Parent),
- how to use a Flysystem adapter for flexible file storage (local, FTP, S3),
- how each row is converted into a TaxonDTO object,
- how the custom TaxonProvider checks for existing taxons or creates new ones (with caching),
- how the TranslationProvider assigns multilingual labels without fallback issues,
- how slugs are generated dynamically using Symfony String Inflector,
- how parent-child relationships are handled to avoid duplication or missing parents,
- how to persist taxons and translations using Doctrine’s EntityManager,
- how to run the import via a Symfony Console command: bin/console app:import.
Final Result:
- A full taxon tree for the B2B channel is imported successfully.
- Taxons include slugs and multilingual translations (e.g., Polish and English).
Each channel can have its own independent taxonomy structure, perfectly matching business segmentation