Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So that I can try to provide the best help I can, are you referring to using a WordPress filter to change information passed to the facet widget provided by Algolia? Or are you trying to make use of a filter within the widget itself, and you’re trying to find a way to conditionally modify the behavior there?

    Some more concrete examples of the facets being used will help as well.

    Thread Starter marcu5p

    (@marcu5p)

    Hi Michael

    Thanks for the reply. I want to push settings to Alogia Facet Display configuration.

    So, I have a list of Products (attribute is solution_name) which form one of my facets. I can sort these easily asc or desc by name or count (with js), but I need them in a custom order. I can achieve this via the Alogia dashboard using Configuration -> Facet Display (renderingContent) and pin the items it the order required. Once they are in the correct order they won’t change.

    I need to push this order from WordPress rather than having to go to the dashboard, in a similar way we are pushing which attributes to use for faceting using attributesForFaceting.

    For example I have tried this but it doesn’t work:

    function custom_posts_index_settings( array $settings ) {
    	$settings['renderingContent'] = ['solution_name => ['Solution One', Solution Five', 'Solution Three', 'Solution two', 'Solution Four'],
    ];
    	return $settings;
    }
    add_filter( 'algolia_searchable_posts_index_settings', 'custom_posts_index_settings' );
    add_filter( 'algolia_posts_index_settings', 'custom_posts_index_settings' );

    Thanks as always

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure how frequently, if at all in automated ways, settings set via custom code are sync’d up. So I’m wondering if you maybe need to trigger the settings sync button in the WP Dashboard. It would be the “Push Settings” button found at /wp-admin/admin.php?page=algolia-search-page

    Thread Starter marcu5p

    (@marcu5p)

    Yes for sure I’d need to use the Push Settings button to trigger it.

    But I can’t get the function constructed correctly, that’s really where I need your knowledge.

    using:

    function facet_display_index_settings( array $settings ) {
    	$settings['renderingContent'] = ['solution_name' =>
    	['Stress Testing', 'API Access'],
    ];
    	return $settings;
    }
    add_filter( 'algolia_searchable_posts_index_settings', 'facet_display_index_settings' );
    add_filter( 'algolia_posts_index_settings', 'facet_display_index_settings' );

    And then “Push Settings” gives me this error:

    An error occurred: Error in renderingContent parsing: Unexpected value type: invalid key 'solution_name'. Expected: facetOrdering, redirect (near 1:51)

    Thanks.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I believe you’re going to need to get your WP filtering to match the structure seen at https://www.algolia.com/doc/api-reference/api-parameters/renderingContent/?client=php

    Thread Starter marcu5p

    (@marcu5p)

    Yes, got it working, thanks so much.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Awesome to hear and thanks for the followup.

    Let us know if you need anything else.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Facet Display filter’ is closed to new replies.