Only import products from certain continent

More
9 years 8 months ago - 9 years 8 months ago #2724 by bram
function afrika_cb(&$item) {

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

}
Last edit: 9 years 8 months ago by bram.

Please Log in or Create an account to join the conversation.

More
9 years 8 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 or Create an account to join the conversation.

More
9 years 8 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 or Create an account to join the conversation.

More
9 years 8 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 or Create an account to join the conversation.

Time to create page: 0.260 seconds