You are here:  » CJ category import issue

Support Forum



CJ category import issue

Submitted by yogi on Wed, 2008-07-09 21:29 in

Hi David,

I have CJ feed that i am importing but alot of merchant have category like this

cat1>subcat1>subcat2
cat1>subcat1>subcat2>subcat3

what i want is just keep the last category and remove rest.

can you tell me how can i do this.

thanks
yogi

Submitted by support on Thu, 2008-07-10 11:54

Hi Yogi,

To do this, you would need a modified version of the Explode filter described in the following thread, which also discusses ways to handle the CJ category field:

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

The Explode filter would let you split the category field on the ">" character, and then a return index of 0 would return the first value, 1 the second etc. etc. However, what you need to do is be able to specify the last value; so to do that, here is a modified version of the Explode filter that would let you specify a negative return index, so "-1" would return the last value.

Simply add the code below to your includes/filter.php and then add a new Explode filter against the category field. Enter ">" (without the quotes) as the explode character, and then "-1" (without the quotes) as the return index.

  /*************************************************/
  /* explode */
  /*************************************************/
  $filter_names["explode"] = "Explode";
  function filter_explodeConfigure($filter_data)
  {
    print "Explode Character or String:<br />";
    print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    widget_errorGet("text");
    print "<br />";
    print "Return Index: (zero based)<br />";
    print "<input type='text' size='3' name='index' value='".widget_safe($filter_data["index"])."' />";
    widget_errorGet("index");
  }
  function filter_explodeValidate($filter_data)
  {
    if (!$filter_data["text"])
    {
      widget_errorSet("text","required field");
    }
    if (!$filter_data["index"])
    {
      widget_errorSet("index","required field");
    }
  }
  function filter_explodeExec($filter_data,$text)
  {
    $parts = explode($filter_data["text"],$text);
    $index = intval($filter_data["index"]);
    if ($index < 0)
    {
      $index = count($parts) + $index;
    }
    return trim($parts[$index]);
  }

Cheers,
David.

Submitted by yogi on Mon, 2008-07-14 03:31

where do i need to enter the value i am little confuse can you please point me on this.

thanks
yogi

Submitted by support on Mon, 2008-07-14 08:12

Hello Yogi,

After adding the PHP code above to your includes/filter.php (make sure it goes inside the PHP tags!), register but don't import your CJ feed, selecting the appropriate category field as the category value.

After returning to the main admin page, click "Filters" alongside the same feed, and then add a new Explode filter against the Category field.

On the configuration page for the filter, enter ">" (without the quotes) as the Explode Character or String; and then "-1" (without the quotes) as the Return Index.

Save the filter configuration, and then import your feed. You should find that the last value in those category fields is the one that is imported.

Cheers,
David.