News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Retrieve fields from #_virtuemart_medias

Started by maxi1973, November 23, 2014, 18:21:27 PM

Previous topic - Next topic

maxi1973

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)

GJC Web Design

you don't need to write queries - look at other VM files to see how media is returned by functions
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

maxi1973

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.

GJC Web Design

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);
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

maxi1973

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

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation