Jump to content

[Solved] how to change the Short description max character limit?


Recommended Posts

Dear Experts:

I Have a questions on the proudct short descripton max character, and now, when I input over 400 character I can’t save my product, and get the below alert event,
1 error
the field description_short (English (English)) is too long : 400 chars max (count now 3912)

so I want increase the max character limit. but I have looked the mysql table product_lang the long descripton and short descripton is configure same. so I think the limit maybe not on mysql table,please kindly give a advices for the issue slove,thanks so much.

Best Regards.
Herny

Link to comment
Share on other sites

  • 1 month later...

I have come up against the same issue and want to be able to modify that 400 limitation to 500 - but I don't understand from the above posts how this can be resolved. Can anyone clarify this a little more? Which specific pieces of which documents need to be changed?

  • Like 1
Link to comment
Share on other sites

Change lines 667-668 of admin/tabs/AdminProducts.php from:

if (Tools::strlen(strip_tags($value)) > 400)
   $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), 'description_short').' ('.$language['name'].') '.$this->l('is too long').' : 400 '.$this->l('chars max').' ('.$this->l('count now').' '.Tools::strlen(strip_tags($value)).')';



to:

if (Tools::strlen(strip_tags($value)) > 500)
   $this->_errors[] = $this->l('the field').' '.call_user_func(array($className, 'displayFieldName'), 'description_short').' ('.$language['name'].') '.$this->l('is too long').' : 500 '.$this->l('chars max').' ('.$this->l('count now').' '.Tools::strlen(strip_tags($value)).')';

Link to comment
Share on other sites

Sorry, was in a rush and I forgot about the other file. You need to also modify classes/Product.php and change:

foreach ($this->description_short as $k => $value)
   if (Tools::strlen(strip_tags($value)) > 400)
   {
       if ($die) die (Tools::displayError().' ('.get_class($this).'->description: length > 400 for language '.$k.')');
           return $errorReturn ? get_class($this).'->'.Tools::displayError('description: length > 400 for language').' '.$k : false;
   }
   return parent::validateFieldsLang($die, $errorReturn);



to:

foreach ($this->description_short as $k => $value)
   if (Tools::strlen(strip_tags($value)) > 500)
   {
       if ($die) die (Tools::displayError().' ('.get_class($this).'->description: length > 500 for language '.$k.')');
           return $errorReturn ? get_class($this).'->'.Tools::displayError('description: length > 500 for language').' '.$k : false;
   }
   return parent::validateFieldsLang($die, $errorReturn);

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

I have two sites which have some products in common (v. 1.3.1). For some products the short description was too short, so I followed the instructions here and extended it to 500. Then I had a product which needed 547 characters in the short description, so I repeated these steps and extended the short description to 575 characters, but it still got truncated. I then reduced the characters until the last part of the text was visible. So I was already puzzled that even though I had increased the maximum number of characters to well in excess of the number of characters in this product's short description, it was still getting truncated. I then noticed that on the 2nd site, items that had shown untruncated on the first site, were still getting truncated, even though the settings were identical (checked and rechecked). As I wanted to put the same product that I had just added to the first site onto the second site, and therefore needed to increase the length of the short description on the second site as well, I copied the entire adminproducts and product files from the 1st site to the 2nd site. So even if my check and recheck was faulty, now I could be 100% certain that the settings for the short description are identical, yet they display differently with less truncation on the first site than on the second. No warning comes up on either site as the products are saved so it would seem that the software is expecting the short descriptions to display correctly. Font and font size are also identical yet they also display slightly differently.

Anybody have any ideas on this strange anomaly?

29704_bTLGyL14SXpDS0OIlsaB_t

29705_Jr7rt5aOVYMytj43Xd4p_t

Link to comment
Share on other sites

It looks like it is Smarty that is truncating the description. You will need to change line 9 of product-list.tpl in your theme's directory (in PrestaShop v1.3.1):


<a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}">{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}



Increase the truncate value from 360 characters to the number of characters you want displayed before "..." is displayed, or just delete the |truncate:360:'...' part altogether if you never want any truncation.

Link to comment
Share on other sites

Hi,

Truncation works for the short description when products are listed in their categories, but how would you truncate the short description on the actual product page? I think you need to add something to product.tpl but cannot figure out what?

Any ideas?

Cheers,
Geoff

Link to comment
Share on other sites

  • 6 months later...

I have followed the instructions to increase my short desc from 400 to 900 as i want the longest descriptions in there, but i still get this error:

MRR 326: cannot be saved
Product->description: length > 400 for language 1
MRR 333: cannot be saved
Product->description: length > 400 for language 1

what do i do?

Link to comment
Share on other sites

  • 5 months later...
  • 3 weeks later...
  • 1 month later...
  • 2 months later...

For PrestaShop™ 1.4.6.2:

 

I was increase limit in

 

AdminProducts.php:1136

 

/* Check description short size without html */

$limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');

if ($limit <= 0) $limit = 1200;

 

and obtain error:

 

Fatal error (Product->description_short: length > 800 for language 6)

 

Only 800 chars I can input into short desc

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
  • 1 year later...

In Prestashop 1.5.4

 

controllers/admin/AdminProductsController at line 1952.

 

// Check description short size without html

$limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');

if ($limit <= 0) $limit = 400;

 

Current limit is 400, so if you dont find the line, just search for "400" and then change the number to whatever u wish.

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

Im looking in configuration table, but there isn't 'PS_PRODUCT_SHORT_DESC_LIMIT''.. 

 

In back office it appears well.  

 

 

EDIT. Ok, now its working. 

this work on my prestashop 1.6 

`ps_configuration` -> PS_PRODUCT_SHORT_DESC_LIMIT 

 

and edit

value text  cange 255 -  to other

Link to comment
Share on other sites

  • 5 months later...

Hi guys,

 

In prestashop 1.6, the max length of short description is a preference product option,

to change the max length of an other of product as name:

1)override Product with the new length

class Product extends ProductCore{
    
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) {
        self::$definition['fields']['name']['size'] = 255;
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }

}

2) change in mysql the setting length of the field name in the table product_lang to new value

3) purge the cache with a delete of cache/class_index.php to launch your override of Product.php

 

Best

Edited by pkodevphp (see edit history)
Link to comment
Share on other sites

  • 2 years later...
  • 1 month later...
  • 6 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...