VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Andre72 on January 28, 2013, 17:10:03 PM

Title: Where in the source are products inserted into the database?
Post by: Andre72 on January 28, 2013, 17:10:03 PM
Hi,
we get a component to add products but it does not work.
The returned error message is still empty so is useless.

For this reason I need to catch the error message when the insert to the DB does not work...
So here's the code from the component:

if (!class_exists( 'VirtueMartModelProduct' )) require (JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'product.php');
$modelProduct = new VirtueMartModelProduct;
...
$prod_id = $modelProduct->store($data);


So I think I'll find the fuction for store in administrator/components/com_virtuemart/models/product.php and in line 49381 I found:
public function store

Is this the right function I'm looking for?
I try something like
$fh=fopen('error.log','w');

There but error.log will never be created so I think I understand something wrong ...
I'm a novice with development.

I use Joomla 2.5.8 and VirtueMart 2.0.18a

Can somebody help me please to figure out why it does not work?

Thanks

Andre
Title: Re: Where in the source are products inserted into the database?
Post by: Andre72 on January 28, 2013, 17:42:44 PM
The path was right - the log file was just created in the excecuting directory ...
So I can do loging now.
Title: Re: Where in the source are products inserted into the database?
Post by: Milbo on January 29, 2013, 16:01:42 PM
This looks correct
$modelProduct = new VirtueMartModelProduct;
...
$prod_id = $modelProduct->store($data);

the $data should be an associative array. Use vmdebug and check our used data format, you may understand then whats missing (for example virtuemart_product_id = null) or so