You are here:  » Brands Mapping

Support Forum



Brands Mapping

Submitted by shopwindow on Tue, 2006-04-04 13:57 in

Having played around with Price Tapestry for the last week and liking the category mapping so much, I have now resolved a brands mapping feature too although this will have to be fully tested once I have imported all feeds into the database and mapped the brands with the mapping feature.

Thanks for a great script though, 1.7 million products so far and growing with no problems on the Database

Submitted by knight01 on Tue, 2007-11-06 15:23

Does anyone have a hack to do this?

I've got several merchants are using different variations of the same brand name.

Perfume & Cologne Comparison Site

Submitted by support on Tue, 2007-11-06 21:51

Hi,

As a very quick hack, you can easily apply category mappings to brands. In includes/admin.php, look for the following code (starting at 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 = "";
    }

...and add the following code immediately AFTERWARDS:

    /* apply category mappings to brands */
    if (isset($admin_importCategoryMappings[$brand]))
    {
      $brand = $admin_importCategoryMappings[$brand];
    }

This should work because there shouldn't be any overlap between categories and brands, but if you find this isn't suitable let me know and i'll document the changes to add a complete brand mapping featured (it basically involves copying all the code for category mapping, and creating a new database table to hold them)...

Cheers,
David.

Submitted by knight01 on Mon, 2007-11-12 07:31

David,
After adding this to /includes/admin.php when it tries to import I get a parse error.

Parse error: syntax error, unexpected $end in /home/sitename/directory/includes/admin.php on line 552

Submitted by support on Mon, 2007-11-12 09:13

Hi,

If you want to email me a copy of your modified includes/admin.php i'll take a look for you...

Cheers,
David.

Submitted by redspan on Fri, 2007-11-16 16:28

Hello,

The beginning of my list of categories before mapping looks list this:

Accessories
Accessoriesbackpacks
Accessoriesbags
Accessoriesbath Towels
Accessoriesbeanies
Accessoriesbelts
Accessoriesbusiness
Accessoriescaps
Accessoriesgifts
Accessoriesgloves
Accessorieshats
Accessorieshome Deco
Accessoriesjewellery
Accessorieskey Rings
Accessoriesmiscellaneous
Accessoriespurses
Accessoriesscarves
Accessoriessunglasses
Accessoriestowels
Accessoriesumbrellas
Accessorieswatches

and then I create a mapping for "Accessories" and add all the rest of the above (one per line) then all those should be mapped to "Accessories", but I have done so and there is no change. All the above categories still appear in the index.

What have I missed?

Regards,
Ben

Submitted by support on Fri, 2007-11-16 17:50

Hi Ben,

The actual values may have spaces in them which is why they are not matching the mapping list. To fix this in, includes/tapestry.php, look for the following code on line 31:

return $text;

...and replace this with:

return trim($text);

After importing again they should then match up properly.

Cheers,
David.

Submitted by redspan on Fri, 2007-11-16 19:05

Hi David,

Hmmm, tried that and it didn't work. I replaced the code on line 31, deleted then recreated the mapping, no change.

Regards,
Ben

Submitted by support on Fri, 2007-11-16 19:10

Hi Ben,

Could you email me a link to your site, and admin area access details if needed and i'll take a look for you.... reply to your reg code or forum registration email is the easiest way to get me...

Cheers,
David.

Submitted by redspan on Thu, 2007-11-22 16:36

Hi David,

I emailed you the details earlier today.

Regards.
Ben

Submitted by Paulzie on Wed, 2007-12-19 23:20

Hi

I've added the code as suggested here:-

    /* apply category mappings to brands */
    if (isset($admin_importCategoryMappings[$brand]))
    {
      $brand = $admin_importCategoryMappings[$brand];
    }

I am having an issue where a BRAND field is blank. It's basically putting in the last Category Mapping entry to be added.

I tried changing the isset to strlen

Submitted by support on Thu, 2007-12-20 09:06

Hi,

The easiest thing to do is probably to wrap that section of code within an if($brand) construct so that it is only applied where there is a valid brand...

  if ($brand)
  {
    if (isset($admin_importCategoryMappings[$brand]))
    {
      $brand = $admin_importCategoryMappings[$brand];
    }
  }

Cheers,
David.

Submitted by paul30 on Mon, 2008-09-15 19:38

So is there the documented way to integrate the "Complete Brand Mapping" ?

I dont know about the rest of you people, but most of my merchants seem to call manufacturers differently:

Correct Full Manufacturer Name
CorrectFull ManufacturerName
Correct-Full ManufacturerName
Full-Manufacturer Name
Full-Name
Manufacturer USA

are some examples that I am experiencing...

So for me this feature is MUCH MUCH needed!

Thanks a lot!

Submitted by support on Tue, 2008-09-16 07:55

Hi,

This modification simply allows you to apply category mappings to brands, removing the need to add new database tables and editing pages in the /admin/ section.

Were you able to get this modification working as required? If you're not sure about anything, feel free to email me your /includes/admin.php and i'll add the modification for you.

Just to clarify, after doing this, you simply need to edit your category and brand mappings in the one place (Category Mapping) in the admin section - and the mappings are then applied to both categories and brands during import...

Cheers,
David.

Submitted by paul30 on Tue, 2008-09-16 09:41

I did not try this mod yet cause I believe that it is not precisely what I need...

I have a manufacturer name like: "Brand Name" and than from another merchant the same manufacturer is called: "Brand and Name", I need to be able to merge them in to a single manufacturer... It is ok I will try to duplicate the category mapping functions within the script myself...

I was just hoping that someone has done it already, and that could save me a day or two of tinkering...

Thanks
Pasha

Submitted by support on Tue, 2008-09-16 09:51

Hello Pasha,

That sounds like this mod will do exactly what you need.

Once implemented, go to Category Mapping and create a new mapping with the single manufacturer name that you want; and then on the next page, enter on separate lines "Brand Name" and "Brand and Name", and then when it comes to import, both will be imported with whatever the master name you chose was!

Cheers,
David.

Submitted by paul30 on Tue, 2008-09-16 10:00

Great! I will implement it tomorrow than!

Thanks a lot!! :)

Submitted by MikeyC on Sat, 2009-01-31 10:43

Hi David,

Can you document the changes to add a complete brand mapping feature ?

Mikey

Submitted by support on Sat, 2009-01-31 11:23

Hi Mikey,

The changes in this thread would apply category mappings to brands also - would that be sufficient or are you likely to have intersect between your brand and category listings...

Cheers,
David.

Submitted by MikeyC on Sat, 2009-01-31 11:41

Hi David,

I would like my category and brand listings intersected.
Gives me a better overview of things.

Submitted by SimonK on Mon, 2011-03-07 16:09

Hi David

Is this mod uptodate for the latest release?

I'm trying to add it to includes/admin.php and not sure exactly what to do....

Thanks
Simon

Submitted by support on Mon, 2011-03-07 16:14

Hi Simon,

For 12/10A, look for the following beginning at line 183 in includes/admin.php:

    if ($importRecord["brand"])
    {
      $importRecord["brand"] = tapestry_normalise($importRecord["brand"]);
    }

...and REPLACE with:

    if ($importRecord["brand"])
    {
      $importRecord["brand"] = tapestry_normalise($importRecord["brand"]);
      if (isset($admin_importCategoryMappings[$importRecord["brand"]]))
      {
        $brand = $admin_importCategoryMappings[$importRecord["brand"]];
      }
    }

Cheers,
David.
--
PriceTapestry.com

Submitted by SimonK on Mon, 2011-03-07 21:17

Thanks David :-)

Submitted by Millssy on Tue, 2012-03-06 15:34

Hi.

I know this is an old thread but i have added the code and i cant seem to get it working...

I have tried all the code replacments in the thread and the only thing i achieved was at one point all my brands dissapered!

any help would be grand.

Submitted by support on Tue, 2012-03-06 15:44

Hi Millssy,

Ah yes - the above refers to an older version of Price Tapestry, the category mapping functionality has been improved since and is more comprehensive, however there is only one section of code to add now to be able to apply Category Mapping to Brands also.

Firstly of course, revert to the distribution version of includes/admin.php, or if you have made changes already undo any changes made re: the above.

Look for the following comment in includes/admin.php at line 233:

    /* apply category mappings */

...and REPLACE with:

    /* apply category mapping to brands also */
    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 */

Cheers,
David.
--
PriceTapestry.com