WP Manifestindependent plugin directory
manifest / ai / product-data-generator

Product Data Generator

Wordpress plugin that works with WooCommerce to generate product content.

by Nic Scott · github.com/nicscott01/product-data-generator · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/nicscott01/product-data-generator/archive/refs/heads/main.zip

A powerful WooCommerce plugin that uses AI to automatically generate product descriptions, short descriptions, and other product content. Features a flexible template/config system for customizing AI prompts and data aggregation.

Features

  • 🤖 AI-Powered Content Generation - Uses WordPress AI Client with GPT models
  • 📝 Multiple Templates - Built-in templates for descriptions, short descriptions, and SEO content
  • ⚙️ Flexible Configuration - Extensive customization through config system and hooks
  • 🎨 Custom Templates - Easy to create your own templates for specific needs
  • 🔌 Developer-Friendly - Comprehensive hooks, filters, and extension points
  • 📦 Preset Configurations - Pre-configured settings for common use cases
  • 💾 Auto-Save - Optionally save generated content automatically
  • 🎯 Context-Aware - Provide custom context for better, more targeted content

Requirements

Installation

  1. Upload the plugin to /wp-content/plugins/product-data-generator/
  2. Run composer install in the plugin directory
  3. Activate the plugin through WordPress admin
  4. Ensure WooCommerce is installed and activated
cd wp-content/plugins/product-data-generator
composer install

Quick Usage

Basic Example

// Generate a product description
$result = ProductDataGenerator\generate_product_content( $product_id );

if ( ! is_wp_error( $result ) ) {
    echo $result['content'];
}

With Custom Context

$config = [
    'context' => [
        'brand_voice' => 'professional and friendly',
        'target_audience' => 'young professionals',
    ],
    'auto_save' => true,
];

$result = ProductDataGenerator\generate_product_content( 
    $product_id, 
    'product_description', 
    $config 
);

Using Presets

// Use a preset configuration
$generator = ProductDataGenerator\AI_Generator::from_preset( 
    'short_description', 
    $product_id 
);

$result = $generator->generate();
$generator->save( $result['content'] );

Built-in Templates

Product Description (product_description)

Generates comprehensive, engaging product descriptions optimized for e-commerce.

Features:

  • 300-500 words
  • SEO-friendly
  • Highlights benefits and features
  • Professional tone

Product Short Description (product_short_description)

Creates concise, impactful product summaries.

Features:

  • 50 words or less (configurable)
  • Attention-grabbing
  • Focuses on key benefits
  • Perfect for product cards

Product SEO (product_seo)

Generates SEO-optimized content with keyword integration.

Features:

  • Keyword-optimized
  • Structured with headings
  • Search intent matching
  • Schema markup support

Architecture

The plugin uses a modular architecture with four core components:

  1. Template - Base class defining data aggregation and prompt building
  2. Template Registry - Manages template registration and retrieval
  3. Template Config - Configuration management with presets
  4. AI Generator - Orchestrates the generation process

See FILE_STRUCTURE.md for detailed architecture documentation.

Configuration

Available Options

$config = [
    'template_id' => 'product_description',
    'product_id' => 123,
    'context' => [
        'brand_voice' => 'professional',
        'target_audience' => 'millennials',
        'word_limit' => 250,
    ],
    'ai_settings' => [
        'model' => 'gpt-4',
        'max_tokens' => 1000,
    ],
    'output_format' => 'html',
    'auto_save' => false,
    'field_mapping' => [
        'description' => 'post_content',
    ],
];

Available Presets

  • full_description - GPT-4, comprehensive descriptions
  • short_description - GPT-3.5-turbo, concise summaries
  • seo_optimized - GPT-4, SEO-focused content

Customization

Add Custom Product Data

add_filter( 'product_data_generator_description_product_data', function( $data, $product ) {
    $data['warranty'] = get_post_meta( $product->get_id(), '_warranty', true );
    $data['features'] = get_post_meta( $product->get_id(), '_features', true );
    return $data;
}, 10, 2 );

Modify AI Prompts

add_filter( 'product_data_generator_description_user_prompt', function( $prompt, $data ) {
    $prompt .= "\n\nEmphasize eco-friendliness and sustainability.";
    return $prompt;
}, 10, 2 );

Create Custom Template

class My_Template extends ProductDataGenerator\Template {
    // Implement required methods
    protected function aggregate_product_data() { /* ... */ }
    protected function build_system_prompt() { /* ... */ }
    protected function build_user_prompt() { /* ... */ }
}

// Register it
add_action( 'product_data_generator_register_templates', function() {
    ProductDataGenerator\Template_Registry::register( new My_Template() );
});

Hooks & Filters

Key Actions

  • product_data_generator_register_templates - Register custom templates
  • product_data_generator_before_generate - Before content generation
  • product_data_generator_after_generate - After content generation
  • product_data_generator_before_save - Before saving content
  • product_data_generator_after_save - After saving content

Key Filters

  • product_data_generator_prompt_data - Modify aggregated prompt data
  • product_data_generator_messages - Modify AI messages
  • product_data_generator_ai_params - Modify AI request parameters
  • product_data_generator_generated_content - Post-process generated content
  • product_data_generator_config_presets - Add custom presets

See TEMPLATE_SYSTEM.md for complete hooks documentation.

Documentation

Examples

Batch Generate

$product_ids = [123, 456, 789];

foreach ( $product_ids as $product_id ) {
    $result = ProductDataGenerator\generate_product_content( $product_id );
    if ( ! is_wp_error( $result ) ) {
        $generator = ProductDataGenerator\get_generator( 'product_description', $product_id );
        $generator->save( $result['content'] );
    }
    sleep( 2 ); // Rate limiting
}

WP-CLI Integration

WP_CLI::add_command( 'product generate', function( $args ) {
    $product_id = $args[0];
    $result = ProductDataGenerator\generate_product_content( $product_id );
    // ...
});

REST API

register_rest_route( 'pdg/v1', '/generate/(?P<id>\d+)', [
    'methods' => 'POST',
    'callback' => function( $request ) {
        return ProductDataGenerator\generate_product_content( 
            $request->get_param( 'id' ) 
        );
    },
]);

See examples.php for more complete examples.

Best Practices

  1. ✅ Always check for WP_Error responses
  2. ✅ Use presets for consistency
  3. ✅ Provide context for better results
  4. ✅ Add rate limiting for batch operations
  5. ✅ Test generation before auto-saving
  6. ✅ Monitor AI API costs
  7. ✅ Cache generated content when possible

Troubleshooting

Recent Queue Failure Explanation

In May 2026, a product queue failed because the AI service stopped accepting one of the optional tuning settings this plugin was sending with each request: temperature.

In client-friendly terms: the plugin was still asking the AI service to use an older "creativity level" control. The AI provider changed its rules for the current model and now rejects that setting. Because every book in the queue used the same AI request format, each book failed for the same reason. The products were not bad, and the queue itself was not broken; the AI request needed to be updated to match the provider's current requirements.

Version 0.0.4 stopped sending that setting by default and added clearer logging when a queue item fails, so future issues should show a useful reason in the WordPress debug log. Version 0.0.5 removes the temperature controls from the admin interface so the settings shown to staff match what the AI service now supports.

Common Issues

"Template not found"

// Check registered templates
$templates = ProductDataGenerator\Template_Registry::get_all();
var_dump( array_keys( $templates ) );

"WordPress AI Client not found"

cd wp-content/plugins/product-data-generator
composer install

Generation errors

$result = ProductDataGenerator\generate_product_content( 123 );
if ( is_wp_error( $result ) ) {
    error_log( $result->get_error_message() );
}

Roadmap

  • [ ] Admin UI for easy generation from product edit screen
  • [ ] Bulk generation admin interface
  • [ ] Generation history and versioning
  • [ ] A/B testing for generated content
  • [ ] Multi-language support
  • [ ] More built-in templates
  • [ ] Analytics and performance tracking

Contributing

Contributions are welcome! Please:

  1. Follow WordPress coding standards
  2. Add comprehensive docblocks
  3. Include examples for new features
  4. Test with multiple product types
  5. Update documentation

Support

  • Documentation: Start with QUICKSTART.md
  • Examples: Check examples.php
  • Issues: Review error messages and logs
  • Code: All classes are well-documented

Credits

License

This plugin is licensed under the GPL v2 or later.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

Changelog

0.0.8

  • Reconcile queue progress only after all Action Scheduler workers have settled, preventing a lost concurrent progress update from leaving a queue permanently marked as processing.
  • Recover scheduled queues that have no worker actions left by rebuilding their result counts and recording any missing worker result as a failure.
  • Mark queues with failed items as failed rather than completed, so recurring queues can recover cleanly on their next scheduled run.

0.0.7

  • Prefer a stable AI model for generation.

0.0.6

  • Serialize per-product queue pre-tasks so AI generation waits for product data fetching to finish.
  • Reschedule template jobs that encounter an in-progress pre-task for the same product.

0.0.5

  • Remove temperature controls from the product editor and queue admin interfaces.
  • Stop submitting temperature values from manual generation UI.

0.0.4

  • Stop sending the deprecated temperature parameter by default to avoid 400 errors from newer AI models.
  • Share AI request setup between manual generation, generator calls, and queue processing.
  • Log manual generation and queue item failures to the WordPress debug log with queue, product, template, and error details.

0.0.1

  • Initial release
  • Template/config system implementation
  • Three built-in templates
  • Comprehensive documentation
  • Example code and usage patterns