integration issues – custom fields, speed, drop down list sort etc

  • Jmasked
    Participant
    2 years, 7 months ago #27750

    Hello I am using the trial right now and trying to get this setup and functional quickly on our dev site.
    info about site
    Elementor / Hello theme
    Woocommerce
    26,000 products
    Using for: front-end search of products with autocomplete, search bar is in header, category pages and brand pages: slugs are /product-category/ and /brand/, (eventually for recommendations)
    Currently use Klevu and are switching to algolia.
    Current settings in plugin
    https://tmpsend.com/w4QEtoBF
    #1 When I activate the drop down list sort, the site gives back a 502 bad gateway instantly. Nothing shows up in any of the logs.

    #2 When on a /brands page no “brand” filter is displayed and when on a “category” page no category filter is displayed.

    #3 Adding the facet filter widget in a column in elementor causes the column size to always be elementor-col-50 no matter what size i set the column in elementor or if I apply a class or ID to the column and apply CSS to it.

    #4 Product variations: In the index I need the PARENT product to have in the data something along these lines…
    https://tmpsend.com/XTcV2Zhh
    #5 I have bootstrapped the plugin and added the following code:

    dd_filter( WPSOLR_Events::WPSOLR_FILTER_INDEX_CUSTOM_FIELDS, [
     $this,
     'add_my_field_to_indexed_custom_fields',
    ], 10, 2 );
    
    public function add_my_field_to_indexed_custom_fields( $custom_fields, $model_type ) {
    if ( ! isset( $custom_fields ) ) {
    $custom_fields = [];
    }
    switch ( $model_type ) {
    case 'post':
    case 'product': // add other post types if you like
    if ( ! in_array( 'variation_count_meta', $custom_fields, true ) ) {
    array_push( $custom_fields, 'variation_count_meta' );
    }
    if ( ! in_array( 'child_sku', $custom_fields, true ) ) {
    array_push( $custom_fields, 'child_sku' );
    }
    if ( ! in_array( 'child_name', $custom_fields, true ) ) {
    array_push( $custom_fields, 'child_name' );
    }
    if ( ! in_array( 'image_url', $custom_fields, true ) ) {
    array_push( $custom_fields, 'image_url' );
    }
    break;
    }
    return $custom_fields;
    }
    //after
    use wpsolr\core\classes\WPSOLR_Events;
    
    add_filter( WPSOLR_Events::WPSOLR_FILTER_POST_CUSTOM_FIELDS, 'filter_custom_fields', 10, 2 );
    
    function filter_custom_fields( array $custom_fields, WP_Post $post) {
        
        $product = wc_get_product( $post );
        // Extract image
        $variations_count = 0;
        $image_url = $product->get_image('thumbnail');
        if ( $product instanceof WC_Product_Variable ) {
            $variations_count = count( $product->get_available_variations() );
            $variations = $product->get_available_variations();
            $attricount      = count( $variations );
            $allattributes = $variations[0]['attributes'];
            // Get children product variation IDs in an array
             foreach ( $product->get_children( false ) as $child_id ) {
                // get an instance of the WC_Variation_product Object
                $variation = wc_get_product( $child_id ); 
    
                if ( ! $variation || ! $variation->exists() ) {
                    continue;
                }
    
                $variation_meta[] = array(
                    'SKU'      => $variation->get_sku(),
                    'Name'     => $product->get_name() . " - " . $child_id,
                    'child_img_url' => $variation['image']['thumb_src'],
                );
            }
    
        }
    
        return $variation_meta;
    
         if($attricount > 0 && is_array($allattributes) && count( $allattributes ) == 1){
            foreach ($allattributes as $key => $value){
                $attriname = '';
                if(strpos($key, 'color')){
                    $attriname = 'Colors';
                }elseif(strpos($key, 'size')){
                    $attriname = 'Sizes';
                }else{
                    $rawattriname = substr($key, -5);
                    $attriname = ucwords(str_replace("_","",$key));
                }
                $variation_count_meta = $attricount . ' ' .$attriname;
                $custom_fields['variation_count_display'] = $variation_count_meta;
                $custom_fields['child_sku'] =  $variation_meta['SKU'];
                $custom_fields['child_name'] = $variation_meta['Name'];
                $custom_fields['child_img_url'] = $variation_meta['child_image_url'];
                $custom_fields['img_url'] = $image_url;
            }
        }
            return $custom_fields;
    }
    

    However, when I attempt to index again, I get the following error:
    Error on line 436 of file /wp-content/plugins/wpsolr-pro/wpsolr/core/classes/models/post/class-wpsolr-model-post.php: Array to string conversion

    wpsolr
    Keymaster
    2 years, 7 months ago #27751

    Let’s fix #1 first.

    a) I never seen so many attributes and custom fields indexed. Are all of them necessary?
    b) How many indexes were created in Algolia (one main index, and one replica per sort).

    wpsolr
    Keymaster
    2 years, 7 months ago #27752

    For #5, if you use boosts (screen 2.3), you do not need the option “Index custom fields and categories” of screen 2.2. This option creates the error I believe, for whatever reason.

    Jmasked
    Participant
    2 years, 7 months ago #27753

    #1

    a) our attributes are brand specific. So we have pa_”brand-name”_size and pa_”brand-name”_color…
    in #4 i link the file of what we actually need for products including variable.
    b) I have 1 main index, and products_relevant & products_replica_sort_total_sale_1_desc

    wpsolr
    Keymaster
    2 years, 7 months ago #27754

    #1
    a) It crashes when you select the WooCommerce sort?
    b) on which sort item?
    c) Did you check the “Replace sort” option on the WPSOLR’s WooCommerce add-on screen?

    Jmasked
    Participant
    2 years, 7 months ago #27755

    #1
    a) it crashes when I check off the “Replace sort” option on the WPSOLR’s WooCommerce add-on screen
    b) see above
    c) see above

    wpsolr
    Keymaster
    2 years, 7 months ago #27756

    #1
    You need to check on the “Replace sort” option if you want to use Algolia for searching, filtering, and sorting.

    The option will replace the WooCommerce sort items with the custom fields you selected as sort in screen 2.4

    Jmasked
    Participant
    2 years, 7 months ago #27757

    #1 every time I do that, immediately I get a 502 bad gateway on the site

    Jmasked
    Participant
    2 years, 7 months ago #27758

    GET /product-category/makeup/face/foundation/ HTTP/1.0″ 502 1175

    wpsolr
    Keymaster
    2 years, 7 months ago #27759

    #1
    You crash when:
    a) You save the option “Replace sort” checked
    b) You select any sort front-end side with “Replace sort” checked
    c) You select any sort front-end side with “Replace sort” unchecked

    Jmasked
    Participant
    2 years, 7 months ago #27760

    #1 a

    wpsolr
    Keymaster
    2 years, 7 months ago #27761

    #1
    This is a first!
    Other 502 errors?

    Jmasked
    Participant
    2 years, 7 months ago #27762

    none, and its only on the front end. admin panel is accesible still. 502 bad gateway happens on every single front end page when the option is saved.

    wpsolr
    Keymaster
    2 years, 7 months ago #27763

    #1
    How can the 502 happen on frontend while saving the option on backend?

    Jmasked
    Participant
    2 years, 7 months ago #27764

    I’m assuming the 502 occurs when attempting to access any front end page calling something.
    Admin page must not call whatever is causing the 502.

Viewing 15 posts - 1 through 15 (of 63 total)

You must be logged in to reply to this topic.