• Resolved olgamm

    (@olgamm)


    Hello, i have an issue with the elasticssearch plugin.

    i have menu order sorting setup with my products, but when im activating the plugin the products are not showing based on the menu order they have.

    The settings that i have enabled are: Post Search, Custom search results and woocommerce.

    Is there a way to make elasticsearch look for my custom sorting options?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter olgamm

    (@olgamm)

    Well, i disabled the woocommerce option in the features page of the plugin and the sorting option is working correctly now. My other issue now is that when im searching an SKU i get some products as an result but not the one with the sku that i searched.

    I was also tried to insert the _sku field in the mapping but with no luck. Do you have any suggestion, why the search by sku is not wokring?

    The other field “brand code” that i added is working fine. I created the field brand code with ACF.

    
    function custom_ep_config_mapping( $mapping ) {
        $mapping['mappings']['properties']['menu_order'] = [
            'type' => 'integer',
        ];
        $mapping['mappings']['properties']['total_sales'] = [
            'type' => 'integer',
        ];
        $mapping['mappings']['properties']['brand_code'] = [
            'type' => 'keyword',
        ];
        $mapping['mappings']['properties']['hidden_tags'] = [
            'type' => 'text',
            'analyzer' => 'standard',
        ];
        $mapping['mappings']['properties']['_sku'] = [
             'type' => 'text',
            'analyzer' => 'keyword',
        ];
        
    
        return $mapping;
    }
    add_filter( 'ep_config_mapping', 'custom_ep_config_mapping' );
    
    // Add sku and brand code in the elastic search 
    function OM_ep_weighting( $fields, $post_type ) {
        if ( 'product' === $post_type ) {
            if ( empty( $fields['meta'] ) ) {
                $fields['meta'] = array(
                    'label'    => 'Custom Fields',
                    'children' => array(),
                );
            }
            // Add 'sku' field
            $sku_key = 'meta._sku.value';
            $fields['meta']['children'][ $sku_key ] = array(
                'key'   => $sku_key,
                'label' => __( 'SKU', 'textdomain' ),
                'exact' => true,
                // 'weight' => 10,
            );
          
            // Add 'brand_code' field
            $brand_code_key = 'meta.brand_code.value';
            $fields['meta']['children'][ $brand_code_key ] = array(
                'key'   => $brand_code_key,
                'label' => __( 'Brand Code', 'textdomain' ),
                'exact' => true,
                // 'weight' => 50,
            );
        }
    
        return $fields;
    }
    add_filter('ep_weighting_fields_for_post_type','OM_ep_weighting',10,2);
    Plugin Author Felipe Elia

    (@felipeelia)

    Hi!

    In ElasticPress 4.6.0 we’ve made a change related to the orderby parameter that should fix your problem (you’ll need to enable the WooCommerce Feature again.)

    As we don’t provide support here, please ask any following up questions in our GitHub repository, okay? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘menu order in category page’ is closed to new replies.