Advertisement:

Author Topic: (SOLVED) Change Fields Information Structure (numbers only to text)  (Read 1771 times)

richieboymx

  • Full Member
  • ***
  • Posts: 110
Hello,

Fields "year, mileage, engine size and power" allow only numbers as values. How can I allow text values in those fields?

I'm trying to customize some of the fields from the car attributes plugin. I have renamed the "Power" field to "Color", however when I fill the information in this field when I publish a new listing with the value "white", nothing shows on the item detail or listing summary; instead it shows the value "0" zero when wditing the listing.

Thanks a lot!  :)
« Last Edit: August 27, 2014, 05:33:05 pm by ramutio »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Change Fields Information Structure (numbers only to text)
« Reply #1 on: August 26, 2014, 09:07:02 pm »
Hi,

I have renamed the "Power" field to "Color"

Do you mean "renamed for viewing" or did you really change i_power field name in the table t_item_car_attr? If you did the latter remember you have to change also any possible reference to i_power in the plugin scripts.

Anyway, you can do this:

Code: [Select]
ALTER TABLE /*TABLE_PREFIX*/t_item_car_attr MODIFY i_mileage VARCHAR(255);
One line per field, using real field name (i_mileage, i_year, i_engine_size...). If you keep the names like this I think you shouldn't need to change anything in the scripts.

Build the list in a text file, save as "changes.sql" and use "Tools / Import data" in Admin Dashboard to download it and make the changes to your database. (Better do first a complete backup of the DB, just in case).

Regards



richieboymx

  • Full Member
  • ***
  • Posts: 110
Re: Change Fields Information Structure (numbers only to text)
« Reply #2 on: August 27, 2014, 02:59:17 am »
Thank you teseo for your response.

Yes, I have renamed every line that had the word "power" to "color" (I already have changed "power_unit" to "interior") including i_power and pc_power.

I'm no expert but seems your fix is for a current or active installation of the plugin. Since I'm testing all the changes that I make to the plugin, I keep installing it and uninstalling it... what would be the equivalent of your fix so the changes are effective when I install the plugin?

I tried changing INT (10) to VARCHAR (40) from the struct.sql file but that did not work, as it gave me a plugin installation error.

Thanks again for your help!


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Change Fields Information Structure (numbers only to text)
« Reply #3 on: August 27, 2014, 03:12:28 am »
Well, changes in struct.sql an re-installation... Then:

CREATE TABLE /*TABLE_PREFIX*/t_item_car_attr (
    fk_i_item_id INT(10) UNSIGNED NOT NULL,
    i_year INT(4) UNSIGNED,
    i_year VARCHAR (40),
    i_doors INT(1) UNSIGNED,
    i_seats INT(4) UNSIGNED,
    i_mileage INT(10) UNSIGNED,
    i_mileage VARCHAR (40),

etc...

fk_i_item_id you need to keep it that way, the rest I think they'd be safe to change them to text fields, maybe you were trying to keep attribute UNSIGNED meant only for numbers? ???

Regards

richieboymx

  • Full Member
  • ***
  • Posts: 110
Re: Change Fields Information Structure (numbers only to text)
« Reply #4 on: August 27, 2014, 05:32:00 pm »
Yes, that was it... It works now!

I didn't knew UNSIGNED was for number only, so I neved removed that command when changing the other parameters in the "struct.sql" file.

Thanks again for your help!  ;D