I am puzzling my brain as to how I can work around a problem I'm experiencing with one particular merchant.
Using a combination of filters I've managed to ensure that all products are entered into the database in the format brand productid so I end up with urls like brandx-12345.html and products are then being correctly matched from different merchants and displayed correctly for price comparision.
However one particular merchant does not provide data in a separate fields for brand and productid, so with them I cannot use a search and replace and insert %BRAND% %PRODUCTID% to create a consistent product name.
Instead they have one product name field that takes the structure:
brandx product123 / descriptive text
During the import process the / is removed and I end up with:
brand productid descriptive text
url: brandx-product123-descriptive-text
This then doesn't match with the same products in the database which take the form
brandx-product123
Is there a way I could prevent the / from being stripped out on import then do a wildcard search and replace on the product name to remove anything after and including /
Or possibly a better way of doing this?
Thanks in advance.
Ok, I've come across another merchant where the product name is
brandx product123 descriptive text
However, there is no character I can use to call the explode feature.
There is no way I can build the product name from other fields as only data for brand is present in another field.
I can think of away around this to make it so the product name is brandx product123 to match with others
Hi,
Are "brandx" and "product123" ever likely to contain SPACES?
Cheers,
David.
There are some brand names that are two words but the vast majority are one word and the product code will not contain spaces so in the vast majority of cases there are no spaces. If something could work for the vast majority of cases, that would be better than not including this particular feed.
Many thanks for your quick response.
I have been using this excellent script for a year or so, although I have neglected the particular site that uses it until recently.
Hi,
What I was thinking was that you could modify the Explode filter to allow more than one return index (comma separated). This would let you split on the SPACE character, and then return indexes 0,1 to give you the first 2 words. This should do the trick:
<?php
/*************************************************/
/* explode */
/*************************************************/
$filter_names["explode"] = "Explode";
function filter_explodeConfigure($filter_data)
{
print "Explode Character or String:<br />";
print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
widget_errorGet("text");
print "<br />";
print "Return Index: (zero based)<br />";
print "<input type='text' size='3' name='index' value='".widget_safe($filter_data["index"])."' />";
widget_errorGet("index");
}
function filter_explodeValidate($filter_data)
{
if (!$filter_data["text"])
{
widget_errorSet("text","required field");
}
if (!$filter_data["index"])
{
widget_errorSet("index","required field");
}
}
function filter_explodeExec($filter_data,$text)
{
$parts = explode($filter_data["text"],$text);
$indexes = explode(",",$filter_data["index"]);
$newText = "";
foreach($indexes as $index)
{
$index = intval($index);
if ($index < 0)
{
$index = count($parts) + $index;
}
$newText .= " ".$parts[$index];
}
return trim($newText);
}
?>
Hope this helps!
Cheers,
David.
Hi,
You'll find something that should help in the following thread:
http://www.pricetapestry.com/node/898
That thread contains code that will add a new "Explode" filter to your site; so you can register a new Explode filter against these awkward product names, and use a return index of 0 (zero) which will return the value infront of the separator character.
However, before you can use this, you need to permit the / character in the product name, as it would ordinarily be stripped before reaching the filters. To do this, look for the following code, starting at line 158 of includes/admin.php:
/* apply standard filters */
$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);
To permit the / character, change this as follows:
/* apply standard filters */
$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]],"/");
That, in conjunction with the Explode filter should do the trick...!
Cheers,
David.