Alternative to All_Products

Highlighted
New Member
2 0 0

I'm looking for an alternative to "all_products"

 

Our current theme uses all_products to display photos of our products in the main menu. Unfortunately we have more than 20 products, so the product images for any product after 20 does not load because of the all_products limit of 20 per page.  Is there an alternative way to call on these product images?

 

Here is the menu code:

{% for link in linklists[vertical-menu].links %}
	<div class="cd-dropdown-wrapper">
		{% if linklists[link.handle] == empty %}
			<li><a class="cd-main-trigger" href="{{ link.url }}">{{ link.title }}</a></li>
		{% else %}
      {% if link.url == '#' %}
		<a class="cd-dropdown-trigger" href="javacript:void(0);">{{ link.title }}</a>
      {% else %}
        <a class="cd-dropdown-trigger" href="{{ link.url }}">{{ link.title }}</a>
      {% endif %}
			<nav class="cd-dropdown">
				<ul class="cd-dropdown-content">
					{% for link in linklists[link.handle].links %}
						{% if linklists[link.handle] == empty %}
							{% if link.url contains 'products/' %}
								{% assign p_handle = link.url | split: '/' | last %}
								{% if all_products[p_handle].variants.size > 1 %}
									<li class="has-children">
										<a href="{{ link.url }}" class="">{{ link.title }}</a>
										<ul class="cd-dropdown-gallery is-hidden fade-out">
											{% for variant in all_products[p_handle].variants %}
												<li>
													<a class="cd-dropdown-item" href="{{ link.url }}">
														<img src="{{ variant.image.src | img_url: '1024x1024' }}" alt=""/>
														<h3>{{ link.title }} <br/> {{ variant.title}}</h3>
													</a>
												</li>
											{% endfor %}
										</ul>
									</li>
								{% else %}
									<li><a href="{{ link.url }}" class="">{{ link.title }}</a></li>
								{% endif %}
							{% else %}
									<li><a href="{{ link.url }}" class="">{{ link.title }}</a></li>
							{% endif %}
						{% else %}
							<li class="has-children">
								<a href="{{ link.url }}" class="">{{ link.title }}</a>
								<ul class="cd-dropdown-gallery is-hidden fade-out">
									{% for link in linklists[link.handle].links %}
										<li>
											{% assign p_handle = link.url | split: '/' | last %}
											<a class="cd-dropdown-item" href="{{ link.url }}">
												<img src="{{ all_products[p_handle].featured_image | img_url: '1024x1024' }}" alt=""/>
												<h3>{{ link.title }}</h3>
											</a>
										</li>
									{% endfor %}
								</ul>
							</li>
						{% endif %}
					{% endfor %}
				</ul>
			</nav>
		{% endif %}
	</div>
{% endfor %}

Any help would be appreciated, thanks!

0 Likes
Shopify Partner
2536 31 561

You do not need to use all_products here. I'd be using code like this:

{% if link.type == product_link %}
  {% assign this_product = link.object %}
  {{ this_product.title }}
  {{ this_product.image | img_tag }}
{% endif %}

Check this https://help.shopify.com/en/themes/liquid/objects/link#link-object

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com! My post solved your problem? This is my Paypal too :)
0 Likes