Jump to content

Display Attribute Title on Frontend


clampdown

Recommended Posts

I've done the following to get attributes into the product-list.tpl, if it helps. I can't recall where I learned this, and it may be copy and pasted from somewhere ;-)

 

This goes in override->controllers->front

<?php
class CategoryController extends CategoryControllerCore
{

public function initContent()
{ 
	parent::initContent();
	
	if($this->cat_products) {
	
		foreach ($this->cat_products as $key => $product) {
				
			
			$attributes_combinations = Product::getAttributesInformationsByProduct($product['id_product']);
			if(is_array($attributes_combinations) && isset($attributes_combinations[0]['group']) && $attributes_combinations[0]['group'] == 'Pack de ') {
				$this->cat_products[$key]['packcount'] = $attributes_combinations[0]['attribute'];
			} else $this->cat_products[$key]['packcount'] = false;

			
			
		}
	
	}

	$this->context->smarty->assign('products', $this->cat_products);

}

}

Link to comment
Share on other sites

  • 2 years later...

 

Hello,

In product.tpl 

add line 362 {$group_attribute|escape:'html':'UTF-8'}

 

<a href="{$link->getProductLink($product)|escape:'html':'UTF-8'}" id="color_{$id_attribute|intval}" name="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" class="color_pick{if ($group.default == $id_attribute)} selected{/if}"{if !$img_color_exists && isset($colors.$id_attribute.value) && $colors.$id_attribute.value} style="background:{$colors.$id_attribute.value|escape:'html':'UTF-8'};"{/if} title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}">
{if $img_color_exists}
<img src="{$img_col_dir}{$id_attribute|intval}.jpg" alt="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" title="{$colors.$id_attribute.name|escape:'html':'UTF-8'}" width="20" height="20" />
{/if}
<!-- Add name attribute -->
{$group_attribute|escape:'html':'UTF-8'}
</a>
Edited by Alexandre Carette (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...