VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: no_leaf on March 27, 2013, 23:44:22 PM

Title: [ SOLVED ] Posting product_id as variable
Post by: no_leaf on March 27, 2013, 23:44:22 PM
Greetings,

I'm trying to add some functionality on product images, and i can do the 99% part but i have a problem on posting product_id while saving the product.

It works in product_edit_images.php if i give a manually product id for value as ;

in tmpl/product_edit_images.php
name="productid" value="8"
and in controllers/product.php
$productid = $_POST['productid'];
this works and writes to database

I can also get the product id with;
$pro_id = $this->product->virtuemart_product_id;

But if i want to post it as $pro_id, not manually written number
It doesn't write to database.
What should i do in controllers/product.php or in another file? VM version : 2.0.18a

Thanks
Title: Re: Posting product_id as variable
Post by: chetanmadaan on March 30, 2013, 21:54:03 PM
Most Virtuemart files do get the $product arrary in them.

you can try dumping the whole array and see what key has the product id and access it through.

or you can also use JRequest/Getvar to get the product id from get/post.

http://docs.joomla.org/Retrieving_and_Filtering_GET_and_POST_requests_with_JRequest::getVar
Title: Re: Posting product_id as variable
Post by: no_leaf on April 02, 2013, 04:12:24 AM
Greetings chetanmadaan,
Thanks for your kind answer, actually it posts the id defined as variable on first page. But i don't know why it doesn't process it to write to database. I have found another solution for that without changing any core file more.
I simply do the query in a pop-up in product images tab.

Thanks for your interest