splitting description text in order to filter it

5 years 5 months ago #3269 by melvinio

Hi all,

I have been looking for a solution in order to split a datafeed description field into sub-items where I can filter on. couldn't find it, sorry if I overlooked.

the outcome that I currently have is like this this is simply a description text from a tradetracker datafeed -->

Example:
Autostyle Uitlaatsierstuk Rond Inox Diameter: ø57mm Lengte : 155mm Montage : klembevestiging Montagemaat : 45mm - 57mm Vorm : rond

Which contains:
Brand - product type - diameter - length - mounting - mountingsize - shape

would there be a way to split this text so that I can use it in order to use it as a filter?
I'm quite new to the usage of callbacks.

I'm using joomla 3.X and also the datafeeds 3.X.

Thanks in advance!

With Kind regards,

Melvin



  • Posts: 2
  • Thank you received:

  • Gender: Unknown
  • Birthdate: Unknown
  • Please Log in to join the conversation.

    5 years 5 months ago #3270 by bram

    To properly split information it should have fixed delimiters for example a comma:

    Autostyle Uitlaatsierstuk Rond Inox, Diameter: ø57mm, Lengte : 155mm, Montage : klembevestiging, Montagemaat : 45mm - 57mm, Vorm : rond

    If the terms in the string are always the same and in the same order you could try a regex.

    function test_cb(&$item) {
    $keep=$item['description'];
    generic_cb($item);
    if ( preg_match("#(.*?) (.*)Diameter : (.*)Lengte : (.*)Montage : (.*)Montagemaat : (.*)Vorm : (.*)#",$keep,$m) ) {
    print_r($m);
    $item['menu_1']=trim($m[1]);
    $item['dummy'] =trim($m[2]); # rest van omschrijving
    $item['menu_2']=trim($m[3]);  # dia
    $item['menu_3']=trim($m[4]); # lengte
    $item['menu_4']=trim($m[5]); #montage
    $item['menu_5']=trim($m[6]); #montage maat
    $item['menu_6']=trim($m[7]); #montage vorm
    }
    
    }



    However, getting the brand will be difficult since you can distinguish between a single and a double word brand. ( is Autostyle the brand or 'Autostyle Uitlaatsierstuk' ?? )



  • Posts: 1494
  • Karma: 57
  • Thank you received: 247

  • Gender: Unknown
  • Birthdate: Unknown
  • The following user(s) said Thank You: melvinio

    Please Log in to join the conversation.

    5 years 5 months ago - 5 years 5 months ago #3271 by melvinio

    Hello Bram,

    Thank you for your quick reply.

    The information in the feed will have the same format every time.
    Also to answer your other question 'Autostyle' would be the brand, the other part wouldn't be relevant to filter. for me the 'other' filters' would be the important ones.

    what I did now:
    I've added the callback function into the feeds.php file, and selected the 'test' callback as the callback for this feed at the datafeed selection.

    How would the filtering work in this case, where should I add the sub-filtering options?

    Thank you!
    ps, If it's a lot of work to get it done, I'd pay you for it of course :)



  • Posts: 2
  • Thank you received:

  • Gender: Unknown
  • Birthdate: Unknown
  • Last Edit: 5 years 5 months ago by melvinio.

    Please Log in to join the conversation.

    Time to create page: 0.061 seconds
    Powered by Kunena Forum