I have seen this discussed for VM 2 but have tried this solution and it does not work unfortunately. The solution for VM2 is below:
Create a template override with categories.php and change the below around line 74:
echo $category->images[0]->displayMediaThumb("",false);
With
$productModel = VmModel::getModel('product');
$prod_in_category = $productModel->getProductListing(false, 1, false, true, true, true, $category->virtuemart_category_id);
$productModel->addImages($prod_in_category[0],1);
if(!empty($prod_in_category[0]->images[0])){
echo $prod_in_category[0]->images[0]->displayMediaThumb("",false);
} else {
echo $category->images[0]->displayMediaThumb("",false);
Or for a random image from the category us:
$productModel = VmModel::getModel('product');
$prod_in_category = $productModel->getProductsInCategory($category->virtuemart_category_id);
$sel = array_rand($prod_in_category);
$productModel->addImages($prod_in_category[$sel],1);
if(!empty($prod_in_category[$sel]->images[0])){
echo $prod_in_category[$sel]->images[0]->displayMediaThumb("",false);
} else {
echo $category->images[0]->displayMediaThumb("",false);
}
I have tried both of the code snippets above but i just get an empty page so am guessing something may have changed between versions. Can anyone advise? I am using Joomla 3.4.5 and Virtuemart 3.0.9.
Best Regards
Donna
hey I want this in the new version as well. I am investigating how to do it too.
Quotewanting to learn to create good templates
if you really mean it, then don't waiting answer from forum, but you must trying self.
Again, again and again.
Now I give you the best option for your learning: I don't send you instructions.
You can try self and after 14 days you send me info, what do you learn - send me result.
that signature I have not changed since a long time ago but I am a persistent fellow so I dont mind learning :D show me