bevi Posted January 18, 2012 Share Posted January 18, 2012 I create a custom .tpl file and I want to call for the product name, firstly I use $product.name and didn't work, on the same code $product.link and $product.price work good the call for the image works to but the product name and product description no way. How can I try to call for this? Anyone knows? Link to comment Share on other sites More sharing options...
Richard S Posted January 18, 2012 Share Posted January 18, 2012 If you created a custom .tpl then you need to be sure that you are sending right information to your .tpl. As I can see you are using an array and, for example, in the default theme of PrestaShop product.tpl there is an object called $product, so you get a name of product by calling $product->name or to be more specific {$product->name|escape:'htmlall':'UTF-8'} Link to comment Share on other sites More sharing options...
bevi Posted January 18, 2012 Author Share Posted January 18, 2012 Richard first thanks for your response. I try using $product->name before without luck, this is the code I use to send the information to the custom .tpl public function displayContent() { global $smarty; $category = new Category(4, Configuration::get('PS_LANG_DEFAULT')); $products = $category->getProducts((int)($params['cookie']->id_lang), 1, 6); $smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize('welchallyn'))); parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'welchallyn.tpl'); } What you think about it? Link to comment Share on other sites More sharing options...
Richard S Posted January 19, 2012 Share Posted January 19, 2012 Have you tried print_r($products) before assigning to Smarty? Is there information good? and I think that parent::displayContent() should be the second line after "global $smarty" which is also not really required if you use everywhere self::smarty. Link to comment Share on other sites More sharing options...
bevi Posted January 20, 2012 Author Share Posted January 20, 2012 I try that you said using print_r($products) and have notice that the name key was null, put parent::displayContent() on second line and same results than always. There is other way to bring the name of the $product variable? Link to comment Share on other sites More sharing options...
Richard S Posted January 20, 2012 Share Posted January 20, 2012 if it is null then you will not get the value and you need to check your database for problems or why there is no name in it. Maybe you are getting wrong language etc. Link to comment Share on other sites More sharing options...
Rolige Posted January 20, 2012 Share Posted January 20, 2012 I try that you said using print_r($products) and have notice that the name key was null, put parent::displayContent() on second line and same results than always. There is other way to bring the name of the $product variable? Hola bevi, mire el post y entre por curiosidad, exactamente que es lo que estas tratando de hacer, quiza pueda ayudarte con algo. Link to comment Share on other sites More sharing options...
bevi Posted January 24, 2012 Author Share Posted January 24, 2012 @Richard S, the database is ok, the same product assigned to other category shows right on other place of the site, I use a few products on this test phase, more over I duplicate the homefeatured module to call the products on the category created for the custom .tpl and create a custom hook to call it and the products shows all the data without issues, anyways I still wonder how can I call the product name without the need of use a module or hook. Some suggest than the product name comes from the language table and its need to make the query on this way, didn't know how to do that 'till now. @aQs, buenas! vi que comentaste en el hilo en español que cree para esta misma consulta, creo que ahí pude poner las cosas mas claras, te deje respuesta ahí. aprovecho para decirte que el sitio del link que compartiste esta quedando muy bien! Link to comment Share on other sites More sharing options...
Richard S Posted January 24, 2012 Share Posted January 24, 2012 It it possible that you get this error if you translated your product name to only a few languages and you trying to select from the language that has not got this product name translated. By the way, using modules and hooks are the best principles in PrestaShop. Link to comment Share on other sites More sharing options...
bevi Posted January 24, 2012 Author Share Posted January 24, 2012 I'm sure than the language is the same, check the others languages than was active and have data on product name. Anyways I can resolve using modules and hooks and like you said if is a good practice it's better to know how to do it in the right way. Thanks a lot for your comments and the sharing of your knowledge Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now