VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: davidex2 on March 04, 2023, 23:21:29 PM

Title: Cannot create more than one custom field of the same type
Post by: davidex2 on March 04, 2023, 23:21:29 PM
HI,

I'm trying to create some custom fields. I can only create the first "string" field. If I try to create a second string field this error appears:

vmError: vmTable store insertObject #__virtuemart_customs Duplicate entry 'S-0-1' for key 'field_type_searchable_published' INSERT INTO `jos9z_virtuemart_customs` (`virtuemart_custom_id`,`custom_parent_id`,`virtuemart_vendor_id`,`admin_only`,`custom_jplugin_id`,`custom_element`,`custom_title`,`custom_tip`,`custom_value`,`custom_desc`,`custom_params`,`field_type`,`is_list`,`is_input`,`is_hidden`,`virtuemart_shoppergroup_id`,`is_cart_attribute`,`searchable`,`layout_pos`,`published`,`ordering`,`show_title`,`created_on`,`created_by`,`locked_by`) VALUES ('0','0','1','0','0','0','sefggef','','','','addEmpty=0|selectType=0|multiplyPrice=0|transform=\"\"|product_sku=\"\"|product_gtin=\"\"|product_mpn=\"\"|','S','0','0','0','','0','0','','1','0','1','2023-03-04 22:17:47','424','0')

The same problem exists also with the "Properties" and "Boolean" fields.

Joomla 4.2.8
VirtueMart 4.0.12 10777


Lo stesso problema c'è anche con i campi "Proprietà" e "Boleano"
Title: Re: Cannot create more than one custom field of the same type
Post by: pinochico on March 05, 2023, 14:45:55 PM
I think the name of post have to cannot create more then one custom field of the same name...

But you send there no info about how you create customfield :)

Where is picture?
Title: Re: Cannot create more than one custom field of the same type
Post by: davidex2 on March 06, 2023, 11:36:19 AM
Virtuemart - Custom Fields - New - String
Title: Re: Cannot create more than one custom field of the same type
Post by: balai on March 06, 2023, 12:33:11 PM
Seems like is related with the index of the table #__virtuemart_customs with the name: 'field_type_searchable_published'
I suppose that it is a unique index in your case.
Use your phpMyAdmin to go to that table's structure and either delete that index or remove it's unique attribute.

Btw. In my database and under VirtueMart 4.0.12 10777 this index is not unique
Title: Re: Cannot create more than one custom field of the same type
Post by: davidex2 on March 08, 2023, 08:31:43 AM
What exactly should I do?
Being a new installation, is it to be considered a bug of virtuemart?
Title: Re: Cannot create more than one custom field of the same type
Post by: GJC Web Design on March 08, 2023, 18:53:15 PM
the keys in the install.sql for  4.0.12 10777 are

  PRIMARY KEY (`virtuemart_custom_id`),
  KEY `field_type_searchable_published` (`field_type`, `searchable`, `published`),
  KEY `custom_parent_id` (`custom_parent_id`),
  KEY `virtuemart_vendor_id` (`virtuemart_vendor_id`),
  KEY `custom_element` (`custom_element`),
  KEY `field_type` (`field_type`),
  KEY `is_cart_attribute` (`is_cart_attribute`),
  KEY `is_input` (`is_input`),
  KEY `searchable` (`searchable`),
  KEY `shared` (`shared`),
  KEY `published` (`published`),
  KEY `ordering` (`ordering`)

So I wonder where your Unique came from?
Title: Re: Cannot create more than one custom field of the same type
Post by: balai on March 09, 2023, 12:22:05 PM
@GJC it was a core problem. See: https://forum.virtuemart.net/index.php?topic=148315.0

@davidex2 As said: Use your phpMyAdmin to go to that table's structure and either delete that index or remove it's unique attribute.
Title: Re: Cannot create more than one custom field of the same type
Post by: davidex2 on March 09, 2023, 12:33:39 PM
I took a screenshot of the table.

Do I have to modify the field_type_searchable_published line and instead of unique do I have to put index?

Thanks