Nadium Posted February 21, 2015 Share Posted February 21, 2015 Hi everyone, I'm currently struggling with an issue which is displaying a custom field on my product_list.tpl. The field has already been created in the database, and is correctly displayed in the product.tpl file with the following : <h2 class="book-subtitle">{$product->xtd_name2|escape:'html':'UTF-8'}</h2> I tried to use the same line on my product-list page, however, it doesn't seem to work and I just don't get the reason. Thanks for your help ! PS : My shop uses Prestashop 1.6 Link to comment Share on other sites More sharing options...
ventura Posted February 21, 2015 Share Posted February 21, 2015 Try this <h2 class="book-subtitle">{$product.xtd_name2|escape:'html':'UTF-8'}</h2> Link to comment Share on other sites More sharing options...
Nadium Posted February 21, 2015 Author Share Posted February 21, 2015 Thanks for your answer ventura. Sadly, I already tried this one and the content is still empty Link to comment Share on other sites More sharing options...
Nadium Posted February 26, 2015 Author Share Posted February 26, 2015 I'm still struggling with this one issue. Got the same problem with my manufacturer-list.tpl (I tried creating a custom field again and to display it on the list) This is kind of confusing because the previous answer seemed logical to me and I have no clue about where to look at to find the answer Link to comment Share on other sites More sharing options...
Nadium Posted March 6, 2015 Author Share Posted March 6, 2015 Ok, so the answer for my question was here : https://www.prestashop.com/forums/topic/296666-solved-custom-field-not-reflecting-in-productlist-and-home-featured-need-help/ To display a custom field on the product-list page, you have to edit the getProduct() function of the classes/Category.php and add a query for your field. In my example, I added " pl.`xtd_name2` " $sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`xtd_name2`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new, product_shop.price AS orderprice Thanks to vekia and to his answer from 1 year ago ! 2 Link to comment Share on other sites More sharing options...
jaywaters Posted September 15, 2015 Share Posted September 15, 2015 Hi Nadium, I'm in exactly the same situation as you were, except this solution doesn't seem to be working. In my case, I've added an 'author' field - it's all working fine in the db and the product page but doing the above edit to the classes/Category.php just seems to break it, causing no items to be listed on the home page or when filtering by category. I've just added the following: pl.`author` Is there something else I'm missing? Thanks! Link to comment Share on other sites More sharing options...
sandra nanou Posted July 3, 2017 Share Posted July 3, 2017 Hi, The issue is quite old but I'm also struggling. I modified getProduct() function in Category.php but my field doesn't show. Have you found a solution? 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