VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Marttyn on July 30, 2013, 21:17:07 PM

Title: Change Product description length (or other fields)
Post by: Marttyn on July 30, 2013, 21:17:07 PM
Ive been al day trying to solve this, and i found the answer!
I will explain so maybe its useful to someone.

I have some lengthy descriptions for my products. And when saving, the text is cut, because it exceed the maximum length for "product_desc" field in the database.
By default my VM 2.0.22a has a 18400 char max length. And i wanted to increase a little.
If i go to my DB and look for the virtuemart_product_en_gb (or the language you installed) table, you can see that "product_desc" field is 18400. And if you try to modify you will get an error. This error is because any ROW of a table can be longer than 65535 bytes. Each character with UTF8 encoding use up to 3 bytes, all the columns of a single row should be no more than 65535 bytes, so the 18400 char default is chosen to fit this limit.
To increase the size of a field, you should decrese the size of other field to be always bellow the limit. So you can shorten your "product_s_desc" from 2000 to 500, and now you can increase "product_desc" to 19900.

BUT you cant do that in the DB, because VM is smarter than you and will change it back again to the default values. So you will have to go to administrator/components/com_virtuemart/helpers/tableupdater.php and find this lines and modify with the values you want.
$fields['product_s_desc'] = 'varchar('.VmConfig::get('dbpsdescsize',2000).') '.$linedefault;
$fields['product_desc'] = 'varchar('.VmConfig::get('dbpdescsize',18400).') '.$linedefault;


for example to this:
$fields['product_s_desc'] = 'varchar('.VmConfig::get('dbpsdescsize',400).') '.$linedefault;
$fields['product_desc'] = 'varchar('.VmConfig::get('dbpdescsize',20000).') '.$linedefault;


With this mod, now you will have to go to your VM config page, and click "Apply". With this the tables will update to the new size!!

Other option, that does not involve changing PHP files would be to declare 'dbpsdescsize' and 'dbpdescsize' and assign  your value to them. I read that should be declared on virtuemart.cfg but i cant make it work  :(

I hope this is useful to someone, as i spent 1 day to figure it out  ;D
Title: Re: Change Product description length (or other fields)
Post by: serge-web54 on October 21, 2015, 16:24:25 PM
i changed this line  :
$fields['product_desc'] = 'varchar('.VmConfig::get('dbpdescsize',18400).') '.$linedefault;

into

$fields['product_desc'] = 'longtext '.$linedefault;

when you have a long text it seems better.
Title: Re: Change Product description length (or other fields)
Post by: sandomatyas on March 20, 2017, 15:52:20 PM
Is there any way to set text or longtext to product_desc field officially?
There is code in tableupdater.php
if(VmConfig::get('dblayoutstrict',true)){
if($table=='products'){
$fields['product_s_desc'] = 'varchar('.VmConfig::get('dbpsdescsize',2000).') '.$linedefault;
$fields['product_desc'] = 'varchar('.VmConfig::get('dbpdescsize',18400).') '.$linedefault;

But it'll be always varchar. What if I need some longer content?
Title: Re: Change Product description length (or other fields)
Post by: Milbo on March 21, 2017, 19:56:58 PM
dblayoutstrict=0 in the virtuemart.cfg does not help?

https://docs.virtuemart.net/manual/general-concepts/206-hidden-configurations.html
Title: Re: Change Product description length (or other fields)
Post by: jflash on October 10, 2018, 09:12:12 AM
I tried set dblayoutstrict=0 but still 18412 characters saved in description...
Joomla 3.8.12 and VM 3.2.14