You are here:  » Updated data feed with different categories.

Support Forum



Updated data feed with different categories.

Submitted by knight01 on Fri, 2007-06-08 04:18 in

I've got a couple of data feeds that have odd categories, basically all products are in the same category.

I went through the mysql after the initial import and changed the categories of each product so they would make sense.

Now it's time to update a feed and of course they are again using the same categories that don't coincide with the categories I'm using.

Is there some way of do the import update that will update based on the product name and NOT import the updated (wrong)category?

Of course now that I think of it, I have probably changed the names of some of the products so they show up in the comparison, so is there a way to import updated feed based on some static information, such as a product id? I'd need to add this to the registration form.

Submitted by support on Fri, 2007-06-08 07:21

Hi,

There are a couple of threads that cover what you want to do here. Firstly, to be able to create dynamic categories based on the content of the product name, see the code in the following thread:

http://www.pricetapestry.com/node/1049

However, rather than using the description, change the code to look at the product name instead, which would make the replacement code as follows:

    if (!$category)
    {
       $name = $record[$admin_importFeed["field_name"]];
       if (stristr($name,"ring")===TRUE) $category = "Rings";
       if (stristr($name,"pendant")===TRUE) $category =
"Pendants";
       // repeat the following line with different search words and categories
       // for as many categories as you wish to detect...
    }

If you use this method of dynamically modifying the category during import then it doesn't matter when you come to re-import, you won't overwrite any changes because they are always made each time you import. If you have changed product names however, this is more complex because you would also need to setup a similar block of code for your adjusted product names. To do this, look for the following code in includes/admin.php:

    /* apply standard filters */
    $record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);

...and then add the following code immediately afterwards:

   $nameMapping["Big Blue Widget"] = "Blue Widget";
   $nameMapping["Small Blue Widget"] = "Blue Widget";
   if ($nameMapping[$record[$admin_importFeed["field_name"]]])
   {
     $record[$admin_importFeed["field_name"]] =
       $nameMapping[$record[$admin_importFeed["field_name"]]]
   }

In this example, any product called "Big Blue Widget" or "Small Blue Widget" would get imported as "Blue Widget". You can add as many of these lines as you need to setup your fixed "Product Name Mapping" so that you don't overwrite your changes each time you import...

Hope this helps,
Cheers,
David.