Display the active collection's product type and all the product types of all products

Hello,

Can you tell me how to appear at the filter bar only the available product types at the active collection?

The code is this for my site

{%- if settings.shop_by_type_enable and shop.types.size > 0 -%}

  {%- if settings.shop_by_type_title != blank -%}
  ##### 
    {{ settings.shop_by_type_title }}
  
  {%- endif -%}
  
    

      {%- if settings.shop_by_type_custom_list != blank -%}
      {%- assign items = settings.shop_by_type_custom_list | split:"," | strip -%}
      {%- for type in shop.types limit:settings.shop_by_type_number -%}
      {%- if type != blank -%}
      {%- if items contains type -%}
      - {{ type | link_to_type }}
      

      {%- endif -%}
      {%- endif -%}
      {%- endfor -%}
      {%- else -%}
      {%- for type in shop.types limit:settings.shop_by_type_number -%}
      {%- if type != blank -%}
      - {{ type | link_to_type }}
      
      {%- endif -%}
      {%- endfor -%}
      {%- endif -%}
    

  

{%- endif -%}