You are here:  » Good way to Brand mapping without copying all code of category


Good way to Brand mapping without copying all code of category

Submitted by yomomma on Mon, 2012-05-07 04:16 in

Is there an easier way to display brands without copying the code for category mapping. If not, what is a good way to copy the category and apply it to brands?

Submitted by support on Mon, 2012-05-07 10:31

Hi yomomma,

As long as there's no overlap (particularly in keyword matches) simply duplicating the code in includes/admin.php is sufficient, then no need to create a whole new admin tool / database table. In that file, look for the following comment at line 233:

    /* apply category mappings */

...and REPLACE with:

    /* apply category mappings to brands */
    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;
          }
        }
      }
    }
    /* apply category mappings */

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by yomomma on Mon, 2012-05-07 14:05

Since there is only one admin.php in the includes file, I don't understand where there would be a duplicate file? Also, if I added the code you suggested would that not delete the category mapping? I wanted to create a brand mapping in addition to the category mapping.

Submitted by support on Tue, 2012-05-08 09:54

Hi,

The modification won't affect Category Mapping at all; that will all still work; the above is just a simple way to achieve Brand Mapping without having to create new database tables and admin tools - it simply uses the same interface as Category Mapping, that's all;

So after adding the above code to includes/admin.php simply treat Category Mapping in /admin/ as "Category and Brand Mapping".

Cheers,
David.
--
PriceTapestry.com

Submitted by yomomma on Tue, 2012-05-08 15:59

How do I separate the brand from the category so that the brand appears under the brand tab?

Submitted by support on Tue, 2012-05-08 16:10

Hi,

That sounds like there are "collisions" between the two so they can't be contained within the same interface, - no problem, I'll create an independent Brand Mapping patch and post to the Download Extras page - I'll let you know by email as soon as it's online - it will be a useful patch for users working with feeds where brands appear in the product name but have no dedicated brand field...

Cheers,
David.
--
PriceTapestry.com

Submitted by bat on Tue, 2012-11-13 17:45

Hi David
Was a patch ever made for the Brand Mapping as detailed above?

Submitted by support on Tue, 2012-11-13 19:27

Hi bat,

It sounds like the override mod in my previous reply here may more appropriate but for a more comprehensive solution the "generic" mapping mod described in this comment could be used, so Brand Mappings could be created with a master name of:

brand:Master Brand Name

As it stands, that would involve re-creating all existing Category Mappings with category: - if that's an issue let me know and it can be modified to assume "category" by default if no field: prefix...

Cheers,
David.
--
PriceTapestry.com