Search results' url without variants ID (item.url) & product first before pages & blog results

Hi,

Try to find a solution but I’m a bit confused. I will try to be clear:

In our shop, when we search for a product, the result url (item.url) add the variant ID. But the variants are hidden in our site and no available (they are used for adding extra links), and that provide a 0.00 price article with no availability even if they are available. Feedback from our customers.. that is such a pity.

How to not print the “&variant=36497732238” at the end of the item.url search results? Like this:

With variant: https://www.claves.ch/products/robert-schumann-the-complete-works-for-piano-vol-vi-cedric-pescia?_pos=4&_sid=f0c144709&_ss=r&variant=36497732238
Without variant: https://www.claves.ch/products/robert-schumann-the-complete-works-for-piano-vol-vi-cedric-pescia?_pos=4&_sid=f0c144709&_ss=r

It could avoid these kind of problems. Or maybe antoher way to solve that like directly hidding variants in search results.

Using theme: Blockshop
Website: www.claves.ch
Added “search autocomplete” with pages, blogs & products results.

I saw that if I search for the SKU directly it provide the variant ID of the available product but if I search for a generic term as the artist “Pescia” it provide an unavailable variant ID..

https://www.claves.ch/search?q=1508
SKU search: “1508” → https://www.claves.ch/products/robert-schumann-the-complete-works-for-piano-vol-vi-cedric-pescia?_pos=1&_sid=fb6026e83&_ss=r&variant=1060642652174

https://www.claves.ch/search?q=pescia
Term search: “Pescia” → https://www.claves.ch/products/robert-schumann-the-complete-works-for-piano-vol-vi-cedric-pescia?_pos=4&_sid=f0c144709&_ss=r&variant=36497732238

search-autocomplete.liquid

{% comment %} Width of results box {% endcomment %}
{% assign results_box_width = '242px' %}
{% comment %} Background color of results box {% endcomment %}
{% assign results_box_background_color = '#ffffff' %}
{% comment %} Border color of results box {% endcomment %}
{% assign results_box_border_color = '#ebebeb' %}

snippet-searchbar-account.liquid


  {% if settings.show_multiple_currencies and settings.header-logo-center == false %}
    

      {% include 'snippet-currency-selector' %}
    

  {% endif %}

  {% if settings.header-search-show %}
    {{ 'layout.header.search_toggle_link' | t }}
  {% endif %}

  {% if settings.header-account-show and shop.customer_accounts_enabled %}
    {{ 'layout.header.account_toggle_link' | t }}
  {% endif %}
    

  
  

  {% if customer %}
    {% assign view_account_link = 'layout.header.account_view_link' | t %}
    {% capture view_account_link %}{{ view_account_link }}{% endcapture %}
    {% assign logout_link = 'layout.header.account_logout_link' | t %}
    {% assign logout_link = logout_link | customer_logout_link %}

    {{ 'layout.header.account_signed_in_html' | t: view_account_link: view_account_link, logout_link: logout_link  }}

    {% comment %}View Account (Logged in as {{ customer.first_name }}) | {{ "Logout" | customer_logout_link }}{% endcomment %}
  {% else %}
    {% assign login_link = 'layout.header.account_login_link' | t %}
    {% assign login_link = login_link | customer_login_link %}
    {% assign signup_link = 'layout.header.account_signup_link' | t %}
    {% assign signup_link = signup_link | customer_register_link %}

    {% if shop.customer_accounts_optional %}
      {{ 'layout.header.account_signed_out_html' | t: login_link: login_link, signup_link: signup_link  }}
    {% else %}
      {{ login_link }}
    {% endif %}
  {% endif %}
  

search.liquid


{% if item.metafields.inventory.ShappifyHidden == "true" %}{% continue %}{% endif %}

{% paginate search.results by 12 %}

  

    # {{ 'general.search.page_title' | t }}
  

  

    

  

  {% if search.terms != "" %}
  

    {% capture search_terms %}**"{{ search.terms }}"**{% endcapture %}
    

{{ 'general.search.results_title_html' | t: search_terms: search_terms }}

  
    
  {% endif %}

  
    

      
    

  

  {% if search.terms != "" %}
  
    {% capture search_results_size %}**{{ search.results_count }}**{% endcapture %}
    

{{ 'general.search.results_size_html' | t: search_results_size: search_results_size }}

  

  {% endif %}

  

    

  

{% if search.results != empty %}
  
  
  {% if settings.search-products-only %}
    
  {% else %} 
  {% comment %} mixed results {% endcomment %}
    {% for item in search.results %}
     

        

          {% if item.object_type == 'article' %}
            {% if item.image %}
              

                
                  {{ item | img_tag: item.title, 'class', 'medium' }}
                
              

            {% endif %}
          {% else %}
            
              {% if item.featured_image.size > 0 %}
              {{ item.featured_image | product_img_url: 'large' | img_tag }}
              {% endif %}
            

          {% endif %}
          
        

        
          

            
            ### {{ item.title | highlight: search.terms | link_to: item.url | within: collection }}
            {{ item.content | strip_html | truncatewords: 40 | highlight: search.terms }}
             
          

          

          

---

          {% if item.url contains "pages" %}
          
          Page: {{ item.handle | replace_first: '-', ' ' | upcase }}
         
          {% else %}
          	{% if item.url contains "blogs" %}
         	 Press & review
          
         	 {% else %}
          	

              
              Album
              

              Catalog N°: {{ item.type }} {{ item.variants.first.sku }}  / From collection: {{ item.collections.last.title }}

          
          

    
          

          
        
        
        {% include "awards-search" %}
             
        
        
          
       
           {% endif %}
          {% endif %}
        
        

      
      

      
        

          

        

      

    {% endfor %}
  {% endif %}

{% endif %}

  

    {% include 'snippet-pagination' %}
  

{% endpaginate %}

search.cross-sell.liquid

{% layout none %}
{% paginate search.results by 50 %}
{{ search.results | json }}
{% endpaginate %}

But maybe I’m not at the right place in the code files. If you need some additionnal code, I can add them.


In the same time: Is it possible to put the products in the first results before pages & blogs results?
Thank you in advance if someone could help me.

Best, Raphael