VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: saraheagle on October 01, 2015, 17:29:56 PM

Title: Update vm2 order format of customfields to vm3 format - Does not work
Post by: saraheagle on October 01, 2015, 17:29:56 PM
Hello - I am having some trouble with the upgrade from VM2 to VM3 with the custom fields as well. I tried using the "Update vm2 order format of customfields to vm3 format" button but it gives a blank page. (/administrator/index.php?option=com_virtuemart&view=updatesmigration&task=fixCustomsParams&98dcb5e2a185c7ba8cdd537d38766c22=1)

If you are not able to update VM could you just post a copy of the code needed to upgrade the custom fields? At the mo, we do not have any custom fields being populated in the admin are or the front end, without recreating every single custom field, so its vital we get some tool to do this somehow.

Thanks
Title: Re: Update vm2 order format of customfields to vm3 format - Does not work
Post by: GJC Web Design on October 02, 2015, 01:45:40 AM
It's just in the model

public function fixCustomsParams(){
$this->checkPermissionForTools();
$q = 'SELECT `virtuemart_customfield_id` FROM `#__virtuemart_product_customfields` LEFT JOIN `#__virtuemart_customs` USING (`virtuemart_custom_id`) ';
$q = 'SELECT `virtuemart_customfield_id`,`customfield_params` FROM `#__virtuemart_product_customfields` ';
$q .= ' WHERE `customfield_params`!="" ';
$db = JFactory::getDbo();
$db->setQuery($q);

$rows = $db->loadAssocList();

foreach($rows as $fields){
$store = '';
$json = @json_decode($fields['customfield_params']);

if($json){

$vars = get_object_vars($json);

foreach($vars as $key=>$value){
$store .= $key . '=' . vmJsApi::safe_json_encode($value) . '|';
}

if(!empty($store)){
$q = 'UPDATE `#__virtuemart_product_customfields` SET `customfield_params` = "'.$db->escape($store).'" WHERE `virtuemart_customfield_id` = "'.$fields['virtuemart_customfield_id'].'" ';
$db->setQuery($q);
$db->execute();

}

}

}
$msg = 'Executed';
$this->setredirect($this->redirectPath, $msg);
}


but the $q looks odd..  :(
Title: Re: Update vm2 order format of customfields to vm3 format - Does not work
Post by: saraheagle on October 16, 2015, 11:00:40 AM
I tried a few things to get what looked like the correct syntax in the database using this file, and then c&p some in the db, but even when it was I think it uses more than one table as it still did not work properly or my syntax was incorrect.

Either way, the amount of time spent on trying to fix this was taking a ridiculously in-proportionment amount of time, for something that really should be included in the software itself.

I'm going to look at using this instead. http://extensions.joomla.org/profile/extension/extension-specific/virtuemart-extensions/migrator-for-virtuemart

S :)
Title: Re: Update vm2 order format of customfields to vm3 format - Does not work
Post by: GJC Web Design on October 16, 2015, 12:34:04 PM
I admit it doesn't work for me either (forgot the error :(  ) but I changed the table in less than 10mins on a migration I did yesterday and working fine

just change the customfields table  Table: #__virtuemart_product_customfields (3 name changes and add 5 columns) to make it look like a stock VM3 customs table

this one only had strings though