Skip to main content

Only import products from certain continent

More
10 years 7 months ago - 10 years 7 months ago #2724 by redactie
function afrika_cb(&$item) {

generic_cb($item);
$m5=strtolower($item);
if ( $m5 != 'afrika') {
$item='';
return;
}

}
Last edit: 10 years 7 months ago by redactie.

Please Log in to join the conversation.

More
10 years 7 months ago #2725 by brotherlouis
Great, it works! I didn't know that the behaviour would be different between 'Afrika' and 'afrika'. Thank you so much!

Please Log in to join the conversation.

More
10 years 7 months ago #2726 by brotherlouis
Mmm for some feeds it works great for others where 'continent' is 'aziƫ' instead of 'azie' it doesn't like you predicted.

Is this how it should work?
Code:
generic_cb($item); $m5 = strtolower($item['menu_5']); if ( preg_match('#^azi.$#',$m5)) { $item['title']=''; return; } }

or this?
Code:
generic_cb($item); $m5 = strtolower($item['menu_5']); if ! preg_match('#^azi.$#',$m5) { $item['title']=''; return; } }

Please Log in to join the conversation.

More
10 years 7 months ago #2727 by brotherlouis
I did find a working solution!
Code:
function continents_cb(&$item) { generic_cb($item); $m5 = strtolower($item['menu_5']); if ( ! preg_match('#(azi.)#',$m5)) { $item['title']=''; return; } }

Works fine with me suppose. Work with countries the same way as well as with other regex i.e.
Code:
if ( ! preg_match('#(indonesi.)|india|cambodja#',$m5)) {

in case you only want to select countries with this callback filter.

Please Log in to join the conversation.

Time to create page: 0.533 seconds