Recent updates change search results behaviour for bi-lingual sites?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Recent updates change search results behaviour for bi-lingual sites?

This topic contains 11 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 years, 2 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #31576
    Laterna57
    Laterna57
    Participant

    Hello dear Ajax Search Pro team,

    Allow me to report an issue that started to appear recently (maybe a few weeks or a month, exact timeframe is not detected).

    Issue: The search results for the secondary language show results in the main language.
    Expected behaviour: The search results in the secondary language must show the results in the second language.

    Setup:
    – Bi-lingual WooCommerce store: English (main language) and Bulgarian (secondary language).
    – Products are always set in English and not translatable – the secondary language shows the price currency and the attributes in Bulgarian but the product is actually in English (did not had issues with the search results with this setup).
    – ASP – WPML compatibility is set to OFF (otherwise there are no results in Bulgarian because there are technically no products in Bulgarian).

    Steps to reproduce:

    1. Go to the Bulgarian version of the store: https://www.laternarecords.com/bg/
    2. Search something – for example – larry
    3. Pick a search result: for example, the first one:
    4. It is the result for the English version (e,g. in EUR and in English attributes for the product).
    https://www.laternarecords.com/en/shop/larry-levan-larry-levans-classic-west-end-records-remixes-made-famous-at-the-legendary-paradise-garage-white-vinyl-repress-west-end-records/
    5. Expected result:
    https://www.laternarecords.com/bg/shop/larry-levan-larry-levans-classic-west-end-records-remixes-made-famous-at-the-legendary-paradise-garage-white-vinyl-repress-west-end-records/

    Comments:

    This behaviour was working correctly perfectly since day 1 – and also after upgrading to the ASPro version. It stopped recently, I suspect it changed its behaviour after some of the recent ASPro updates. I’ve not examined the plugin code, due to time restrictions (though suspecting wp_localize_script or similar changes).

    My request is that if you can please check whether this is from the ASP and if we can easily return the old behaviour?

    Thank you very much in advance.

    Best regards and huge thanks for the wonderful plugin, worth every cent.
    The Laterna team

    #31580
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Thank you for the details!

    It is unfortunately an issue related to one of the WPML core hooks wpml_permalinl. While we are using it correctly, it still returns incorrect strings for some reason. Yesterday someone else reported something similar, which we seemingly managed to resolve by editing the plugin code yet again.

    Please try the following tweaks first.

    If those does not work, then I’m afraid the only solution is to try to implement the same change as we did yesterday, and hope it works.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31587
    Laterna57
    Laterna57
    Participant
    You cannot access this content.
    #31588
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I just re-read your post, but I may have missunderstood you.

    I noticed that WPML compatibility is OFF, which means that results are returned regardless of the language regardless of which language is opened.
    So if I go the BG version of the site, then type in “larry” I get the english results, which lead me to the english version of the product – which is the correct behavior.
    When WPML compatibility is turned OFF, the plugin returns any results for any languages. WPML may actually resolved the issue with ther hook, and now it works correctly, but in your case it is the “incorrect” way – because you want to redirect to a URL where the product actually does not exist.

    I believe this might be still resolveable with a custom code though to replace the language string with the currently opened:

    add_filter( 'asp_results', 'asp_change_lang_to_local', 10, 1 );
    function asp_change_lang_to_local( $results ) {
    	
    	// Parse through each result item
    	if ( defined('ICL_LANGUAGE_CODE') ) {
    		foreach ($results as $k=>&$r) {
    			if ( isset($r->post_type) ) {
    				$r->link = apply_filters('wpml_permalink', $r->link, ICL_LANGUAGE_CODE, true);
    				if ( strpos($r->link, ICL_LANGUAGE_CODE . '/') === false ) {
    					$r->link = apply_filters('wpml_permalink', $r->link, ICL_LANGUAGE_CODE);
    				}
    			}
    		}
    	}
    
    	return $results;
    }

    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case! I have not been able to test this, so please be careful.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31589
    Laterna57
    Laterna57
    Participant
    You cannot access this content.
    #31590
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you for your insights, I hope that code helps.

    It was working until the most recent release, because the wpml_permalink API call was actually used incorrectly, and it caused issues on other WPML installations. In your case it worked incorrectly, but that was the correct way (defaulted to the current site language, while the correct language was the original).
    Those products do not exist in the database, so the plugin cannot find them, WPML just makes a way to access them via the other language URIs as well – but still, only a single product exists. If I understood correctly, you don’t actually have a translation made, and have an assigned language, the products are only in english. The search requests the result URL, which is the english version – but still, the other language versions will work, but those don’t actually exist (if the tranlsation does not exist).
    The custom code I suggested should try requesting the permalinks by the current site language – even if the translation does not exist.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31591
    Laterna57
    Laterna57
    Participant
    You cannot access this content.
    #31592
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31594
    Laterna57
    Laterna57
    Participant
    You cannot access this content.
    #31596
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31599
    Laterna57
    Laterna57
    Participant
    You cannot access this content.
    #31601
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘Recent updates change search results behaviour for bi-lingual sites?’ is closed to new replies.