XML Feed Generator
A WordPress plugin for generating XML feeds for price comparison sites (Heureka format).
by Táňa Poláková · github.com/polakova/wp-custom-plugin-xml-feed-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/polakova/wp-custom-plugin-xml-feed-generator/archive/refs/heads/main.zipA professional WordPress plugin for generating XML feeds for price comparison sites (Heureka format). Features background processing, caching, and a user-friendly admin interface.
Features
- Background Processing: Efficiently processes large product catalogs (60k+ products) using cursor-based pagination
- Caching System: Pre-generates feeds for optimal performance with automatic cache management
- Admin Interface: Easy-to-use admin panel for managing feed generation and scheduling
- WooCommerce Integration: Seamlessly integrates with WooCommerce product data
- ACF Support: Works with Advanced Custom Fields for custom product metadata
- Memory Efficient: Optimized for large catalogs with minimal memory footprint
- Scheduled Generation: Automatic daily feed generation via WordPress cron
Requirements
- WordPress 5.8 or higher
- PHP 7.4 or higher
- WooCommerce 5.0 or higher
- Advanced Custom Fields (ACF) - Optional, for custom fields support
Installation
- Download or clone this repository
- Upload the plugin folder to
/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to 'XML Feed Export' in the WordPress admin menu
Configuration
Basic Setup
- Go to XML Feed Export in the WordPress admin menu
- The feed will be automatically available at:
https://yoursite.com/export/heureka.xml - Click Schedule Daily Cron to enable automatic daily feed generation
Product Requirements
For products to be included in the feed:
- Must be in the "Pneumatiky" product category
- Must have stock available (local or external warehouse)
- Must have the ACF field "cmat" set
- Must have "poslat_do_heureky" meta field set to "1" (or not set at all)
Stock Checking
The plugin checks for stock in two ways:
- Local Stock: Products managing stock with quantity > 0
- External Warehouse: ACF repeater field "external_warehouse" with quantity >= 2
Usage
Viewing the Feed
The XML feed is accessible at:
https://yoursite.com/export/heureka.xml
Manual Generation
- Go to XML Feed Export in WordPress admin
- Click Generate Feed Now to manually trigger feed generation
- The generation process runs in the background and may take several minutes for large catalogs
Scheduled Generation
- Go to XML Feed Export in WordPress admin
- Click Schedule Daily Cron to enable automatic daily generation at 2:00 AM
- The feed will be automatically regenerated daily
Cache Management
- Cached feeds are served if they exist and are less than 25 hours old
- Cache files are stored in:
wp-content/uploads/xml-feed-generator-heureka-feed.xml - The admin interface shows cache status, file size, and last modification time
Technical Details
Architecture
The plugin uses a three-step background processing system:
- Initiator (Step A): Creates the temp file, writes XML header, and schedules the worker
- Worker (Step B): Processes products in batches of 2000, writes to temp file
- Finalizer (Step C): Writes XML footer and renames temp file to final cache file
Performance Optimizations
- Cursor-based pagination: Uses
WHERE ID > cursor_idinstead ofOFFSETfor better performance - Direct meta queries: Bypasses WooCommerce product objects for faster stock checking
- Batch processing: Processes 2000 products per batch to balance memory and speed
- Memory management: Suspends cache addition during processing to prevent memory bloat
XML Format
The plugin generates XML in Heureka format with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<SHOP>
<SHOPITEM>
<ITEM_ID>...</ITEM_ID>
<PRODUCTNAME>...</PRODUCTNAME>
<PRODUCT>...</PRODUCT>
<DESCRIPTION>...</DESCRIPTION>
<URL>...</URL>
<PRICE>...</PRICE>
<PRICE_VAT>...</PRICE_VAT>
<VAT>...</VAT>
<MANUFACTURER>...</MANUFACTURER>
<CATEGORYTEXT>Pneumatiky</CATEGORYTEXT>
<EAN/>
<DELIVERY_DATE>0</DELIVERY_DATE>
<PRODUCTNO>...</PRODUCTNO>
<GIFT>2x Osviežovač vzduchu do auta</GIFT>
<IMGURL>...</IMGURL>
<DELIVERY>
<DELIVERY_ID>DPD</DELIVERY_ID>
<DELIVERY_PRICE>3.95</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>3.95</DELIVERY_PRICE_COD>
</DELIVERY>
</SHOPITEM>
</SHOP>
Development
File Structure
xml-feed-generator/
├── xml-feed-generator.php # Main plugin file
├── includes/
│ ├── class-feed-generator.php # Feed generation logic
│ ├── class-admin.php # Admin interface
│ └── class-stock-checker.php # Stock checking logic
└── README.md
Hooks and Filters
The plugin uses the following WordPress hooks:
xml_feed_generator_daily- Daily cron hookxml_feed_generator_worker- Background worker hookxml_feed_generator_finalizer- Finalization hook
Options
The plugin stores the following options:
xml_feed_generator_schedule- Cron schedule settingxml_feed_generator_cursor_id- Current processing cursor
Troubleshooting
Feed Not Generating
- Check that WooCommerce is active
- Verify products exist in the "Pneumatiky" category
- Check WordPress debug log for error messages
- Ensure write permissions on the uploads directory
Memory Issues
If you encounter memory errors:
- Reduce batch size in
class-feed-generator.php(line ~200) - Increase PHP memory limit in
php.ini - Check server logs for specific error messages
Cache Not Updating
- Clear the cache file manually from the uploads directory
- Unschedule and reschedule the cron job
- Manually trigger feed generation
Support
For issues, questions, or contributions, please open an issue on the GitHub repository.
License
GPL v2 or later
Changelog
1.0.0
- Initial release
- Background processing with cursor-based pagination
- Admin interface for feed management
- Scheduled daily generation
- Cache system for performance optimization