WP Manifestindependent plugin directory
manifest / ecommerce / wp-custom-plugin-xml-feed-generator

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

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/polakova/wp-custom-plugin-xml-feed-generator/archive/refs/heads/main.zip

A 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

  1. Download or clone this repository
  2. Upload the plugin folder to /wp-content/plugins/ directory
  3. Activate the plugin through the 'Plugins' menu in WordPress
  4. Navigate to 'XML Feed Export' in the WordPress admin menu

Configuration

Basic Setup

  1. Go to XML Feed Export in the WordPress admin menu
  2. The feed will be automatically available at: https://yoursite.com/export/heureka.xml
  3. 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:

  1. Local Stock: Products managing stock with quantity > 0
  2. 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

  1. Go to XML Feed Export in WordPress admin
  2. Click Generate Feed Now to manually trigger feed generation
  3. The generation process runs in the background and may take several minutes for large catalogs

Scheduled Generation

  1. Go to XML Feed Export in WordPress admin
  2. Click Schedule Daily Cron to enable automatic daily generation at 2:00 AM
  3. 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:

  1. Initiator (Step A): Creates the temp file, writes XML header, and schedules the worker
  2. Worker (Step B): Processes products in batches of 2000, writes to temp file
  3. Finalizer (Step C): Writes XML footer and renames temp file to final cache file

Performance Optimizations

  • Cursor-based pagination: Uses WHERE ID > cursor_id instead of OFFSET for 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 hook
  • xml_feed_generator_worker - Background worker hook
  • xml_feed_generator_finalizer - Finalization hook

Options

The plugin stores the following options:

  • xml_feed_generator_schedule - Cron schedule setting
  • xml_feed_generator_cursor_id - Current processing cursor

Troubleshooting

Feed Not Generating

  1. Check that WooCommerce is active
  2. Verify products exist in the "Pneumatiky" category
  3. Check WordPress debug log for error messages
  4. Ensure write permissions on the uploads directory

Memory Issues

If you encounter memory errors:

  1. Reduce batch size in class-feed-generator.php (line ~200)
  2. Increase PHP memory limit in php.ini
  3. Check server logs for specific error messages

Cache Not Updating

  1. Clear the cache file manually from the uploads directory
  2. Unschedule and reschedule the cron job
  3. 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