Alejandrosi Posted August 21, 2014 Share Posted August 21, 2014 Hello all, I am trying to add the product reference in th product listing, below the product name. I was reading lots of posts and it seems to be easier in older ps versions but I am facing a problem when trying to add it. Adding {$product.reference} into the product-list.tpl don´t work in this ps version. I managed to add the reference into the product-list by adding the following code to the product-list.tpl: <p id="product_reference"{if empty($product->reference) || !$product->reference} style="display: none;"{/if}> <label>{l s='Model'} </label> <span class="editable" itemprop="sku">{$product.reference} </span> </p> The problem is when changing the view from grid to list. It changes to "undefined" I used the following code into the global.js (the one that manages the switch): html += '<p id="product_reference">'+ $(element).find('.product_reference').html() + '</p>'; I know the problem is here in the global.js but as I don´t have idea of this lenguaje I can´t find out how to make it work. Hope I was clear, and please advise if someone knows how to do this Thanks! Link to comment Share on other sites More sharing options...
vekia Posted August 22, 2014 Share Posted August 22, 2014 you use ($product->reference) in if codition and {$product.reference} in <span> product-list.tpl doesnt contain $product as object, just a $product as an array so you have to use this variable as array use $product.reference only Link to comment Share on other sites More sharing options...
Alejandrosi Posted August 22, 2014 Author Share Posted August 22, 2014 Hi thanks. And should I change the the global.js code? Link to comment Share on other sites More sharing options...
vekia Posted August 23, 2014 Share Posted August 23, 2014 no, in js file everything is allright :-) Link to comment Share on other sites More sharing options...
Alejandrosi Posted August 23, 2014 Author Share Posted August 23, 2014 Vekia. I don´t want to keep on bothering you but it still disappears when switching from grid to list. I left the product-list.tpl like this: <p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}> <label>{l s='Model'} </label> <span class="editable" itemprop="sku">{$product.reference} </span> </p> The product reference ppears correctly but then it disappears. Link to comment Share on other sites More sharing options...
Totti Posted August 23, 2014 Share Posted August 23, 2014 because once you use. and once -> ? Link to comment Share on other sites More sharing options...
Alejandrosi Posted August 26, 2014 Author Share Posted August 26, 2014 Hi Totti. I changed to . all the ->. The reference appears. But it changes to undefinded once you change from grid to list Link to comment Share on other sites More sharing options...
Alejandrosi Posted August 28, 2014 Author Share Posted August 28, 2014 Any ideas? I left the product list.tpl <p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}> <label>{l s='Model'} </label> <span class="editable" itemprop="sku">{$product.reference} </span> </p> and the global.js html += '<p id="product_reference">'+ $(element).find('.product_reference').html() + '</p>'; 1 Link to comment Share on other sites More sharing options...
Alejandrosi Posted September 2, 2014 Author Share Posted September 2, 2014 I resolved the issue inserting the product reference code inside the <h5> of the product name. It seems to be working fine. Link to comment Share on other sites More sharing options...
Totti Posted September 3, 2014 Share Posted September 3, 2014 ($product->reference) for object and {$product.reference} for array ?? Link to comment Share on other sites More sharing options...
michelnavone Posted September 9, 2014 Share Posted September 9, 2014 Hi, does anyone have the final solution how to display the product reference in the categories view? I am already completely frustrated...once it works one view, it doesnt in the either. What do i need to do to get it done?? thannnkkkssss! Link to comment Share on other sites More sharing options...
Alejandrosi Posted September 9, 2014 Author Share Posted September 9, 2014 In product-list.tpl: <h5 itemprop="name"> {if isset($product.pack_quantity) && $product.pack_quantity}{$product.pack_quantity|intval|cat:' x '}{/if} <a class="product-name" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url"> {$product.name|truncate:45:'...'|escape:'html':'UTF-8'} </a> <p id="product_reference"{if empty($product.reference) || !$product.reference} style="display: none;"{/if}> <label>{l s='Model'} </label> <span class="editable" itemprop="sku">{$product.reference}</span> </p> </h5> And it shows right after the Product name. Try it and let me know. 2 Link to comment Share on other sites More sharing options...
michelnavone Posted September 9, 2014 Share Posted September 9, 2014 Wow, perfect, works!! Would you know how to use a different font size for the product reference...? Now it shows it exactly the same as way as in the product view thank you!!! Link to comment Share on other sites More sharing options...
Alejandrosi Posted September 9, 2014 Author Share Posted September 9, 2014 You should add a line in the global.css file. p#product_reference { font-size: % } Choose the % you fit the best or use firebug or the chrome inspector to see how to change it the best. I´m glad it helped you. It took me months to find a solution! Link to comment Share on other sites More sharing options...
michelnavone Posted September 14, 2014 Share Posted September 14, 2014 THANK YOU!!!!!! everything worked well!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts