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

Related Products -

Started by gbarkerdesign, September 29, 2013, 18:42:27 PM

Previous topic - Next topic

gbarkerdesign

Joomla - 2.5.14
VM - 2.0.22c

I'm using the following code in:
template > html > com_virtuemart > productdetails > default_relatedproducts.php

It's working great but it's taking the image of the main product and using it for the related products.


<?php

// Check to ensure this file is included in Joomla!
defined '_JEXEC' ) or die ( 'Restricted access' );
$model = new VirtueMartModelProduct();
$calculator calculationHelper::getInstance();
$currency CurrencyDisplay::getInstance();
?>


<div class="product-related-products">
    <h3><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?> <?php echo $this->product->category_name?></h3>
    <p>Check out some of these other products from Us</p>
    <div class="product-field clearfix">
        <?php
        
foreach ($this->product->customfieldsRelatedProducts as $field) {
            
?>


            <div class="related-product-item">

                <?php
                $product 
$model->getProductSingle($field->custom_value,true);
                
?>


                <a title="<?php echo $product->product_name ?> - <?php echo $product->product_s_desc?>" href="<?php echo $product->link?>">
                    <?php
                    
echo $this->product->images[0]->displayMediaThumb('class="browseProductImage"'false);
                    
?>

                </a>

                <h2><a title="Find out more about <?php echo $product->product_name ?> - <?php echo $product->product_s_desc?>" href="<?php echo $product->link?>"><?php echo $product->product_name ?><span class="related-product-desc"><?php echo $product->product_s_desc?></span></a></h2>

            </div>


        <?php ?>
    </div>
</div>

Maxim Pishnyak

You could compare your code and original code for related. What is the difference?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

gbarkerdesign

The original code is pretty basic and doesnt give you any control over layout of the related items. The code I posted was something I found ages ago online and it works apart from this element.

The original code is this:


<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @subpackage
 * @author Max Milbers, Valerie Isaksen

 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default_relatedproducts.php 6431 2012-09-12 12:31:31Z alatak $
 */

// Check to ensure this file is included in Joomla!
defined '_JEXEC' ) or die ( 'Restricted access' );
?>

<div class="product-related-products">
    <h3><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?> <?php echo $this->product->category_name?></h3>
    <p>Check out some of these other products from Eden Clay</p>
    <div class="product-field clearfix">

        <?php
        
foreach ($this->product->customfieldsRelatedProducts as $field) {
            if(!empty(
$field->display)) {
                
?>


                <span class="related-product-item"><?php echo $field->display ?></span>

            <?php }
        } 
?>

    </div>
</div>

Maxim Pishnyak

Quote from: gbarkerdesign on September 30, 2013, 09:02:52 AM
The original code is pretty basic and doesnt give you any control over layout of the related items.
So it couldn't display proper image then?
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart