## Filter: wpd_ai_show_product_variations

Control whether product variations are included in analytics data queries. This affects how product-level data is aggregated in reports.

### Description

By default, Alpha Insights includes product variations in analytics queries. This filter allows you to exclude variations and only show parent products, which can simplify reports and improve performance for stores with many variations.

#### Location

File: `includes/classes/WPDAI_Data_Warehouse.php`

Method: `WPDAI_Data_Warehouse::get_analytics_data()`

Line: ~6430

### Parameters

Parameter | Type | Description
--- | --- | ---
$show_variations | bool | Whether to include product variations (default: true)

#### Return

Type: bool

Description: True to show variations, false to hide them

### Example Usage

### Hide Product Variations

    add_filter( 'wpd_ai_show_product_variations', '__return_false' );

### Conditional Display Based on User Role

    add_filter( 'wpd_ai_show_product_variations', 'hide_variations_for_customers' );
    function hide_variations_for_customers( $show_variations ) {
        // Hide variations for non-admin users
        if ( ! current_user_can( 'manage_options' ) ) {
            return false;
        }
        return $show_variations;
    }

### Hide Variations for Specific Report Types

    add_filter( 'wpd_ai_show_product_variations', 'hide_variations_in_summary_reports' );
    function hide_variations_in_summary_reports( $show_variations ) {
        // Check if this is a summary report
        if ( isset( $_GET['report_type'] ) && $_GET['report_type'] === 'summary' ) {
            return false;
        }
        return $show_variations;
    }

### Performance Optimization for Large Stores

    add_filter( 'wpd_ai_show_product_variations', 'optimize_for_large_stores' );
    function optimize_for_large_stores( $show_variations ) {
        // Get total product count
        $product_count = wp_count_posts( 'product' )->publish;

        // Hide variations if store has more than 10,000 products
        if ( $product_count > 10000 ) {
            return false;
        }

        return $show_variations;
    }

### Best Practices

- Keep variations enabled for detailed product analysis
- Disable variations for high-level summary reports
- Consider your store's variation structure before disabling
- Test reports after changing this setting
- Variations provide more granular data but increase query complexity

### Impact on Reports

When variations are hidden:

- Product sales are aggregated to parent products
- Variation-specific data is not available
- Reports may load faster with fewer products
- Less detailed product-level insights

When variations are shown:

- Each variation appears as a separate product
- More granular product performance data
- Reports may be more complex with many variations
- Better for stores with few variations per product

### Important Notes

- This affects all analytics queries, not individual reports
- Changing this setting may require clearing report caches
- Variation data is still stored, just not displayed
- Default (true) is recommended for most stores
- Consider your reporting needs before disabling

### Debugging

    add_filter( 'wpd_ai_show_product_variations', 'debug_variation_display', 999 );
    function debug_variation_display( $show_variations ) {
        error_log( 'Alpha Insights Show Variations: ' . ( $show_variations ? 'YES' : 'NO' ) );
        return $show_variations;
    }

### Related Classes

- `WPDAI_Data_Warehouse` - React dashboard data warehouse