batch update using CF/CC

zaratustra27 29 Mar, 2011
I want to make a bulk update at existing prices in virtuemart, the criteria to make the update is by selecting all the products with the same price and replacing all of them by a new one, so I created a simple form that gathers old price and new price both (form backup attached). Then, I connected it to a CC connection that is linked to the desired table (jos_vm_product_price) and set the connection this way:

'precio_viejo' is old price and 'precio_nuevo' is new price.

SQL WHERE:
WHERE `product_price` = <?php echo $_POST['precio_viejo']; ?>

POST VARIABLES: precio_viejo, precio_nuevo
CONNECTION VIEW SETTINGS->VIEW->BODY:
<?php

$data = array();
$data['product_price_id'] = $MyRow->product_price_id;
$data['product_price'] = $_POST['precio_nuevo'];
print_r(array_values($data));/*TEST LINE TO DISPLAY THE GENERATED ARRAY, IT DISPLAYS NOTHING*/
$record =& JTable::getInstance("vm_product_price", "Table");
if ( !$record->save($data) ) {
JError::raiseWarning(100, $record->getError());
}

if (!class_exists('Tablevm_product_price')) {
class Tablevm_product_price extends JTable {
var $product_price_id = null;
var $product_id = null;
var $product_price = null;
var $product_currency = null;
var $product_price_vdate = null;
var $product_price_edate = null;
var $cdate = null;
var $mdate = null;
var $shopper_group_id = null;
var $price_quantity_start = null;
var $price_quantity_end = null;
function __construct( &$database ) {
parent::__construct( '#_vm_product_price', 'product_price_id', $database );
}
}
}
?>

FRONT END SETTINGS->FRONT END GROUP PERMISSIONS:
View/New Record/Editors: Managers and above
ADMIN SETTINGS->DATA VIEW FIELD NAMES:
product_price_id
product_price

But once the prices are submitted it doesn't change anything, what's wrong?

Thanks in advance,
GreyHead 29 Mar, 2011
Hi zaratustra27,

I don't think this is a ChronoChronnectivity application. CC is a data viewer, it's not intended to update tables in any way like this.

If instead you move this code to the OnSubmit After Email in your form you can execute the table update.

(NB I haven't looked at the code in detail.)

Bob
zaratustra27 29 Mar, 2011
Thanks, I deleted the connection and moved the code to the onSubmitAfetrEmail field but it didn't work.

I attached the saved form with the last changes.

Thanks again for your help,
This topic is locked and no more replies can be posted.