Refinery Product Recommendations includes built-in WP-CLI commands for fetching recommendations, managing relevancy generation, viewing analytics, and clearing caches from the command line. These commands are useful for debugging recommendations, triggering generation on demand, monitoring performance, and integration with AI development tools like Claude Code.
Prerequisites
- WP-CLI version 2.5 or later
- WooCommerce installed and active
- A WordPress user with the
manage_woocommercecapability
Recommendation commands
Get recommendations
Fetch product recommendations for a specific product. Returns a table of recommended products with name, price, and stock status.
wp refinery recommendations get 42
wp refinery recommendations get 42 --placement=shortcode_default --format=json
wp refinery recommendations get 42 --format=ids
Options:
--placement=<key>— Placement key to use (default:product_single). View available placements with theplacementscommand.--format=<format>—table,json, orids(comma-separated product IDs)
If the product does not exist, the command exits with an error. If no recommendations are found, a warning is displayed.
Configuration commands
List strategies
List all configured recommendation strategies with their key, name, description, and enabled status.
wp refinery recommendations strategies
wp refinery recommendations strategies --format=json
List placements
List all configured recommendation placements with their key, name, location, and enabled status.
wp refinery recommendations placements
wp refinery recommendations placements --format=json
Generation commands
Generate relevancy scores
Trigger a synchronous relevancy score generation. Products are processed in batches and progress is displayed as the generation runs. Optionally limit generation to a single strategy.
wp refinery recommendations generate
wp refinery recommendations generate --strategy=default
Options:
--strategy=<key>— Limit generation to a single strategy key
The command includes safety limits to prevent infinite loops. If the batch offset does not advance or the maximum iteration count is exceeded, the command exits with an error.
Check generation status
Check whether a relevancy generation is currently in progress.
wp refinery recommendations generate-status
Analytics
Display recommendation performance analytics including clicks, conversions, conversion rate, and revenue.
wp refinery recommendations analytics
wp refinery recommendations analytics --days=7 --format=json
wp refinery recommendations analytics --days=0
Options:
--days=<number>— Number of days to include. Use0for all time. (default: 30)--format=<format>—tableorjson
Cache management
Clear cached recommendation results. Optionally target a single product.
wp refinery recommendations cache-clear
wp refinery recommendations cache-clear --product_id=42
Options:
--product_id=<id>— Clear cache for a specific product. Omit to clear all recommendation caches.