You are here:  » Exclude product globally

Support Forum



Exclude product globally

Submitted by kevinsan on Tue, 2009-10-20 04:36 in

I have a product across several datafeeds that I want to exclude from view. Is there an easy way to exclude individual products globally without editing the datafeeds?

Submitted by support on Tue, 2009-10-20 07:32

Hi,

Other than using the Drop Record filter on each feed; it's easy to add a global drop for a specified product name within the import record handler function. To do this, in includes/admin.php, look for the following comment on line 158:

    /* apply standard filters */

...and immediately before that point, add the following new code:

    if ($record[$admin_importFeed["field_name"]]=="Product Name") return;

...and that will drop any product called exactly "Product Name" from the import.

Alternatively, to drop by keyword rather than the whole product name, use:

    if (strpos($record[$admin_importFeed["field_name"]],"Keyword")!==FALSE) return;

Cheers,
David.

Submitted by kevinsan on Tue, 2009-10-20 10:02

Thanks David,

I have multiple products to exclude globally.

Using:

if ($record[$admin_importFeed["field_name"]]=="Product Name") return;

Should I use one line per product or is there a way to add multiple products to the if statement?

Submitted by support on Tue, 2009-10-20 10:22

Hi,

A neat way to drop multiple products is something like this;

$dropProducts = array("Product 1","Product 2","Product 3");
foreach($dropProducts as $dropProduct)
{
  if ($record[$admin_importFeed["field_name"]]==$dropProduct) return;
}

Cheers,
David.

Submitted by kevinsan on Tue, 2010-01-19 02:53

Hi David,

On the latest version of PT I would like to drop multiple categories. Similar to dropping products in the post above.

Can you provide the code and location to place the code.

Thanks.

Submitted by support on Tue, 2010-01-19 10:37

Hi,

You could insert the code immediately BEFORE category mapping if you're only interested in dropping categories coming from the feeds (which I presume would be the case). Look for the following comment around line 203 of includes/admin.php

/* apply category mappings */

...and insert the following code to drop selected categories:

$dropCategories = array("Category 1","Category 2","Category 3");
if (in_array($importRecord["category"],$dropCategories)) return;

Hope this helps!

Cheers,
David.