Hi David,
It seems that a lot of merchants datafeeds are incredibly sloppy!
I had no idea companies would be so inefficient with data they're providing us with to try and sell their products, anyway...
I have added these two custom fields to the product table: Brand Name & Model #.
Basically the merchants can't be bothered to supply these two values separately, but there is a consistency in their product names and descriptions, although PT can't pick them up when comparing prices. Mapping products is a last resort for me, I like things automated, so I was thinking that when I am registering or importing the feeds and the Brand Name and Model No. are not supplied, that I can check the Merchant that owns the feed and use a Regex to extract the necessary information from their product names or descriptions and insert the values into the Brand Name & Model No. values that would have been.
What I am asking David is where can I catch this action? Which file, function, file lines am I looking for to catch it just before the import to check the Product Names or Descriptions with my Regex's and slot them into the product database?
Cheers,
Chris
Hello Chris,
It all happens in the admin__importRecordHandler() function which begins at line 108 in includes/admin.php. The best place to implement your code would be just AFTER the following code at line 292; which is almost immediately before the SQL is constructed for inserting the product into the database:
if (!$merchant) return;
At this point; merchant name is in $merchant (should you want to "case" your code to apply different rules for different merchants), with product name and description in the following variables:
$importRecord["name"]
$importRecord["description"]
...and the variables you would want to populate based on your rules are in the same array, e.g.
$importRecord["model_number"]
Hope this helps!
Cheers,
David.