Jump to content

How to bypass the meta title limit in product page


texxo

Recommended Posts

Hello,

i have added manually in the database in meta title of prodiuct the name of the product (that is being done automatically if the field is empty) but i wanted also to have a standard additional text after it (this is why i did it manually and directly in the database with a query).

All went ok.

The only problem though is:

Because the meta title is bigger than the character limit inside the back office, when i try to update something in the product description and save it, although it shows the green message Settings Saved, in fact nothing is saved.

I double checked it by removing characters from the meta title to match the character limit and then of course it works all ok and saves the changes.

So, i have 2 questions:

How can i make prestashop 1.7.2.4 to bypass the control of this character limit (i.e. to increase the limit of meta title characters to 200) so i dont face this issue.

or

How can i make prestashop 1.7.2.4 to add automatically what i want it to add at the end of the automatically generated (or not automatically generated) meta title.

I know that more characters are not useful, but in my case i want to have specific message appearing also in the meta title of the product in addition to the product title.

If someone knows in which file to look for it, i will surely find it (in either cases).

Thank you for any help provided.

Link to comment
Share on other sites

Product meta_title characters limit is controller by it's classes Product.php, size = 128
it's also set as  `Length/Values` of database table ps_product_lang column meta_title

If you want to have more than 128 characters, you have to modify/override Product class, set the size value more than 128
also don't forget to change the  related DB table columns as mentioned above

However it's not recommended, and I suggest you to create custom module which able to add extra text after meta_title where the module should have it's own database table to store the necessary/related data.

Link to comment
Share on other sites

Hello, thank you for the answer.

The database i already modified to accomodate 255 chars.

I know it is not recomended but i dont plan to upgrade presta for the following period at all.

(since it works now, better to leave it working - i have made many customizations to my files but i always keep the original copy just in case)

So, i should look in the Product.php file to find where is set the 128 chars limit, right?

Any further help like which line it is around, or any other thing that i should have in mind?

It would be perfect (for the second part of your answer) for me to know where the meta title is being processed and just go and add there the phrase i want (its a standard phrase e.g. the name of the shop and some more words that i want to be always after the meta title that is generated automatically (or taken from the saved meta title from the product info)

Thank you.

Link to comment
Share on other sites

  • 2 weeks later...

for info:

i have found and changed this in line 335 of product,php in classes folder.

            'meta_title' =>                array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),

changed to:

            'meta_title' =>                array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),

 

now it works ok and i can edit normally the product and all is saved.

it would be of course better if anyone knew to tell me where the actual page title is formed.
then i could just go and add the string i want manually there to appear all the time.

Link to comment
Share on other sites

  • 6 years later...

In Prestashop 8 it can be changed from src/Core/Domain/Product/ProductSettings.php

 

    /**
     * Bellow constants define maximum allowed length of product properties
     */
    public const MAX_NAME_LENGTH = 128;
    public const MAX_MPN_LENGTH = 40;
    public const MAX_META_TITLE_LENGTH = 70;
    public const MAX_META_DESCRIPTION_LENGTH = 160;

    /**
     * This is the default value for short description (a.k.a. summary) maximum length,
     * but this value is configurable,
     * it is saved in configuration named PS_PRODUCT_SHORT_DESC_LIMIT
     */
    public const MAX_DESCRIPTION_SHORT_LENGTH = 800;
    public const MAX_DESCRIPTION_LENGTH = 21844;
    public const MAX_LINK_REWRITE_LENGTH = 128;
    public const MAX_AVAILABLE_NOW_LABEL_LENGTH = 255;
    public const MAX_AVAILABLE_LATER_LABEL_LENGTH = 255;

 

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