Extension developing , $productMode->getErrors to see if it's not ok?

Started by ereallstaff, November 16, 2012, 12:38:05 PM

Previous topic - Next topic

ereallstaff

Hello I need to know if there is a unique way for all virtuemart function to detect if the process ( f.e. saving correctly a product translation ) have gone right or not.

In the core I see always this:

$errors = $productModel->getErrors();
               if(!empty($errors)){
                  foreach($errors as $error){
                                                               echo 'Product with id '.$data['virtuemart_product_id'].' Creation failed in following point: '.$i.' ' . $error;
                  }
                  vmdebug('Product add error',$product);
                  $productModel->resetErrors();
                  $continue = false;

But also when process goes not well the getErrors is blank!

May I know why ? Or if somewhere there is something useful to do ?

Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ì
Try out our new joomla background rotator ( for joomla 1.x or 2.x), for only 14,99 eur @ innovailweb.it

Milbo

There are two opposite patterns.
One pattern is to setErrors in the object and get them from the object. The problem with this is that php is not completly OOP like java. Especially if you have a problem, the whole process dies and you see nothing, so we changed the pattern a year ago, using directly the joomla message system. You can enable directly echoing of vmdebug with VmConfig::$echoDebug=true;
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/