VOOZH about

URL: https://deepwiki.com/MahoCommerce/maho/2.2-sample-data-import

⇱ Sample Data Import | MahoCommerce/maho | DeepWiki


Loading...
Last indexed: 15 May 2026 (ea8ab8)
Menu

Sample Data Import

Sample data import provides demonstration products, categories, CMS pages, and media files for Maho installations. This system downloads versioned sample data from GitHub, imports it with automatic EAV attribute ID remapping, and supports multiple database engines (MySQL, PostgreSQL, SQLite). The import process handles schema differences between sample data and the installed Maho version, ensuring compatibility with new system attributes introduced in updates (e.g., gtin and mpn attributes added in Maho 26.1.0).

For information about the initial installation wizard workflow, see Installation. For configuration system details, see Configuration System Overview.


Sample Data Contents

The sample data repository (MahoCommerce/maho-sample-data) contains:

ComponentDescriptionLocation
ProductsClothing, accessories, configurable products with swatchesdb_data.sql
CategoriesOrganized catalog structure with tree hierarchydb_data.sql
AttributesProduct attributes including user-defined onesdb_data.sql
Attribute SetsCustom attribute sets and groupsdb_data.sql
CMS PagesAbout, contact, and informational pagesdb_data.sql
ConfigurationStore settings, swatch configurationsdb_config.sql
Media FilesProduct images, banners, category thumbnailsmedia/ directory

Sample data is version-specific. The installer determines the branch matching the current Maho version by parsing Mage::getVersion() (e.g., branch 25.9 for version 25.9.x).

Sources: lib/MahoCLI/Commands/Install.php132-137 app/code/core/Mage/Catalog/sql/maho_setup/maho-26.1.0.php17-49


Installation Entry Points

Sample data can be installed through two methods:

CLI Installation


The Install command at lib/MahoCLI/Commands/Install.php handles sample data import inline during installation. Table prefix is not supported with sample data because SQL files use hardcoded table names. If a prefix is provided with sample data, the CLI command automatically unsets it before proceeding.

Sources: lib/MahoCLI/Commands/Install.php71 lib/MahoCLI/Commands/Install.php88-97

Web Wizard Installation

The installation wizard includes a dedicated "Sample Data" step. The web interface provides visual progress tracking via Mage_Install_Model_Installer_SampleData, which persists status to var/sampledata_progress.json.


System Architecture


Diagram: Sample Data Import System Architecture

The CLI entry point and the Web Wizard both delegate to the SampleDataImporter class, which handles the critical EAV attribute remapping and engine-specific SQL adjustments.

Sources: lib/MahoCLI/Commands/Install.php129-283 lib/MahoCLI/Helper/SampleDataImporter.php25-264


EAV Attribute Remapping System

The most critical aspect of sample data import is EAV attribute ID remapping. Sample data SQL contains hardcoded attribute IDs that differ from the current installation due to version differences or installation order.

Remapping Process


Diagram: EAV Attribute ID Remapping Process Flow

Sources: lib/MahoCLI/Helper/SampleDataImporter.php232-264 app/code/core/Mage/Catalog/sql/maho_setup/maho-26.1.0.php17-49

Attribute Matching Logic

The importer matches attributes using a composite key: entity_type_id:attribute_code. This ensures attributes are matched correctly across entity types (customer vs product vs category).

Sources: lib/MahoCLI/Helper/SampleDataImporter.php150-158

SQL Transformation Tables

The remapSql() logic transforms all references to attribute IDs and option IDs across several EAV tables defined in TABLES_WITH_ATTRIBUTE_ID and TABLES_WITH_OPTION_ID.

TableColumns RemappedPurpose
catalog_product_entity_*attribute_idProduct value tables
catalog_category_entity_*attribute_idCategory value tables
catalog_eav_attributeattribute_idCatalog-specific attribute settings
eav_attribute_optionattribute_id, option_idAttribute options
eav_attribute_option_swatchoption_idVisual swatch mappings

Sources: lib/MahoCLI/Helper/SampleDataImporter.php46-65 lib/MahoCLI/Helper/SampleDataImporter.php70-72


Multi-Database Engine Support

Sample data SQL files are written in MySQL syntax. The system translates them for other database engines during the import phase using specialized adapters.

Engine Specific Handling

  • MySQL: Standard execution with backtick quoting.
  • PostgreSQL: Uses information_schema.columns for schema introspection and double-quote identifier quoting.
  • SQLite: Uses PRAGMA table_info for schema introspection and double-quote identifier quoting.

Sources: lib/MahoCLI/Helper/SampleDataImporter.php187-204 lib/MahoCLI/Helper/SampleDataImporter.php212-221


Key Classes and Methods

MahoCLI\Helper\SampleDataImporter

Core EAV attribute remapping engine.

MethodPurpose
__construct()Initializes PDO and loads table schemas/entity types
loadTableSchemas()Introspects DB for eav_attribute and catalog_eav_attribute columns
getTableColumns()Driver-specific logic to fetch column names (MySQL, PgSQL, SQLite)
quoteIdentifier()Driver-specific identifier quoting
loadEntityTypeIds()Loads mapping of entity_type_code to entity_type_id

Sources: lib/MahoCLI/Helper/SampleDataImporter.php129-135 lib/MahoCLI/Helper/SampleDataImporter.php171-175 lib/MahoCLI/Helper/SampleDataImporter.php180-207 lib/MahoCLI/Helper/SampleDataImporter.php212-221 lib/MahoCLI/Helper/SampleDataImporter.php150-158

System Localization Helpers

The installer also provides helpers to list available configuration options for localization.

CommandPurpose
sys:currenciesLists available currency codes via Mage::app()->getLocale()->getOptionCurrencies()
sys:localesLists available locale codes via Mage::app()->getLocale()->getOptionLocales()
sys:timezonesLists available timezones via Mage::app()->getLocale()->getOptionTimezones()

Sources: lib/MahoCLI/Commands/SysCurrencies.php33 lib/MahoCLI/Commands/SysLocales.php33 lib/MahoCLI/Commands/SysTimezones.php33