Should this work with the premium version as well?
-
HaikoGParticipant3 years, 8 months ago #16124
We’ve just purchased the premium version because we wanted to customize the look and feel of the suggestions box, but after installing the premium version Solr is no longer used for the suggestions.
If not, what can we do to plug WPSolr in the premium YITH WooCommerce Ajax Search as well?
HaikoGParticipant3 years, 8 months ago #16127In the Solr index we’ve added a ‘pricelist_id’, which is used to filter results per usergroup. So, every user has a certain pricelist which dictates which products they see. We’re also indexing the SKU and EAN number of the products. This worked perfectly with WPSolr and the free version of YITH Woocommerce ajax search:
– Searching a regular product like phone, showed only phones from within the users’ pricelist; Also in the suggestions box.
– Searching a SKU that’s not in users pricelist, showed ‘No results’, as it should
– Searching a SKU that is available in the users’ pricelist showed that product, as it should.Now we wanted to show the image of the product in the suggestion box. As YITH is used for the suggestion box, I looked in this plugin for the answer, which turned out the free version of YITH can’t do that. So we upgraded the plugin.
Now the suggestion box is no longer showing the Solr results, but searches the entire product database.
– Searching a regular product like phone, now shows all product with phone in the title in the suggestion box. But when actually pressing search, we get the filtered Solr results.
– Searching a SKU that’s not in users pricelist, shows ‘No results’, as it should
– Searching a SKU that is available in the users’ pricelist now says ‘No results’ when it should show a product. But when I click search, it shows the correct product.So this is telling me te suggestionsbox / Yith is no longer using WPSOLR as search engine, but rather the old/regular WP query.
HaikoGParticipant3 years, 8 months ago #16134Ok, I’ve tried to find the problem and got a solution
In
Replace
add_action( ‘wp_ajax_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );
add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, [ $this, ‘ajax_search_products’ ], 9 );with
if ( ! isset( $_REQUEST[‘wc-ajax’] ) ) {
add_action( ‘wp_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9);
add_action( ‘wp_ajax_nopriv_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ), 9 );
} else {
add_action( ‘wc_ajax_yith_ajax_search_products’, array( $this, ‘ajax_search_products’ ) , 9);
}and
$wpsolr_query->query[‘s’] = $query->query[‘s’];
with
$wpsolr_query->query[‘s’] = $_REQUEST[‘query’];Don’t know if this still works for the free version, but it does for the premium so if anyone runs in to this you can use this
wpsolrKeymaster3 years, 8 months ago #16136Thanks for the feedback. I’ll try to integrate that to the next release https://www.wpsolr.com/forums/topic/release-21-9/
- This reply was modified 3 years, 8 months ago by wpsolr.
finalwebsitesParticipant3 years, 8 months ago #16483Hi,
I have the same problem. We bought the Yith premium to get a better experience.
The problem is that the whole search mechanism is different from the free version.
In the free version only some arguments are used for the get_posts() function. For the premium version the use their own taxonomy and meta query arguments. My guess is that it’s the reason why WPSOLR doesn’t work. Any suggestions? My forst idea is to fork the free version and add the extra information to the list of post suggestions (like thumb, categories and price)finalwebsitesParticipant3 years, 8 months ago #16604Hi,
I checked the code form the Yith plugin and noticed they just using the get_posts() functions to get the suggestions for the the ajax search. I’ve built my own search widget using the same function. It looks like that my results are based on WPSOLR (it’s very fast, but my query is searching only inside the title and description. Where can I find some information about custom queries I can perform on the WPsolr search index?
ThanksfinalwebsitesParticipant3 years, 8 months ago #16647Hi,
this question was more common (sorry for trashing this topic). I will also create queries for posts on different places.
What kind of query / function or filter can I use?
You must be logged in to reply to this topic.