cssshopifyliquidshopify-templateshopify-activemerchant

i have tried to access shopify all product handle and get 20 unique products using meta fields but somehow it display repeated products


I am developing a store overthere i'm using metafields to retrive product using all_products and also used unique handle to get product on paroduct page but somehow it gives me repeated product list for last two or three products. i'm trying to archive this using metafileds but it wont' work.
please find below snap as my problem statement below image is for liquid to get product using metafields ninteen metafields unique handles



Solution

  • Using metafields for that it's not a good idea, because multiple things can be wrong like your client creating a handle redirect.

    A handle goes to a single product but multiple handles can go to the same product, maybe that is your problem. Another trouble with your code is you convert the product title if it contains / or , so maybe they're different products but after your title conversion, they look similar... You should remember the handle can be edited, or changed to a redirect.

    Another way to achieve this can be using collections, it will be easier to maintain, adding or removing products from the collection. Adding a product metafield to save the collection will help on easy maintain and detach the collection from the product handle.

    STEPS:

    Done!

    now your code should be:

    <div>
      {% for up in collections[product.metafields.upsales.collection].products %} 
        {% if up.available != blank %}
           <!---  the rest of your code --->
        {% endif %}
      {% endfor %}
    </div>