Hi David,
I've been looking around the forum for some code - I've found something close but I just need a pointer.
I've seen you can add custom global filters in the includes/admin.php like this:
// Custom filters
$importRecord["description"] = strip_tags($importRecord["description"]);
/* apply user filters */
$filter_dropRecordFlag = false;
Can you show me the code to DROP all records containing, I guess, an array of keywords such as "mens, men's, men, infant, infant's" etc so I can just add to the list?
Thanks,
George
Hi again,
I've added the code like so:
// Custom filters - Remove Male, infants and anything else
$stopWords = array("mens","men's","men","mens'","infant","infant's","infants","infants'","boys","boy's","boy","boys'"); // add to as required all lower case
$checkFields = array("name","description","fields/gender"); // list of fields to check for stop words in
foreach($checkFields as $checkField)
{
foreach($stopWords as $stopWord)
{
if (strpos(strtolower($record[$checkField]),$stopWord) !== FALSE) return;
}
}
Removed the filters via the Admin area and then re-ran the feed but it doesn't seem to have filtered anything?
Have I gone wrong somewhere?
Thanks,
George
Hi George,
I'd used $record instead of $importRecord... so this line:
if (strpos(strtolower($record[$checkField]),$stopWord) !== FALSE) return;
...should be:
if (strpos(strtolower($importRecord[$checkField]),$stopWord) !== FALSE) return;
Regarding your custom fields; in this case the value in $checkField should be the field name in the database rather then the feed, so assuming that you have created a new field "gender", use that in place of "fields/gender"...
Hope this helps
Cheers,
David.
Hi George,
That's straight forward - at the point above (immediately before /* apply user filters */ ) try something like this:
$stopWords = array("mens","men's","men"); // add to as required all lower case
$checkFields = array("name","description"); // list of fields to check for stop words in
foreach($checkFields as $checkField)
{
foreach($stopWords as $stopWord)
{
if (strpos(strtolower($importRecord[$checkField]),$stopWord) !== FALSE) return;
}
}
Hope this helps!
Cheers,
David.