You are here:  » Exclude a product if it contains a certain word on import

Support Forum



Exclude a product if it contains a certain word on import

Submitted by paddyman on Wed, 2009-11-18 17:02 in

Hi David

Would like to exclude all products containing the word "Preowned". Can you please advise how to do this with includes/admin.php ??

Cheers

Adrian

Submitted by support on Wed, 2009-11-18 17:20

Hi Adrian,

Add a "Drop Record" filter to the Product Name field, and enter "preowned". At the next import anything with Preowned in the title will not be imported!

Cheers,
David.

Submitted by paddyman on Wed, 2009-11-18 17:32

Hi David,

Sorry should have said I'm looking to do this for all feeds and looking for a way to do it once rather than have to create a filter for each feed.

Is this possible ?

Cheers

Adrian

Submitted by support on Wed, 2009-11-18 18:54

Hi Adrian,

Sure - you could plumb it into the import record handler function in includes/admin.php. Look for the following code around about line 152:

    if ($admin_importFeed["field_category"])

..and INSERT the following new code immediately BEFORE that line:

    if (strpos($importRecord["name"],"Preowned")!==FALSE) return;

Cheers,
David.

Submitted by paddyman on Wed, 2009-11-18 21:02

Hi David,

Many thanks for this. If I wanted to stop products with other words for example "console", could I plug that in to the code above with a pipe character, or would I need to repeat that line of code with the new word ?

Cheers

Adrian

Submitted by support on Wed, 2009-11-18 21:08

Hi Adrian,

Just repeating the line is the easiest way, but a slightly neater way of doing things would be:

  $stopWords = array("Preowned","second hand","resale");
  foreach($stopWords as $stopWord)
  {
    if (strpos($importRecord["name"],$stopWord)!==FALSE) return;
  }

...then just edit the $stopWords array with the words / phrases in quotes, comma separated.

Cheers,
David.