News:

Support the VirtueMart project and become a member

Main Menu

Modify Generic child variant dropdown to images

Started by rayge, January 02, 2014, 21:15:25 PM

Previous topic - Next topic

rayge

I need to convert the Generic child variant drop down to instead display their related product images.

does this make sense or do i need to clarify the question?

THANKS FOR ANY HELP!!
I Use: Joomla 3.4.1 & VM 3.0.9

rayge

#1
OK so after getting no help I decided to code it myself AS usual LOL

This code goes in default_addtocart.php as a template override.
It is expected that you only have one Generic child variant.

//START - ADDED BY RLH TO DISPLAY IMAGE INSTEAD OF DROPDOWN.
$productModel = VmModel::getModel ('product');
$productModel->setId($this->product->virtuemart_product_id);
$uncatChildren = $productModel->getUncategorizedChildren ($customfield->withParent);
$mediaModel = VmModel::getModel ('Media');
if(count($uncatChildren)>0) {
foreach ($uncatChildren as $child) {
$M_link = JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id'],FALSE);

//getFiles() SAYS is meant only for backend use but i couldnt find any other function.
$M_images = $mediaModel->getFiles(true, false, $child['virtuemart_product_id']);
$M_thumb = $M_images[0]->file_url_thumb;
$M_full = $M_images[0]->file_url;

if($M_thumb!='') {
$M_image = $M_thumb;
} elseif($M_full!='') {
$M_image = $M_full;
} else {
//Pull default image here
}
$f_img[] = '<a href="'.$M_link.'" title="'.htmlentities($child['product_name']).'"><img src="'.$M_image.'" style="height:60px;"></a>';
}

//handle html display here
foreach($f_img as $imgval){
echo $imgval;
}
}
//END - ADDED BY RLH TO DISPLAY IMAGE INSTEAD OF DROPDOWN.
I Use: Joomla 3.4.1 & VM 3.0.9

communion

Hey man, this is really brilliant, and works great, but for some reason is only displaying the images on the Parent item. Is there a way you know of for these images to also show on the child products as well, so the user can switch between them?

Thanks in advance

gregdevice

Was this code ever adjusted so the thumbnails show on the child products? Would be great. Should be built-in. Thanks

prehn

Quote from: communion on September 10, 2014, 03:19:20 AM
Hey man, this is really brilliant, and works great, but for some reason is only displaying the images on the Parent item. Is there a way you know of for these images to also show on the child products as well, so the user can switch between them?

Thanks in advance

Hi there, excuse the bump, but just want to know if you fixed so that the images were shown in the child product swell as the parent. I having the exact same problem were it shows up on the parent product but not the child product.

mickey3k

Hi,

sorry for bumping this thread up, but I searched for hours on end to find a solution to this problem and wanted to leave my findings here for others with the same problem. Don't know why it is not built in. It is very inconvenient if the customer does not see the child variant product image, especially if you have like a T-Shirt with 20 different colors and you only see the text "green", "red", "blue" and so on.

I wanted to leave the solution I found here. It is a small plugin that does exactly what you need and works perfectly. The guy behind it is also doing a great job on customizing. I needed to make the parent product "not orderable", which was not built in, so he included it in one day for free. Props to him.

The plugin: http://shop.st42.fr/en/products/product-child-variants.htm