Jump to content

Showing color blocks on product-list.tpl


Recommended Posts

I use the last version of prestashop and i cant figure out how i show the color block on de product-list.tpl.
How can i fix this? I've tried the following:

product-list.tpl

{if !empty($product.colors)}


 

Kleur:

 


{foreach from=$product.colors key=id_attribute item=color }
fgf
{/foreach}


{/if}

category.php

$smarty->assign(array(
'allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
'allow_oosp' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
'suppliers' => Supplier::getSuppliers(),
'colors' => (sizeof($colors) AND $product->id_color_default) ? $colors : false,
'errors' => $errors));

/* colors */
foreach ( $cat_products as $key => $cat_product ) {
$product = new Product ( intval ( $cat_product[ 'id_product' ] ), true , intval ( $cookie -> id_lang ));
$colors = array();
$attributesGroups = $product -> getAttributesGroups ( intval ( $cookie -> id_lang ));
if ( Db :: getInstance ()-> numRows ())
{
foreach ( $attributesGroups AS $k => $row )
{
/* Color management */
if (isset( $row[ 'attribute_color' ] ) AND $row[ 'attribute_color' ] AND $row[ 'id_attribute_group' ] == $product -> id_color_default )
{
$colors[$row[ 'id_attribute' ]][ 'value' ] = $row[ 'attribute_color' ] ;
$colors[$row[ 'id_attribute' ]][ 'name' ] = $row[ 'attribute_name' ] ;
$colors[$row[ 'id_attribute' ]][ 'id_image' ] =(( $row[ 'id_image' ] != NULL ) ? intval ( $row[ 'id_image' ] ) : - 1 );




}
}
}
$cat_products[$key][ 'colors' ] = $colors ;


}
Link to comment
Share on other sites

×
×
  • Create New...