Ilvi
Ilvi

Reputation: 13

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}

Upvotes: 0

Views: 660

Answers (1)

PrestaAlba
PrestaAlba

Reputation: 689

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.

Upvotes: 1

Related Questions