Product Data Generator
Wordpress plugin that works with WooCommerce to generate product content.
by Nic Scott · github.com/nicscott01/product-data-generator · website
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.zipA 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
- WordPress 6.0+
- PHP 7.4+
- WooCommerce 7.0+
- WordPress AI Client ^0.2
Installation
- Upload the plugin to
/wp-content/plugins/product-data-generator/ - Run
composer installin the plugin directory - Activate the plugin through WordPress admin
- 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:
- Template - Base class defining data aggregation and prompt building
- Template Registry - Manages template registration and retrieval
- Template Config - Configuration management with presets
- 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 descriptionsshort_description- GPT-3.5-turbo, concise summariesseo_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 templatesproduct_data_generator_before_generate- Before content generationproduct_data_generator_after_generate- After content generationproduct_data_generator_before_save- Before saving contentproduct_data_generator_after_save- After saving content
Key Filters
product_data_generator_prompt_data- Modify aggregated prompt dataproduct_data_generator_messages- Modify AI messagesproduct_data_generator_ai_params- Modify AI request parametersproduct_data_generator_generated_content- Post-process generated contentproduct_data_generator_config_presets- Add custom presets
See TEMPLATE_SYSTEM.md for complete hooks documentation.
Documentation
- QUICKSTART.md - Get started in 5 minutes
- TEMPLATE_SYSTEM.md - Comprehensive system documentation
- FILE_STRUCTURE.md - Architecture and file structure
- examples.php - 14 practical code examples
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
- ✅ Always check for
WP_Errorresponses - ✅ Use presets for consistency
- ✅ Provide context for better results
- ✅ Add rate limiting for batch operations
- ✅ Test generation before auto-saving
- ✅ Monitor AI API costs
- ✅ 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:
- Follow WordPress coding standards
- Add comprehensive docblocks
- Include examples for new features
- Test with multiple product types
- 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
- Author: Nic Scott
- Company: Creare Web Solutions
- License: GPL v2 or later
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
temperatureparameter 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