Hi,
Is it possible to add a filter to all feeds to only show products between a certain prcie range, ie dump products under $50
Thanks
Hi David,
I want to get such function as a import filter module, so how can I do this? (changes in includes/filters.php ?)
for example: Don´t import all Products with prices under $20
Thanks and Regards,
Harry
Hi Harry,
Sure - i've just written a "Min Max" filter which will do this - you can enter both min or max or just one of them if you only want a minimum or maximum; so in your case just enter "20" (without the quotes) in the Min box. Here's the code:
/*************************************************/
/* minMax */
/*************************************************/
$filter_names["minMax"] = "Min Max";
function filter_minMaxConfigure($filter_data)
{
print "Min:<br />";
print "<input type='text' name='min' value='".widget_safe($filter_data["min"])."' />";
widget_errorGet("min");
print "<br /><br />";
print "Max:<br />";
print "<input type='text' name='max' value='".widget_safe($filter_data["max"])."' />";
widget_errorGet("max");
}
function filter_minMaxValidate($filter_data)
{
if ($filter_data["min"] && !is_numeric($filter_data["min"]))
{
widget_errorSet("min","must be numeric");
}
if ($filter_data["max"] && !is_numeric($filter_data["max"]))
{
widget_errorSet("max","must be numeric");
}
}
function filter_minMaxExec($filter_data,$text)
{
global $filter_dropRecordFlag;
if($filter_dropRecordFlag)
{
return $text;
}
else
{
$x = intval($text);
if ($filter_data["min"] && $filter_data["max"])
{
$filter_dropRecordFlag = ($x < $filter_data["min"] || $x > $filter_data["max"]);
}
elseif($filter_data["min"])
{
$filter_dropRecordFlag = ($x < $filter_data["min"]);
}
elseif($filter_data["max"])
{
$filter_dropRecordFlag = ($x > $filter_data["max"]);
}
}
return $text;
}
Cheers,
David.
Hi,
If you want to filter ALL merchants, then rather than writing a new filter module (which would mean that you could do this selectively using the "Filters" feature), the easiest way would be to just drop the products you don't want based on price in the import function.
During import, the price is fixed up by the following code on line 168 in includes/admin.php:
$record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);
Simply change this as follows to drop any product below $50:
$record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);
if ($record[$admin_importFeed["field_price"]] < 50) return;
That should do the trick!
Cheers,
David.