You are here:  » Merge Brands

Support Forum



Merge Brands

Submitted by npaitken on Thu, 2010-01-21 20:09 in

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

Submitted by support on Fri, 2010-01-22 08:54

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.

Submitted by kiddaclo on Sat, 2010-01-23 14:51

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.

Submitted by support on Sat, 2010-01-23 20:00

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.

Submitted by kiddaclo on Sat, 2010-01-23 20:14

Hi David,

It would be useful if I could keep the "dynamic mapping" if that's not too much trouble.

Cheers,
Chris.

Submitted by support on Sat, 2010-01-23 20:20

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.

Submitted by kiddaclo on Wed, 2010-01-27 12:09

Thanks David, Works a treat

Cheers,
Chris.

Submitted by stevewales20 on Wed, 2011-03-02 21:51

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?

Submitted by support on Thu, 2011-03-03 09:42

Hi Steve,

It works entirely within the Category Mapping system so no need to create any more files...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Thu, 2011-03-03 19:15

Cheers :)