This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Product taxonomy in asp_result_groups

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #45319
    joshinmartinjoshinmartin
    Participant

    Hi Team, Thank you for giving us the wonderful plugin. We used in a few of our client websites and it works perfectly.

    But, we are now getting stuck with a build for which we like to have your support.
    We would like to add a Woo product category to the asp_result_groups.
    We could not find anything in the documentation.

    Would you be able to provide the query code for this, please?

    Thank You,
    Joe

    #45333
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Joe,

    You can actually group by taxonomy terms (including woocommerce categories) via the settings, no code is required: https://i.imgur.com/qx69rIx.png
    That should do the trick 🙂

    #45340
    joshinmartinjoshinmartin
    Participant

    Thank you, Ernest,

    Unfortunately, this doesn’t solve our issues :-(.

    We have the result group sections like ” page, posts and products ” already and we need to add a new tab from “woo product category” to the same result group. not as a separate result group.

    Sorry if I am still unclear to you.

    #45341
    joshinmartinjoshinmartin
    Participant

    You cannot access this content.

    #45359
    Ernest MarcinkoErnest Marcinko
    Keymaster

    The code seems to be incorrect. There is this knowledge base article on how to exactly use the asp_results_groups hook.

    The main issue with your code is that you are tring to add items via query_posts to the live results list, however those are not compatible there. Instead of that, you should try ASP_Query. Something like:

    $args = array(
    	's' => '',
    	'_ajax_search' => true,
    	'post_tax_filter' => array(
    		array(
    			'taxonomy'  => 'product_cat',
    			'include'   => array(123), // Taxonomy term ID here
    			'allow_empty' => false // Allow results, that does not have connection with this taxonomy
    		)
    	)
    );
    $asp_query = new ASP_Query($args);
    $groupss = $asp_query->posts;
    #45371
    joshinmartinjoshinmartin
    Participant

    Thank you – we made some progress now. We can see the titles of category now. But still, the content and link is not appearing in the result.
    You can see the test website here: https://tsw.detypedev.com/

    Can you check the code for us, please –

    $args = array(
    ‘s’ => $_POST[‘aspp’],
    ‘_ajax_search’ => true,
    ‘post_type’ => array(‘product’),
    ‘post_status’ => array(‘publish’),
    ‘posts_limit’ => 5,
    ‘keyword_logic’ => ‘AND’,
    ‘post_fields’ => array(
    ‘title’, ‘ids’,’content’, ‘excerpt’,’url’
    ),
    ‘post_tax_filter’ => array(
    array(
    ‘taxonomy’ => ‘product_cat’,
    ‘include’ => array(50),
    )
    )
    );
    $asp_query = new ASP_Query($args);
    $groupss = $asp_query->posts;

    #45382
    Ernest MarcinkoErnest Marcinko
    Keymaster

    It looks all right to me for the first sight.

    Can you check if there is anything within the $groupss variable?

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Product taxonomy in asp_result_groups’ is closed to new replies.