Hi David.
I have a feed with columns EAN and UPC.
Usually (95% of the feed), the EAN is correctly filled.
HOwever, sometimes is empty and the UPC appears.
Is any filter where I can take UPC only when EAN is empty and UPC is not?
Thanks!
Great David, both filters worked as expected.
However, I had to use /^$/ to avoid warning for PHP.
Ah yes, should have included the delimiters sorry - corrected and clarified above...
Cheers,
David.
--
PriceTapestry.com
Hi,
As per filtering for the brand twice in product name this could be solved by also adding a Search and Replace RegExp with %fieldname% placeholder support. To add the new filter, add the following code to includes/filter.php:
/*************************************************/
/* searchReplaceRegExpPlaceholder */
/*************************************************/
$filter_names["searchReplaceRegExp"] = "Search and Replace (RegExp/Placeholder)";
function filter_searchReplaceRegExpPlaceholderConfigure($filter_data)
{
widget_textBox("Search","search",TRUE,$filter_data["search"],"",3);
widget_textBox("Replace","replace",FALSE,$filter_data["replace"],"",3);
}
function filter_searchReplaceRegExpPlaceholderValidate($filter_data)
{
if (!$filter_data["search"])
{
widget_errorSet("search","required field");
}
}
function filter_searchReplaceRegExpPlaceholderExec($filter_data,$text)
{
$filter_data["search"] = filter_recordPlaceholders($filter_data["search"]);
$filter_data["replace"] = filter_recordPlaceholders($filter_data["replace"]);
return trim(preg_replace($filter_data["search"],$filter_data["replace"],$text));
}
With that in place, add a new Search and Replace (RegExp/Placeholder) filter to the EAN field and for Search use:
/^$/
(In a regular expression ^ is the beginning of line anchor and $ is the end of line anchor - forward slashes used as delimiters in this case - so this will only match if the EAN field is empty)
...and for Replace use:
%upc%
...where upc is the actual field name of the field containing the UPC in the feed...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com