You are here:  » Default Category / Default Brand


Default Category / Default Brand

Submitted by Confuscius on Thu, 2006-08-24 16:20 in

Hi David

I have a number of product feeds where SOME of the records do not contain either a category in the "CATEGORY" field or a brand in the "BRAND" field. Ideally, for those records that have missing data then I would like to default them to say 'Other' and 'Unbranded'. Ideally the best time to do this would be at the point of importing the feed.

I have tried a search and replace on the respective fields within each feed BUT whilst you can replace something with nothing then I cannot find a way to replace nothing with something! (presumable because the Search function must be provided with something in the first place). I have also tried putting defaults on the Mysql products table as another possible solution but re-importing does not seem to change anything.

Please advise! Thanks in advance.

Paul

Submitted by support on Thu, 2006-08-24 16:26

Hi Paul,

Here's a simple mod that you can make to includes/admin.php. Find the block of code starting on line 203 that constructs the $category and $brand values during import.

If you change this section as follows; it will change the behavior to use the values from the category and brand fields if they are not blank; otherwise it will use the value in the user supplied category and brand fields (on the feed registration page):

<?php
    
/* construct category value if required */
    
if ($admin_importFeed["field_category"])
    {
      
$category $record[$admin_importFeed["field_category"]];
    }
    if ((!
$category) && ($admin_importFeed["user_category"]))
    {
      
$category $admin_importFeed["user_category"];
    }
    
/* apply category mappings */
    
if (isset($admin_importCategoryMappings[$category]))
    {
      
$category $admin_importCategoryMappings[$category];
    }
    
/* construct brand value if required */
    
if ($admin_importFeed["field_brand"])
    {
      
$brand $record[$admin_importFeed["field_brand"]];
    }
    if ((!
$brand) && ($admin_importFeed["user_brand"]))
    {
      
$brand $admin_importFeed["user_brand"];
    }
    else
    {
      
$brand "";
    }
?>

Hope this helps!
David.

Submitted by Confuscius on Thu, 2006-08-24 16:59

Many thanks for the amazingly fast response - works an absolute treat. Now, if you could just find a way to get more than 10% of Merchants to produce half reasonable feeds then there would be a lot less work involved in putting together something half reasonable!

Great product. Great support. Great potential.

Paul