'Display product available sizes on product miniature Prestashop 1.7

I would like to know how to show available product sizes on product miniature in Prestashop 1.7.

Variable $product.size gives an array so I tried somehow to use

<ul>
{foreach from=$product key=?? item=??}
    <li>{$product.size}</li>
{/foreach}
</ul>

but doesn't work. Exactly it returns maybe 20 empty

  • file is located in your_theme/templates/catalog/_partials/miniatures/product.tpl

    Could somebody help me?

    Thanks is advance



  • Solution 1:[1]

    Unfortunately in 1.7 you can't just display all attributes related to product, without additional modifications. By default, you have only access to "default" attribute.

    There are number of additional modules to do that, you can search them by looking for "PrestaShop Attributes on product list" on both official and third party marketplaces.

    If you want to consider doing modification by your own, I suggest to look at the Product::getProductsProperties method where you have a code which is used to get all informations about the product displayed on the list.

    Solution 2:[2]

    Display defaut attributes on product miniature Prestashop 1.7 file located : your_theme/templates/catalog/_partials/miniatures/product.tpl

    {*------Display default attributes in product list-----*}
    {if isset($product.attributes) && !empty($product.attributes)}
        <span class="default-attributes">
            {foreach from=$product.attributes item=attribute}             
                 {$attribute.group} : {$attribute.name}
                {/if}
            {/foreach}
        </span>
    {/if}
    

    Solution 3:[3]

    For me works the solution by Idriss el basrii thanks to him but you just delete the {/if} closure tag inside foreach :

    {*------Display default attributes in product list-----*}
    {if isset($product.attributes) && !empty($product.attributes)}
    <span class="default-attributes">
        {foreach from=$product.attributes item=attribute}             
             {$attribute.group} : {$attribute.name}
        {/foreach}
    </span>
    

    Sources

    This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

    Source: Stack Overflow

    Solution Source
    Solution 1 Krystian Podemski
    Solution 2 Idriss el basrii
    Solution 3