VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: maxi1973 on November 23, 2014, 18:21:27 PM

Title: Retrieve fields from #_virtuemart_medias
Post by: maxi1973 on November 23, 2014, 18:21:27 PM
Hello, i'm trying to edit the mail_html_question.php file and i need to insert product image/thumbnail . I figure that all fields in that file are from virtuemar_product_media table, but i need to retrieve image related to products... but those informations are in virtuemart_medias table of database.
How can i retrieve join tables to obtain file_url or file_url_thumb from table?
thanks a lot in advance and sorry for my english
Joomla 2.5.27 and VM 2.0.22d (at the moment i can't update)
Title: Re: Retrieve fields from #_virtuemart_medias
Post by: GJC Web Design on November 23, 2014, 23:18:13 PM
you don't need to write queries - look at other VM files to see how media is returned by functions
Title: Re: Retrieve fields from #_virtuemart_medias
Post by: maxi1973 on November 24, 2014, 09:35:36 AM
Thanks GJC, i've looked inside form.php and the code to call the thumb is this:<?php // Product Image
echo $this->product->images[0]->displayMediaThumb('class="product-image"',false); ?>

but if i add this in mail_html_question.php i have this error: Fatal error: Call to a member function displayMediaThumb() on a non-object in /web/htdocs/www..../mail_html_question.php on line 70 . If i remove all after dispalyMedia Thumb i have no image at all in email.
I've tryed also solution posted here: http://forum.virtuemart.net/index.php?topic=115630.msg389622#msg389622
but whithout results,also changing file_url_thumb with file_url... in email i have a broken link (clicking on broken image i have only website root (http://www.orientalpets.it), but not image.
Hope you or other users may help me in this trouble. Thanks a lot.
Title: Re: Retrieve fields from #_virtuemart_medias
Post by: GJC Web Design on November 24, 2014, 10:45:20 AM
you need to check what is available in that file - i.e product model etc

if not call it perhaps so - u need to experiment a bit

$productModel = VmModel::getModel('Product');

$productModel->addImages($this->product);
Title: Re: Retrieve fields from #_virtuemart_medias
Post by: maxi1973 on November 24, 2014, 14:08:39 PM
Sorry GJC, but i don't understand... i have to insert the code you posted in mail_html_question.php? so in that case i have to replace
<a href="<?php  echo $product_link ?>"><img src="<?php echo JURI::root() . $this->product->images[0]->file_url;   ?>" />
</a>

with:
$productModel = VmModel::getModel('Product');
$productModel->addImages($this->product);
<a href="<?php  echo $product_link ?>"><img src="<?php echo JURI::root() . $productModel->addImages($this->product); ?>" />
</a>
?
Please, i'm not an addict to programming, so be patient. thanks
Title: Re: Retrieve fields from #_virtuemart_medias
Post by: GJC Web Design on November 24, 2014, 21:58:52 PM
I really don't know - I haven't ever worked on that file - that is for u to do - look at other vm files to see how its done

the fatal error means the $this->product->images isn't there - you need to get it into your file by probably importing the model and running addImages()
But you have to experiment - might be enough just to run addImages()

then it may be $this->product->images[0]->file_url