You are here:  » Filters for lots of categories in a feed

Support Forum



Filters for lots of categories in a feed

Submitted by Paul1107 on Tue, 2010-08-03 19:34 in

Hi David,

I have a feed from a dept store which has lots of categories as you would expect, but upon registration some of feed categories have been automatically assigned to previously configured MAPPED categories.

My question is how to filter all the remaining categories in the feed except those that have been assigned to the mapped categories.

Cheers!

Paul

Submitted by support on Wed, 2010-08-04 08:58

Hi Paul,

If you only want to include mapped categories, and have any other categories removed (just the category field, not the products themselves), this can be done in includes/admin.php. Look for the Category Mapping code as follows, beginning at around line 203:

    /* apply category mappings */
    if (isset($admin_importCategoryMappings["=".$importRecord["category"]]))
    {
      $importRecord["category"] = $admin_importCategoryMappings["=".$importRecord["category"]];
    }
    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["category"],$word) !== FALSE) $found++;
            }
          }
          if ($found == count($words))
          {
            $importRecord["category"] = $v;
            break;
          }
        }
      }
    }

...and REPLACE that with:

    /* apply category mappings */
    $isMapped = FALSE;
    if (isset($admin_importCategoryMappings["=".$importRecord["category"]]))
    {
      $importRecord["category"] = $admin_importCategoryMappings["=".$importRecord["category"]];
      $isMapped = TRUE;
    }
    else
    {
      foreach($admin_importCategoryMappings as $k => $v)
      {
        if ($importRecord["category"] == $v)
        {
          $isMapped = TRUE;
          break;
        }
        if (substr($k,0,1) !== "=")
        {
          $found = 0;
          $words = explode(" ",$k);
          foreach($words as $word)
          {
            if ($word)
            {
              if (strpos($importRecord["category"],$word) !== FALSE) $found++;
            }
          }
          if ($found == count($words))
          {
            $importRecord["category"] = $v;
            $isMapped = TRUE;
            break;
          }
        }
      }
    }
    if (!$isMapped) $importRecord["category"] = "";

Hope this helps!

Cheers,
David.