News:

Support the VirtueMart project and become a member

Main Menu

add short description to related products

Started by kobiavr, June 07, 2012, 19:20:28 PM

Previous topic - Next topic

kobiavr

i need help
i want to add short description to related products

all i know is that i need to add some code to this file
default_relatedproducts.php

thank you
kobi

kobiavr

i found it
this is the code
<?php echo $this->product->product_s_desc ?>

PRO

NO,

you will get the short description of the PRODUCT url you are on, not the related one

kobiavr

You're right
Now I noticed that is the same description to all
:(

lamvt

joomquery - Make website like loving Kids: http://joomquery.com

srajca

couldn't you use $product->product_s_desc ?

zerolds

on default_related_products.php

i have to make something like that soo i will share the code with you

and here comes the code

<?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">
       <h4><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>

    <?php
   
    foreach ($this->product->customfieldsRelatedProducts as $field) {
       
       if(!empty($field->display)) {
   ?><div class="relatproduct">
            <?php
                   
                                                               $idproducto = $field->custom_value;
                                                                   $db = JFactory::getDbo();
                                                               $query = $db->getQuery(true);
                                                               $query->select($db->quoteName('product_s_desc'));
                                                               $query->from($db->quoteName('#__virtuemart_products_es_es'));
                                                               $query->where($db->quoteName('virtuemart_product_id') . '=' . $idproducto . '');
                                                               $db->setQuery($query);
                                                               $descripcioncorta = $db->loadResult();
                                                               
                                                                     $db = JFactory::getDbo();
                                                               $query = $db->getQuery(true);
                                                               $query->select($db->quoteName('virtuemart_media_id'));
                                                               $query->from($db->quoteName('#__virtuemart_product_medias'));
                                                               $query->where($db->quoteName('virtuemart_product_id') . '=' . $idproducto . '');
                                                               $db->setQuery($query);
                                                               $idmedia = $db->loadResult();
                                                               
                                                               
                                                                          $db = JFactory::getDbo();
                                                               $query = $db->getQuery(true);
                                                               $query->select($db->quoteName('file_url'));
                                                               $query->from($db->quoteName('#__virtuemart_medias'));
                                                               $query->where($db->quoteName('virtuemart_media_id') . '=' . $idmedia . '');
                                                               $db->setQuery($query);
                                                               $urlimagen = $db->loadResult();
                                                               
                                                                                             $db = JFactory::getDbo();
                                                               $query = $db->getQuery(true);
                                                               $query->select($db->quoteName('virtuemart_category_id'));
                                                               $query->from($db->quoteName('#__virtuemart_product_categories'));
                                                               $query->where($db->quoteName('virtuemart_product_id') . '=' . $idproducto . '');
                                                               $db->setQuery($query);
                                                               $catid = $db->loadResult();
                                                                   $produrl=JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $idproducto. '&virtuemart_category_id=' . $catid , FALSE);
                                                                $query = $db->getQuery(true);
                                                               $query->select($db->quoteName('product_name'));
                                                               $query->from($db->quoteName('#__virtuemart_products_es_es'));
                                                               $query->where($db->quoteName('virtuemart_product_id') . '=' . $idproducto . '');
                                                               $db->setQuery($query);
                                                               $nombreprod = $db->loadResult();
                                                               
                                                               echo '<div class="imgrelapro"><a href="'.$produrl.'"><img src="'.$urlimagen.'" /></a></div>';
                                                             
                                                         
                                                               
                                                               
                                                               echo '<div clas="nombpro"><span>'.$nombreprod.'</span></div>';
                                                               
                                                               
                                                           
                                               
                                                               echo '<div class="shordesp">';
           
                                                                  echo substr($descripcioncorta, 0, 140);
                                                                                         if (strlen($descripcioncorta) > 140){
                                                                                             echo "...";
                                                                                         }
                                                                                           echo '</div>';
                                                                                           
                                                                         echo '<div class="seeprod"><a href="'.$produrl.'"><span>'.JText::_('COM_VIRTUEMART_SEE_PRODUCTO').'</span></a></div>';               
                                                                                           
                                                         
                                                               
                        ?>
           
         
                   
      </div>
   <?php }
       } ?>
        </div>