Hey guys!
I thought my need was very basic but I can't seem to find a way out.
I just want to display a product on the home page. I don't want like the featured products with only the link to the product. I want directly the product with the add to cart button, the cover, description, everything.
In order to do that, I created a module in which I can configure the product ID to display.
And then, I tried to do something like that
public function HookDisplayMyProduct($params) { $productId = Configuration::get('DISPLAYPRODUCT_ID'); if ($productId !== false) { $lang_id = (int) Configuration::get('PS_LANG_DEFAULT'); $product = new Product($productId, false, $lang_id); if (Validate::isLoadedObject($product)) { $this->context->smarty->assign([ 'product' => (array) $product, ]); return $this->display(__FILE__, 'my-product.tpl'); } } }
The my-product.tpl is just a copy/paste from the original product.tpl
And then, in my homepage, I just display the hook
{block name='hook_my_product'}
{hook h='displayMyProduct'}
{/block}
And I thought it was enough but the $product variable does not contain everything I need, I have some errors like "Undefined index: id_customization (or cover and so on)"
So maybe I did something wrong here and there is an easier way to achieve that.
Any input would be much appreciated !
I'm on PS 1.7
Cheers