Hi David,
Now that I've implemented the brandFilter mod I was wondering if you've developed a script for merging brands at import? Brand name variations is not nearly as bad as categories and products but there's still quite a bit of variation from merchant to merchant with the feeds I'm using.
Hope there's a fix for this.
Thanks,
Neil
Hi David,
I'd also like to do this mod however I can't find the code in includes/admin.php around line 234.
I have similar at 169
if ($admin_importFeed["field_brand"])
{
$importRecord["brand"] = $record[$admin_importFeed["field_brand"]];
}
elseif($admin_importFeed["user_brand"])
{
$importRecord["brand"] = $admin_importFeed["user_brand"];
}
else
{
$importRecord["brand"] = "";
}
Should i replace this code, or am I missing something?
Cheers,
Chris.
Hi Chris,
The above modification refers to an earlier distribution of Price Tapestry, with the current version, insert the following code immediately _after_ the section you posted above:
if (isset($admin_importCategoryMappings[$importRecord["brand"]]))
{
$importRecord["brand"] = $admin_importCategoryMappings[$importRecord["brand"]];
}
This is assuming that "dynamic" brand mapping is not required - if it is, let me know and I'll post the code required for that...
Cheers,
David.
Hi David,
It would be useful if I could keep the "dynamic mapping" if that's not too much trouble.
Cheers,
Chris.
Hi Chris,
No probs - it's basically just a copy & paste of the entire category mapping section; replacing the appropriate variables. It's perhaps easier to document by pasting the code in before category mapping, so to do this, look for the following comment around line 203:
/* apply category mappings */
...and then insert the following new code immediately before that point:
if (isset($admin_importCategoryMappings["=".$importRecord["brand"]]))
{
$importRecord["brand"] = $admin_importCategoryMappings["=".$importRecord["brand"]];
}
else
{
foreach($admin_importCategoryMappings as $k => $v)
{
if (substr($k,0,1) !== "=")
{
$found = 0;
$words = explode(" ",$k);
foreach($words as $word)
{
if ($word)
{
if (strpos($importRecord["brand"],$word) !== FALSE) $found++;
}
}
if ($found == count($words))
{
$importRecord["brand"] = $v;
break;
}
}
}
}
Hope this helps!
Cheers,
David.
Am i right in thinking that this code can be managed via the category mapping script or will i need to copy the categories.php script and make changes?
Hi Steve,
It works entirely within the Category Mapping system so no need to create any more files...
Cheers,
David.
--
PriceTapestry.com
Hi Neil,
Sure - one simply fix is to apply category mappings to brands also - then you can manage them all in the same place. In includes/admin.php, look for the following code beginning at around line 234:
/* construct brand value if required */
if ($admin_importFeed["field_brand"])
{
$brand = $record[$admin_importFeed["field_brand"]];
}
elseif($admin_importFeed["user_brand"])
{
$brand = $admin_importFeed["user_brand"];
}
else
{
$brand = "";
}
...simply REPLACE that with:
/* construct brand value if required */
if ($admin_importFeed["field_brand"])
{
$brand = $record[$admin_importFeed["field_brand"]];
}
elseif($admin_importFeed["user_brand"])
{
$brand = $admin_importFeed["user_brand"];
}
else
{
$brand = "";
}
if (isset($admin_importCategoryMappings[$brand]))
{
$brand = $admin_importCategoryMappings[$brand];
}
Hope this helps!
Cheers,
David.