That's almost working.
(a) I needed to set the value of DO to false, but only on the toggle. My code now looks like this:
function onBeforeProductupdate(&$product, &$do) {
if (!myProductHelper::productValidation($product)) {
$product->product_published = 0;
if (JRequest::getVar('ctrl') == 'toggle') {
$do = false;
}
}
}
(b) The next problem is that the toggle only provides a partial set of
product data in the object not the full set provided when the product form is saved. Can the call to
save be changed to something like this?
$obj = new hikashopProductClass; // Need to cater for the other classes as well.
$obj->getProducts($elementPkey);
$obj->$task = $value;
$class->save($obj);