# Catalog Generator

> Open-source Magento 2 module for generating realistic test catalogs — products, categories, MSI inventory, attributes, and pricing rules

**Open Source** — [github.com/qoliber/m2-catalog-generator](https://github.com/qoliber/m2-catalog-generator) (MIT License)

A Magento 2 module for generating realistic test catalogs from YAML configuration files. Generate hundreds of thousands of products with categories, MSI inventory, custom attributes, tier prices, catalog rules, and more — all using high-performance direct SQL for speed.

## Why?

Performance testing, indexer benchmarking, and demo environments all need realistic catalog data. Magento's built-in performance toolkit is limited and slow. Catalog Generator creates a complete, realistic catalog in minutes — not hours — using direct SQL inserts with batched operations and low memory usage.

## Features

- **YAML-driven** — define your entire catalog in a single configuration file
- **All product types** — simple, configurable, bundle, and grouped with realistic variants
- **MSI Multi-Source Inventory** — configurable sources, stocks, sales channels, and per-source stock assignment
- **Custom EAV attributes** — dropdown and multiselect with configurable options, searchable/filterable flags
- **Custom product options** — dropdown, radio, checkbox, multi-select with realistic labels and random pricing
- **Tier prices** — percentage-based with configurable levels
- **Catalog price rules** — random discounts linked to all websites and customer groups
- **Realistic names** — products get names like "Alpine Merino Jacket", categories use 100+ real department names
- **Multi-website / multi-store** — websites, store groups, and store views with per-website root categories
- **Customer groups** — configurable additional groups beyond Magento defaults
- **URL rewrites** — automatic URL key and rewrite generation for products and categories
- **Randomized product images** — placeholder image generation
- **High performance** — direct SQL inserts in 5,000-row batches, ~250MB peak memory for 1M+ products
- **Progress tracking** — Symfony progress bars with %, elapsed time, ETA, and memory usage

## Quick Start

```bash
composer require qoliber/m2-catalog-generator
bin/magento module:enable Qoliber_CatalogGenerator
bin/magento setup:upgrade
```

Generate a catalog:

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/small.yml
```

<Admonition type="danger" title="Destructive Operation">
This command **completely wipes** the existing product catalog and related tables before generating new data. Only use in development or testing environments. The module requires developer mode to run.
</Admonition>

## Sample Configurations

The module ships with 5 ready-to-use YAML configurations in the `_samples/` directory, ranging from quick validation to million-product stress tests:

### test.yml — Quick Validation

Minimal catalog for verifying the module works correctly.

| Entity | Count |
|--------|-------|
| Categories | ~7 |
| Simple products | 20 |
| Configurable products | 3 (+ children) |
| Bundle products | 3 |
| Grouped products | 3 |
| Websites | 1 (2 store views) |
| Customer groups | 2 additional |
| MSI sources/stocks | 2 / 2 |
| Custom attributes | 3 (2 dropdown + 1 multiselect) |
| Catalog rules | 2 |

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/test.yml
```

---

### small.yml — Development

A practical catalog for everyday development and feature testing.

| Entity | Count |
|--------|-------|
| Categories | ~100 |
| Simple products | 500 |
| Configurable products | 50 (+ children) |
| Bundle products | 50 |
| Grouped products | 50 |
| Websites | 1 (2 store views) |
| Customer groups | 4 additional |
| MSI sources/stocks | 2 / 2 |
| Custom attributes | 5 (3 dropdown + 2 multiselect) |
| Custom options | 50 products (3 options each) |
| Tier price levels | 5 |
| Catalog rules | 3 |

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/small.yml
```

---

### medium.yml — Integration Testing

Multi-website catalog for testing cross-store features, MSI, and indexer performance.

| Entity | Count |
|--------|-------|
| Categories | ~600 |
| Simple products | 5,000 |
| Configurable products | 500 (+ children) |
| Bundle products | 200 |
| Grouped products | 200 |
| Websites | 2 (3 store views each) |
| Customer groups | 6 additional |
| MSI sources/stocks | 3 / 2 |
| Custom attributes | 8 (5 dropdown + 3 multiselect) |
| Custom options | 200 products (3 options each) |
| Tier price levels | 5 |
| Catalog rules | 3 |

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/medium.yml
```

---

### large.yml — Performance Benchmarking

The catalog used for [Optimized Indexes benchmarks](https://docs.qoliber.com/docs/extensions/speed/optimized-indexes/benchmarks) — 131K+ total products across 2 websites with 6 store views.

| Entity | Count |
|--------|-------|
| Categories | ~615 |
| Simple products | 75,000 |
| Configurable products | 3,000 (+ 27,000 children) |
| Bundle products | 1,500 (+ 18,000 children) |
| Grouped products | 750 (+ 6,000 children) |
| **Total products** | **~131,250** |
| Websites | 2 (3 store views each) |
| Customer groups | 8 additional |
| MSI sources/stocks | 4 / 2 |
| Custom attributes | 30 (15 dropdown + 15 multiselect) |
| Custom options | 500 products (4 options each) |
| Tier price levels | 3 |
| Catalog rules | 2 |

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/large.yml
```

---

### big.yml — Stress Testing

Massive catalog for stress-testing indexers, search engines, and infrastructure limits. Over 1 million total products.

| Entity | Count |
|--------|-------|
| Categories | ~800 |
| Simple products | 100,000 |
| Configurable products | 10,000 (+ ~160,000 children) |
| Bundle products | 5,000 (+ ~80,000 children) |
| Grouped products | 5,000 (+ ~40,000 children) |
| **Total products** | **~1,120,000+** |
| Websites | 3 (3 store views each) |
| Customer groups | 10 additional |
| MSI sources/stocks | 5 / 3 |
| Custom attributes | 20 (12 dropdown + 8 multiselect) |
| Custom options | 1,000 products (5 options each) |
| Tier price levels | 4 |
| Catalog rules | 4 |

```bash
bin/magento qoliber:catalog:generate vendor/qoliber/m2-catalog-generator/_samples/big.yml
```

<Admonition type="warning" title="Resource Requirements">
Image generation is disabled in `large.yml` and `big.yml` for performance. The `big.yml` config generates 1M+ products — ensure sufficient MySQL `max_allowed_packet` and `innodb_buffer_pool_size`.
</Admonition>

## YAML Configuration Reference

A configuration file defines your entire catalog. Here is the structure with all available options:

```yaml
clean_before_run: true      # Wipe existing catalog data before generating
prefix: 'qoliber'           # Prefix for generated entity names

entities:
  category:
    count: "1/2/5/10"       # Category tree: 1 root / 2 L1 / 5 L2 / 10 L3
    attributes:
      name: "resolver:category_name"  # Use realistic category names
      include_in_menu: 1
      is_active: 1
      is_anchor: 1
    tasks:
      - 'category:generate_url_attributes'

  website:
    count: 2                 # Number of websites
    stores_per_website: 3    # Store views per website
    tasks:
      - 'category:generate_urls'
      - 'website:assign_sales_channel'

  customer_group:
    count: 8                 # Additional groups beyond Magento defaults

  stock:
    msi_sources_count: 4     # MSI inventory sources
    msi_stock_count: 2       # MSI stocks (linked to sources automatically)
    tasks:
      - 'stock:link_sources'

  custom_attributes:
    dropdown:
      count: 15                        # Number of dropdown attributes
      options_per_attribute: 8         # Options per attribute
      product_assignment_percent: 30   # % of products that get values
      searchable: true
      filterable: true
    multiselect:
      count: 15
      options_per_attribute: 10
      product_assignment_percent: 20
      searchable: true
      filterable: true

  product:
    types:
      simple:
        count: 75000
      configurable:
        count: 3000
        options: [2, 3]      # 2 attributes x 3 options = 6 children each
      bundle:
        count: 1500
        options:              # Bundle option types and children per type
          checkbox: 3
          select: 3
          multi: 3
          radio: 3
      grouped:
        count: 750
        options: [8]          # 8 child products per grouped
    attributes:
      name: "resolver:name"  # Realistic product names
      price: 499
      status: 1
      tax_class_id: 2
      visibility: 4
      weight: 1.00
    custom_options:
      count: 500                  # Number of products to get custom options
      options_per_product: 4
      values_per_option: 4
    tier_prices:
      levels: 3               # Tier price levels (e.g., 3 = discounts at qty 2/5/10)
    tasks:
      - 'product:assign_to_categories'
      - 'product:assign_to_type_categories'
      - 'product:assign_custom_attributes'
      - 'product:assign_custom_options'
      - 'product:assign_tier_prices'
      - 'product:assign_stock'
      - 'product:assign_to_websites'
      - 'product:generate_images'    # Comment out for large catalogs
      - 'product:generate_url_keys'
      - 'product:generate_urls'

  catalog_rules:
    count: 2
    discount_type: by_percent
    discount_range: [5, 30]   # Random discount between 5-30%

  commands:
    tasks:
      - 'command:indexer:reindex'
      - 'command:cache:flush'
```

### Category Count Format

The `count` field uses a slash-separated format defining the tree structure:

```
"1/2/5/10" = 1 root → 2 level-1 → 5 level-2 → 10 level-3
```

The first level creates one root category per website. Total categories = product of all levels across the tree.

### Resolver System

Use `resolver:name` for realistic product names and `resolver:category_name` for category names:

- **Product names**: generated from adjective + material + product pools (e.g., "Alpine Merino Jacket", "Cedar Sunglasses")
- **Category names**: drawn from 100+ real department names (e.g., "Electronics", "Garden & Patio", "Men's Fashion")

## Requirements

- Magento Open Source, Mage-OS, or Adobe Commerce 2.4.6+
- PHP 8.1+
- **Developer mode only** — the module refuses to run in production mode

## Contributing

This is an open-source project under the MIT License. Contributions, bug reports, and feature requests are welcome on [GitHub](https://github.com/qoliber/m2-catalog-generator).
