Zecan Posted January 24, 2016 Share Posted January 24, 2016 Hello, I am creating packs of products on my prestashop 1.6.1.2The packs contain a lot of same product but with different attributes.You can see it there : http://www.canz.fr/promotions-et-packs-graffiti-bombe-de-peinture/430-pack-xx-large-iota-bombes-a-graffiti-moins-cheres.html When you go down you see "Pack Content".It displays all the thumbs of products with the "name - attribute name- attribute ref" of each. I would like to keep only the last part, not the name part as it is always the same. For example : Ironlak Premium 400ml - Bombe de Peinture Couleur-Bolt - Marron Sombre I will only keep : Bolt - Marron Sombre. So nothing is repeated.I checked 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:245:'...'|escape:'html':'UTF-8'} </a> </h5> I've tried {$product.reference|truncate:245:'...'|escape:'html':'UTF-8'} But it displays the same reference for all attributes, it displays the reference of product not of the attribute. I could not find a variable to display this.Anyone can help? Thx.Regards, Zecan. Link to comment Share on other sites More sharing options...
Zecan Posted January 25, 2016 Author Share Posted January 25, 2016 I'm adding a little up, I'm still trying to do it. Thank you. Link to comment Share on other sites More sharing options...
musicmaster Posted January 26, 2016 Share Posted January 26, 2016 Did you try {$product|print_r} to see which variables are available in your template? Link to comment Share on other sites More sharing options...
Zecan Posted January 27, 2016 Author Share Posted January 27, 2016 Array ( [id_product] => 8 [id_supplier] => 0 [id_manufacturer] => 2 [id_category_default] => 6 [id_shop_default] => 1 [id_tax_rules_group] => 2 [on_sale] => 0 [online_only] => 0 [ean13] => 0 [upc] => [ecotax] => 0.000000 [quantity] => 19 [minimal_quantity] => 1 [price] => 3.4 [wholesale_price] => 0.000000 [unity] => [unit_price_ratio] => 0.000000 [additional_shipping_cost] => 0.00 [reference] => IR400 [supplier_reference] => [location] => [width] => 0.000000 [height] => 0.000000 [depth] => 0.000000 [weight] => 0.440000 [out_of_stock] => 2 [quantity_discount] => 0 [customizable] => 0 [uploadable_files] => 0 [text_fields] => 0 [active] => 1 [redirect_type] => 404 [id_product_redirected] => 0 [available_for_order] => 1 [available_date] => 0000-00-00 [condition] => new [show_price] => 1 [indexed] => 1 [visibility] => both [cache_is_pack] => 0 [cache_has_attachments] => 1 [is_virtual] => 0 [cache_default_attribute] => 3321 [date_add] => 2013-05-26 18:44:54 [date_upd] => 2016-01-14 13:11:24 [advanced_stock_management] => 0 [pack_stock_type] => 3 [id_shop] => 1 [id_lang] => 1 [description] => .......... [link_rewrite] => bombe-de-peinture-ironlak-premium-graffiti [meta_description] => Bombe de Peinture Ironlak pour le graffiti Acrylique et Brillante. [meta_keywords] => bombe de peinture,ironlak,spray,aerosol,acrylique,brillante,graffiti,carrosserie [meta_title] => [name] => Ironlak Premium 400ml - Bombe de Peinture Couleur-Bolt - Marron Sombre [available_now] => [available_later] => [id_image] => 8-127 [legend] => Ironlak Premium 400ml - Bombe de Peinture [category_default] => Bombes de Peinture [pack_quantity] => 2 [id_product_pack] => 430 [id_product_attribute_item] => 3321 [id_product_attribute] => 3321 [rate] => 20 [tax_name] => TVA [allow_oosp] => 0 [category] => bombes-de-peinture [link] => http://www.canz.fr/bombes-de-peinture/8-bombe-de-peinture-ironlak-premium-graffiti.html [attribute_price] => 0 [price_tax_exc] => 2.833333 [price_without_reduction] => 3.4 [reduction] => 0 [specific_prices] => [quantity_all_versions] => 2566 I only get this. [Name] is the only one which display the attribute name. Is there a way to truncate it? Link to comment Share on other sites More sharing options...
musicmaster Posted January 27, 2016 Share Posted January 27, 2016 Something like {$product->name|truncate:25:'...'} ? Link to comment Share on other sites More sharing options...
Zecan Posted January 28, 2016 Author Share Posted January 28, 2016 Thank you Musicater. But it's still not what I need. It displays "Ironlak Premium 400ml..."So the 25 first letters. What I need is here in green : Ironlak Premium 400ml - Bombe de Peinture Couleur-Bolt - Marron Sombre I can't find any solution with regular variables. Any ideas? Link to comment Share on other sites More sharing options...
musicmaster Posted January 28, 2016 Share Posted January 28, 2016 (edited) Something like {$product->name|substr:50} ? See also here: http://stackoverflow.com/questions/4389978/smarty-getting-substring-of-a-var-with-strpos-as-start-and-strlen-as-end Edited January 28, 2016 by musicmaster (see edit history) Link to comment Share on other sites More sharing options...
Zecan Posted January 28, 2016 Author Share Posted January 28, 2016 Thank you for the link, this is very interesting. I've tried this : <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" > {assign var="bar_at" value=$produt.name|strpos:"-"} {$product.name|substr:($bar_at+1)} </a> </h5> But it doesn't work, it just cut the first letter of the full name. Link to comment Share on other sites More sharing options...
musicmaster Posted January 28, 2016 Share Posted January 28, 2016 value=$produt.name Looks like a typo to me... Link to comment Share on other sites More sharing options...
Zecan Posted January 28, 2016 Author Share Posted January 28, 2016 I think I can make it work using this {assign var="bar_at" value=$produt.name|strpos:"|"} {$product.name|substr:($bar_at+1)} But it means that $product.name has to display thisIronlak Premium 400ml - Bombe de Peinture Couleur | Bolt - Marron Sombre instead of this Ironlak Premium 400ml - Bombe de Peinture Couleur-Bolt - Marron Sombre Do you know where I can edit the $product.name variable so as to try to change the separator to | between attribute group name and attribute name ? Link to comment Share on other sites More sharing options...
Zecan Posted January 28, 2016 Author Share Posted January 28, 2016 Ok. The best I could do is {assign var="bar_at" value=$product.name|strpos:"Couleur-"} {$product.name|substr:($bar_at)} We get this :Couleur-Bolt - Marron Sombre And it means that it only works with product with attribute group name as "Couleur".It is not solved, if someone has a better idea, thank you. Link to comment Share on other sites More sharing options...
musicmaster Posted January 29, 2016 Share Posted January 29, 2016 There are more variables in your template. Try {$attributesCombinations|print_r} Link to comment Share on other sites More sharing options...
Zecan Posted January 30, 2016 Author Share Posted January 30, 2016 I just get this Array ( ) 1 Link to comment Share on other sites More sharing options...
Zecan Posted February 9, 2016 Author Share Posted February 9, 2016 Hello, I've still not found a best solution than what I did up. Any help please, thx. Link to comment Share on other sites More sharing options...
Zecan Posted February 15, 2016 Author Share Posted February 15, 2016 I'm done with this. If anyone can contact me in private to help me, I'll pay for it. THX. Link to comment Share on other sites More sharing options...
safa Posted February 15, 2016 Share Posted February 15, 2016 there is no need paid service or tpl edit upload first orginal .tpl file(product-list.tpl) open this file , classes / Pack.php find this line $line['name'] .= ' '.$value['group_name'].'-'.$value['attribute_name']; replace like this $line['name'] = $value['attribute_name']; Note: i don't tested if not works write here i will try help you. Regards.. Link to comment Share on other sites More sharing options...
Zecan Posted February 16, 2016 Author Share Posted February 16, 2016 Hi Safa, thank you. I've been trying now for two weeks and your help solved it very quickly. The most funny is that I tried that you said one week before but I forgot to remove the "." before the = It works like a charm now. I Mark it as SOLVED. Best regards, Bertrand. 1 Link to comment Share on other sites More sharing options...
safa Posted February 16, 2016 Share Posted February 16, 2016 (edited) you're welcome, many time i forgot ", . ; e.t.c." it's not a bug it's a feature Edited February 16, 2016 by safa (see edit history) 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