How can I correctly create an array and add items in code?

Hi everyone,

I’m writing some code to add products to any blog post based on tags that use product’s handle. I’ve tried with one product and it works just fine so I was trying to iterate it through a loop but I couldn’t get any information from the array I’ve created. This is the code I’ve written so far. Can you help me understand what I’m doing wrong? Thanks!

{% comment %}declare variables{% endcomment %}
  {% assign related_prod_index = 0 %}
  {% assign related_prod_array = "" | split: ',' %}    
      
{% comment %}check for tags that contains products handles{% endcomment %}
  {% for tag in article.tags %}
      {% if tag contains "product_"%}
        {% assign prod_handle = tag | split:"_" %}
        {% assign blog_prod = all_products[prod_handle[1]] %}
        {% assign related_prod_array = related_prod_array | push:blog_prod  %}
        {% assign related_prod_index = related_prod_index | plus:1 %}
      {% endif %}
  {% endfor%}

{% comment %}check how many product tags I found{% endcomment %} 
 # {{ related_prod_index }} tags found
     
{% comment %}loop that create small preview for each product{% endcomment %} 
  {% if related_prod_array %} 
      {% for rel_pr in related_prod_array %}
        
        

{{rel_pr.title}}

        

{{rel_pr.price | money}}

      {% endfor %}
{% endif %}