Forum Replies Created

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter kov09

    (@kov09)

    Yes, thanks for your time!

    I’m closing this thread and open new one related to strings translation issue…

    Thread Starter kov09

    (@kov09)

    Here is final working version:

    function kov_algolia_should_index_post( $should_index, $post ) {
    	if ( ms_is_switched() ) {
    		$should_index = false;
    	}
    
    	return $should_index;
    }
    
    add_filter( 'algolia_should_index_post', 'kov_algolia_should_index_post', 10, 2 );
    add_filter( 'algolia_should_index_searchable_post', 'kov_algolia_should_index_post', 10, 2 );
    Thread Starter kov09

    (@kov09)

    Yes, I saw that file, thanks.

    I was debugging algolia_should_index_post hook. As we discussed before it’s called few times on each post save (for original post and all its relations). For translations get_current_blog_id() function call returns correct blog there, so I can suggest that we receive wrong algolia_index_name_prefix option somewhere. – In theory plugin should sync all related posts to correct indices after switch_to_blog() call by MultilinguallPress…

    Here is my quick workaround for now:

    function kov_algolia_should_index_post( $should_index, $post ) {
    	$current_blog_id = get_current_blog_id();
    	
    	restore_current_blog();
    
    	// check if current $post object doesn't belong to current blog... ms_is_switched() doesn't work here somewhy...
    	if ( isset( $post->post_title ) && !post_exists( $post->post_title ) ) {
    		$should_index = false;
    	}
    
    	switch_to_blog( $current_blog_id );
    
    	return $should_index;
    
    }
    
    add_filter( 'algolia_should_index_post', 'kov_algolia_should_index_post', 10, 2 );
    • This reply was modified 3 years, 7 months ago by kov09.
    • This reply was modified 3 years, 7 months ago by kov09.
    • This reply was modified 3 years, 7 months ago by kov09.
    • This reply was modified 3 years, 7 months ago by kov09.
    • This reply was modified 3 years, 7 months ago by kov09.
    Thread Starter kov09

    (@kov09)

    After some digging I found that basically issue isn’t related to the re-indexation process, but only to individual post syncing. I was confused because there were always post edits during re-indexation! Here is the thing… Each time on post update site syncs it with all related translations (related posts on other subsites) to the same index. I believe it’s a conflict with MultilingualPress – it triggers post update for all subsites when we save the post, and Algolia plugin uses save_post hook to sync item. I’m trying to disable sync_item action for other subsites now… I’ll keep informing, hope we will find the solution.

    And there is another thing… Records are transferred to Algolia with translated strings based on admin language, but not on the site’s original one, so here is an example: site is on DE lang, admin part is on EN language – all synced products will have Products post label, but not Produkte. It created additional filter entry and confuses user… This doesn’t happen during WP_CLI sync.

    Thread Starter kov09

    (@kov09)

    Nope, it’s not me 🙂

    I gonna do some debugging and back to you when have something new…

    Thread Starter kov09

    (@kov09)

    We use only algolia_post_shared_attributes & algolia_searchable_post_shared_attributes filters for indexing _sku field.

    Unfortunately re-indexation doesn’t do the thing. We also tried to use –url parameter in WP-CLI command.

    We have a lot of posts (up to 10000 posts in each subsite), so each re-indexation takes some time. The strange thing is that it mixes different number of posts / post types each time… It may be Products / Posts / Pages or only Products; and it happens only on subsites.

    Thread Starter kov09

    (@kov09)

    Algolia dashboard shows mixed posts as well.

    Thread Starter kov09

    (@kov09)

    Here are current indices on Algolia; each subsite uses own prefix:

    • live_de_searchable_posts
    • live_de_posts_product
    • live_en_searchable_posts
    • live_en_posts_product
    • live_en_posts_page
    • live_fr_searchable_posts
    • live_fr_posts_product
    • live_fr_posts_page
Viewing 8 replies - 16 through 23 (of 23 total)