integration issues – custom fields, speed, drop down list sort etc
- JmaskedParticipant3 years 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 conversionJmaskedParticipant3 years 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
You must be logged in to reply to this topic.