Support forum login

©2006-2010 IAAI Software

Contact Us

Merge Brands

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

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 dmorison 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.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com

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 dmorison 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.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com

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 dmorison 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.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com

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

Thanks David, Works a treat

Cheers,
Chris.