Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
Guil182

Attribute Name on product list

Question

Hi,

I want to display the attribute name of the combination on product list.

So, in config.inc.php, i created this function :

function name_combination($id_product_attribute){
    $combination = new Combination($id_product_attribute);
     $nomcombination = $combination->getAttributesName(Context::getContext()->langage->id);
    
     return $nomcombination;
}

And in product-list.tpl :

<span>
{name_combination($product.id_product_attribute)}
</span>

But it always return an empty array....:/

Thank for your help

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi,

Your approach is wrong....to place a function inside config.inc.php file is bad idea.

But even if you want to go that way product-list.tpl has $products variable and inside there a foreach loop that include `product-list-item.tpl` each time with $product variable.

So you should put your code inside product-list-item.tpl

A better approach will be to create a simple module with a unique hook and exec that hook inside the tpl file.

{hook h="my_unique_hook" mod="my_module_name" product=$product}

 

Share this post


Link to post
Share on other sites
  • 0

Hi,

Thank you, you are right.
I just modified and created all that.
In addition, I solved my problem, it was the id of the language that I did not get.

regards

Share this post


Link to post
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...