Useful hooks

How to Enable This Filter

To enable these filters, paste the code into the functions.php file of your active theme (preferably a child theme) by following these steps:

  • Go to Appearance → Theme File Editor in your WordPress dashboard, or access the file via FTP / file manager.

  • Open the functions.php file.

  • Paste the code at the bottom of the file and save.

Using a child theme is recommended to avoid losing changes during theme updates.

Disabling synchronization for selected products

To disable synchronization for selected products, add the following to the functions.php file of your theme:

add_filter('ei_disable_sync_product_ids', 'my_ei_disable_sync_product_ids');
function my_ei_disable_sync_product_ids() {
    return array(111, 222, 333, 444);
}

Replace 111, 222, 333, 444 with the actual product IDs.

Enabling synchronization only for selected products

/**
 * Only sync products 101, 202 and 303.
 *
 * @param int[] $ids  Current list of IDs to sync (empty by default).
 * @return int[]      Filtered list of IDs to sync.
 */
add_filter( 'ei_enable_sync_product_ids', function( $ids ) {
    // Override any existing list—only these three will be synced.
    return array( 101, 202, 303 );
} );
/**
 * Enabling synchronization only for products in a specific category.
 *
 * @param int[] $ids  Current list of product IDs to sync (empty by default).
 * @return int[]      Product IDs belonging to the 'featured-products' category.
 */
add_filter( 'ei_enable_sync_product_ids', function( $ids ) {
    // You can change 'featured-products' to any category slug
    $category_slug = 'featured-products';

    // This runs on every sync, so for large catalogs, consider caching the IDs
    $products_in_category = get_posts([
        'post_type'      => 'product',
        'posts_per_page' => -1,
        'fields'         => 'ids',
        'tax_query'      => [
            [
                'taxonomy' => 'product_cat',
                'field'    => 'slug',
                'terms'    => $category_slug,
            ],
        ],
    ]);

    return $products_in_category;
} );

Allowing HTML and images in product descriptions

To disable description sanitization and include all images and HTML formatting from the source site, add the following to the functions.php file of your theme:

add_filter('cegg_description_sanitization', '__return_false');

Import domain as brand taxonomy

For the Rehub theme only, to import the domain as the "brand" taxonomy, add the following to your functions.php file:

add_filter('ie_import_brand', '__return_false');
add_filter('ie_import_store', '__return_true');

Custom parameters for scraping services

// Add country_code parameter to ScraperAPI requests
add_filter('ei_parse_url_scraperapi', 'my_ei_parse_url_scraperapi', 10, 1);
function my_ei_parse_url_scraperapi($url) {
    return add_query_arg('country_code', 'de', $url);
}

// Add country parameter to ScrapingDog requests
add_filter('ei_parse_url_scrapingdog', 'my_ei_parse_url_scrapingdog_country', 10, 1);
function my_ei_parse_url_scrapingdog_country($url) {
    return add_query_arg('country', 'de', $url);
}

// Add dynamic parameter to ScrapingDog requests
add_filter('ei_parse_url_scrapingdog', 'my_ei_parse_url_scrapingdog_dynamic', 10, 1);
function my_ei_parse_url_scrapingdog_dynamic($url) {
    return add_query_arg('dynamic', 'true', $url);
}

// Add premium parameter to ScrapingDog requests
add_filter('ei_parse_url_scrapingdog', 'my_ei_parse_url_scrapingdog_premium', 10, 1);
function my_ei_parse_url_scrapingdog_premium($url) {
    return add_query_arg('premium', 'yes', $url);
}

Last updated

Was this helpful?