Dave,
I've added a product id field as described in these messages:
http://www.pricetapestry.com/node/313
http://www.pricetapestry.com/node/775
Everything is working as expected, however leave it to the merchants to make things complicated. :)They all use the manufactures product id, but they tweak it a little. Either by adding a space or a dash.
i.e.
AR-108FK
AR 108 FK
Secondly, some add some extra characters, their own code, to the product id.
i.e.
RSI-AR108FK
I know there is no way to automatically remove their added characters, but presuming there is an automated way during import to remove the spaces and dashes, would it be possible to compare the product id based on a %like% using the shortest product id?
The way I think it would work is, the script will look for a product with the product id of AR108FK and find all products that have those characters including RSIAR108FK.
Of course I think there could be an issue if someone clicks the product RSIAR108FK
as the script wouldn't be able to find the other products with the AR108FK product ids.
Any thoughts on how I can solve the spaces/dashes during import and find product ids that are similar to each other to within 5 or 6 characters?
Well, the spaces and dashes was easy enough.
Have you made any changes to search.php as yet to support the new field?
No, there have been no changes to the search.php at this point. I didn't see anything in the other messages addressing the search.php so I left it alone. I certainly would prefer to have a full text search over loosing it.
(edited) I see you're actually already doing what I asked about (edited)
I don't know that the MakeIndex.php will be a good option, based on what I think it's doing. The problem becomes each merchant using a variety of names for the product. (widgets, famous widgets, or best selling widgets) Which is why I was excited to find feeds that had a common field (product id) even though there are still some minor variances in it.
I'm having another issue, I'll post that in a separate thread so as not to confuse these issues.
Still working on a way to resolve the merchants that are adding characters to the product id, I'm probably going to accept that I will just need to modify the feed manually before uploading. Its only a little bit extra work ad it seems like it may be the easiest way to solve the issue.
Hi,
Firstly, removing the spaces and hyphens during import is requires a simple mod to the import record handler in includes/admin.php Look for the following function:
function admin__importRecordHandler($record)
...and then add the following code after the global variable declarators...
$record[$admin_importFeed["field_productid"]] =
str_replace(" ","",$record[$admin_importFeed["field_productid"]]);
$record[$admin_importFeed["field_productid"]] = str_replace("-","",$record[$admin_importFeed["field_productid"]]);
(where productid is the name of the field you've created)
That should import all product IDs with hyphens and spaces removed.
The second part of your question is more complex because it depends on how you want the search to behave for queries that are not based on a product ID. Have you made any changes to search.php as yet to support the new field? Using %LIKE% style query rules out the use of the full text indexing, so that is one trade-off you have to consider.
Another option is to append the product ID to the product name and let the full text index manage the indexing of them alongside the product name. Achieving the same result but requiring code modifications is creating a full text index against the product name AND the product ID field. You can do this with the following script, or by executing the SQL directly via phpMyAdmin (or similar tool)...
makeIndex.php
<?php
set_time_limit(0);
ignore_user_abort();
require("includes/common.php");
$sql = "create fulltext index ft_nameproductid on products (name,productid)";
database_queryModify($sql,$rows);
print "<p>Done.</p>";
?>
(it is best to run this on an empty database)
Then, you can modify search.php by searching for each instance of:
MATCH name
and replacing it with:
MATCH name,productid
Again, where productid is whatever you have called the field in your database.
Hope this helps!
Cheers,
David.