kov09
Forum Replies Created
-
Yes, thanks for your time!
I’m closing this thread and open new one related to strings translation issue…
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 );Yes, I saw that file, thanks.
I was debugging
algolia_should_index_posthook. As we discussed before it’s called few times on each post save (for original post and all its relations). For translationsget_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 afterswitch_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 );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_posthook to sync item. I’m trying to disablesync_itemaction 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.
Nope, it’s not me 🙂
I gonna do some debugging and back to you when have something new…
We use only
algolia_post_shared_attributes&algolia_searchable_post_shared_attributesfilters 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.
Algolia dashboard shows mixed posts as well.
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