Jump to content

Product Summary length too long


vm0824

Recommended Posts

Hello,

   I have found that the product editor in the back office reports an error if the Summary field is longer than 800 characters. However, It still does not save the new Summary text unless the total markup length is 408 or less.

 

For instance, if I save a summary of 500 characters, I get no errors. In fact, I get a "Settings Updated" balloon that indicates success. But, if I refresh the page, the summary text is back to how it was before the edit.

 

How can I troubleshoot this? I  checked MySQL and I see its a type of "TEXT" which should be able to store 65k characters.

 

running 1.7.0.5

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

Have you tried adjusting the "Max size of product summary" on the Shop Parameters > Product Settings tab? By default, it is blank, which limits it to 800 characters.

 

I found the validation code on lines 888-897 of classes/Product.php:

        if ($field == 'description_short') {
            $limit = (int) Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');
            if ($limit <= 0) {
                $limit = 800;
            }

            $size_without_html = Tools::strlen(strip_tags($value));
            $size_with_html = Tools::strlen($value);
            $this->def['fields']['description_short']['size'] = $limit + $size_with_html - $size_without_html;
        }

It appears to increase the limit of the field so that HTML tags are not included in the count.

Link to comment
Share on other sites

Ah hah! If I set the value of "Max size of product summary", then it actually obeys this number. However, if it is left at 0 (as default), then it behaves in the following way:

  • validation will still default to 800. So a 700 character summary will pass validation and indicate a successful save
  • when i refresh the page, it appears to not have saved.

 

so the workaround as you mentioned, is to define that field to 800.

 

 

In the code above, im not sure why it has this line: 

$this->def['fields']['description_short']['size'] = $limit + $size_with_html - $size_without_html;

 

For a 100 char summary that is 150 total char long, this would set the size = 800 + 150 - 100 = 850. Is this to redefine the limit for this particular summary based on the amount of markup? 

Link to comment
Share on other sites

I understand now, thank you.

 

I suspect then that there is some disconnect between the validation code you have posted above and the actual saving of the data. I tried to review further into ObjectModel.php for the validateField function, but didn't find anything that sticks out to me. (lines 984-1078 of /classes/ObjectModel.php)

Link to comment
Share on other sites

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...