Jump to content

How to add variable to product-list.tpl ?


miguelangelss4

Recommended Posts

Hello,

I'm trying to add some variable to the product-list.tpl but I'm not able to achieve this.

 

I have tried some things... First in my tpl file I added:

{$product.msolla|var_dump} {$msolla|var_dump}

And I updated \controllers\front\ProductController.php, function initContent() by adding 'msolla' => 'asdf' in the $this->context->smarty->assign() array argument. Also I added $this->msolla = 'asdfa' in \classes\Product.php

 

Other thing I tried is to adapt this http://nemops.com/lowest-price-prestashop-product-list/#.Wo2OWKiWbcs to my case, with this:

class CategoryController extends CategoryControllerCore
{
	public function initContent()
	{
		parent::initContent();
		
		$this->context->smarty->assign('msolla', 555);
	}
}

Any of this worked. All of this (and combinations between all) are printing a null content for "msolla" variable...

What I'm doing wrong?

 

Thanks!

Link to comment
Share on other sites

Hi Rho_Bur,

yes, I tried to do this... my CategoryController was my try to overriding this. I put this file \override\controllers\front\CategoryController.php with the code of my first post, but in product-list.tpl file I have 

{$product.msolla|var_dump} {$msolla|var_dump}

And both have a null value... :( 

Link to comment
Share on other sites

9 hours ago, miguelangelss4 said:

Hi Rho_Bur,

yes, I tried to do this... my CategoryController was my try to overriding this. I put this file \override\controllers\front\CategoryController.php with the code of my first post, but in product-list.tpl file I have 


{$product.msolla|var_dump} {$msolla|var_dump}

And both have a null value... :( 

 

then  what's output of  

{var_dump($msolla)}

Link to comment
Share on other sites

  • 2 years later...

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...