Jump to content

[SOLVED] How to use $smarty vars


Recommended Posts

Hi,
 
I want to use the product vars in a custom module. In my controller I have this:

<?php
class producttopdfdisplayModuleFrontController extends ModuleFrontController
{
	public function initContent()
	{
		parent::initContent();

		$this->context->smarty->assign(
			array(
				'my_module_name' => Configuration::get('MYMODULE_NAME'),
				'my_module_link' => $this->context->link->getModuleLink('producttopdf', 'display')
			)
		);

		$this->setTemplate('display.tpl');
	}
}

but I can`t use $product->id for example. I need to use the product name, sku, images, description, etc.

Thanks for you time.

Edited by vekia (see edit history)
Link to comment
Share on other sites

you have to pass $product variable to smarty array, something like:

$product = new Product(12);
$this->context->smarty->assign(array(
'my_module_name' => Configuration::get('MYMODULE_NAME'),
'product' => $product,
'my_module_link' => $this->context->link->getModuleLink('producttopdf', 'display')
));

where the 12 is a product ID number you want to display.

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...