Search code examples
phpsmartyprestashopprestashop-1.6

Prestashop 1.6: How to get color list for accessories block in product view


How can I get color list for each product in accessories block in product view in a loop:

{foreach from=$accessories item=accessory name=accessories_list}

{/foreach}

Solution

  • You can use function getAttributesColorList from Product class. You need to pass as parameter an array of product IDs. You can call directly in you TPL but I don't recommend it:

    {foreach from=$accessories item=accessory name=accessories_list}
        {assign var='accesoryColors' value=Product::getAttributesColorList(array($accessory.id_product))}
    {/foreach}
    

    A cleaner option is to modify $accessories var in controller before pass it to TPL.

    Good luck.