Update vm2 order format of customfields to vm3 format - Does not work

Started by saraheagle, October 01, 2015, 17:29:56 PM

Previous topic - Next topic

saraheagle

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

GJC Web Design

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..  :(
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

saraheagle

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 :)

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation