DEV Community

Thesius Code
Thesius Code

Posted on • Originally published at datanest-stores.pages.dev

Product Catalog Manager

Product Catalog Manager

Bulk product import/export, hierarchical category management, variant handling, SEO metadata generation, and image optimization. Manage thousands of SKUs efficiently from a single interface.

Key Features

  • Bulk Import/Export — CSV and JSON support with validation and error reporting
  • Category Management — Hierarchical category trees with inheritance rules
  • Variant Handling — Size, color, material combinations with SKU auto-generation
  • SEO Metadata — Auto-generate titles, descriptions, and URL slugs from product data
  • Image Optimization — Resize, compress, and generate alt-text for product images
  • Data Validation — Schema enforcement, duplicate detection, required field checks

Quick Start

# 1. Extract and configure
unzip product-catalog-manager.zip
cd product-catalog-manager
cp config.example.yaml config.yaml

# 2. Import your product catalog
python -m product_catalog.core --import products.csv --validate

# 3. Generate SEO metadata
python -m product_catalog.core --generate-seo --output catalog_with_seo.csv
Enter fullscreen mode Exit fullscreen mode

Architecture

src/product_catalog/
├── core.py              # Import/export engine, validation pipeline
├── categories.py        # Category tree CRUD, parent-child relationships
├── variants.py          # Variant matrix generation, SKU builder
├── seo.py               # Title/description/slug generation from templates
├── images.py            # Resize, compress, alt-text generation
└── utils.py             # CSV/JSON parsing, slug generation, deduplication
Enter fullscreen mode Exit fullscreen mode

Usage Examples

Bulk Import with Validation

from product_catalog.core import CatalogManager

catalog = CatalogManager(config_path="config.yaml")

result = catalog.import_csv("products.csv", validate=True)
print(f"Imported: {result['imported']}, Skipped: {result['skipped']}, "
      f"Errors: {result['errors']}")

for error in result["error_details"][:3]:
    print(f"  Row {error['row']}: {error['message']}")
Enter fullscreen mode Exit fullscreen mode

Generate Variants

from product_catalog.variants import VariantGenerator

gen = VariantGenerator(sku_template="{base}-{color}-{size}")

variants = gen.generate(
    base_sku="TSHIRT",
    attributes={
        "color": ["red", "blue", "black"],
        "size": ["S", "M", "L", "XL"]
    },
    base_price=24.99,
    price_adjustments={"XL": 5.00}  # XL costs $5 more
)

for v in variants[:4]:
    print(f"  {v['sku']}: ${v['price']:.2f}")
# TSHIRT-RED-S: $24.99
# TSHIRT-RED-M: $24.99
# TSHIRT-RED-L: $24.99
# TSHIRT-RED-XL: $29.99
Enter fullscreen mode Exit fullscreen mode

SEO Metadata Generation

from product_catalog.seo import SEOGenerator

seo = SEOGenerator(
    title_template="{name} - {category} | Your Store",
    description_max_length=160
)

meta = seo.generate(product={
    "name": "Classic Blue Widget",
    "category": "Widgets",
    "description": "A premium blue widget for everyday use.",
    "price": 29.99
})

print(f"Title: {meta['title']}")
print(f"Slug: {meta['slug']}")
print(f"Meta description: {meta['meta_description']}")
Enter fullscreen mode Exit fullscreen mode

Category Hierarchy Query

-- Full category tree with product counts
WITH RECURSIVE category_tree AS (
    SELECT id, name, parent_id, name AS full_path, 0 AS depth
    FROM categories WHERE parent_id IS NULL
    UNION ALL
    SELECT c.id, c.name, c.parent_id,
           ct.full_path || ' > ' || c.name, ct.depth + 1
    FROM categories c JOIN category_tree ct ON c.parent_id = ct.id
)
SELECT ct.full_path, ct.depth, COUNT(p.id) AS product_count
FROM category_tree ct
LEFT JOIN products p ON p.category_id = ct.id
GROUP BY ct.full_path, ct.depth ORDER BY ct.full_path;
Enter fullscreen mode Exit fullscreen mode

Configuration

import:
  format: "csv"                    # csv | json
  delimiter: ","
  encoding: "utf-8"
  required_fields: ["sku", "name", "price", "category"]
  duplicate_strategy: "update"     # update | skip | error
  validate_on_import: true

categories:
  max_depth: 5                     # Maximum nesting levels
  separator: " > "                 # Display separator for breadcrumbs

variants:
  sku_template: "{base}-{color}-{size}"
  max_variants_per_product: 100

seo:
  title_template: "{name} | {category}"
  title_max_length: 60
  description_max_length: 160
  slug_separator: "-"
  auto_generate_on_import: true

images:
  max_width: 1200
  max_height: 1200
  quality: 85                      # JPEG compression quality
  formats: ["jpg", "webp"]
  generate_alt_text: true
Enter fullscreen mode Exit fullscreen mode

Best Practices

  1. Validate before importing — Always use --validate flag to catch issues pre-import
  2. Use consistent SKU patterns — Define a template and enforce it programmatically
  3. Limit category depth — 3-4 levels is optimal; deeper trees confuse customers
  4. Generate SEO metadata early — Don't publish products without title/description/slug
  5. Deduplicate regularly — Run duplicate detection monthly on large catalogs

Troubleshooting

Issue Cause Fix
Import fails with encoding error Non-UTF-8 characters in CSV Set encoding: "latin-1" or clean source file
Duplicate SKUs on import Same SKU in multiple rows Set duplicate_strategy: "update"
SEO titles truncated Title exceeds 60 characters Shorten title_template or product names
Variant explosion Too many attribute combinations Limit attributes or set max_variants_per_product

This is 1 of 11 resources in the Retail Automation Pro toolkit. Get the complete [Product Catalog Manager] with all files, templates, and documentation for $39.

Get the Full Kit →

Or grab the entire Retail Automation Pro bundle (11 products) for $139 — save 30%.

Get the Complete Bundle →


Related Articles

Top comments (0)