Filtering products on import
Import only part of a large feed instead of the whole catalog.
Marketplace feeds are often far larger than what you actually need. An affiliate network may only offer one broad category file — for example a single "Arts & Entertainment" feed with 1.6 million Etsy products, when your site only covers party supplies.
The import filter solves this. Products are matched before they are written to your database, so only the ones you want are stored.
Setting it up
In the module settings you'll find three fields:
Filter products by — which field to match against: Category, Title, or Brand.
Filter mode — Include matching products (keep only matches) or Exclude matching products (keep everything else).
Filter values — one value per line. Leave empty to import every product.
Matching is case-insensitive and partial, so you don't have to type a value exactly. This matters most for categories, which are usually hierarchical: filtering on Party Supplies also keeps Party & Celebration~~Party Supplies~~Party Games and every other subcategory beneath it. Multiple lines are combined with OR — a product is a match if it matches any one of them.
After the import, the feed status shows how many rows were skipped, for example Skipped rows: 1,626,235 filtered. If that number is the entire feed, your filter matched nothing — check the mapping and the exact spelling of your values.
Filtering reduces what is stored, not what is downloaded. The full feed file is still fetched and parsed on every sync, so a very large feed takes the same time and disk space as before. If the import exceeds your server's time limit, ask your network for a narrower category feed, or run the sync from system cron using WP‑CLI, which has no PHP execution limit.
Changing any filter setting re-imports the feed with the new rules.
Filtering with code
When the three fields aren't enough — combining conditions, matching on price, or reading a field the UI doesn't offer — use the cegg_feed_product_filter hook. Return false to skip a product. It runs for every row, in addition to any filter configured in the settings.
add_filter('cegg_feed_product_filter', function ($keep, $product, $module_id) {
// Only apply this to one feed module.
if ($module_id !== 'Feed__1') {
return $keep;
}
// Skip anything under 10.00.
if ($product['price'] < 10) {
return false;
}
// Keep party games, but not the printable ones.
if (stripos($product['category'], 'Party Games') === false) {
return false;
}
return stripos($product['title'], 'printable') === false;
}, 10, 3);The $product array holds the mapped fields — title, price, category, brand, ean, orig_url, stock_status and the rest. Add the snippet to your theme's functions.php or a small custom plugin, then reload the feed data so it applies.
Last updated