The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Sun Nov 15, 2009 3:42 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 17, 2006 3:41 am
Posts: 23
Hi

I got this module "Virtuemart Top Ten Products" on my site, but I would like to display the product's image on this module (the module only shows the product's name).
What piece of code should I change to display the images on the module?
Thank you for your help.

Here is the module code:
Code:
global $mosConfig_absolute_path, $sess;

/* Load the virtuemart main parse code */
require_once( $mosConfig_absolute_path.'/components/com_virtuemart/virtuemart_parser.php' );

require_once(CLASSPATH.'ps_product.php');
$ps_product = new ps_product;

// change the number of items you wanna haved listed via module parameters
$num_topsellers = $params->get ('num_topsellers', 10);

$list  = "SELECT p.product_id, p.product_sales as sales, p.product_parent_id, p.product_name, c.category_id, c.category_flypage ";
$list .= "FROM #__{vm}_product p, #__{vm}_product_category_xref pc, #__{vm}_category c WHERE ";
$q = "p.product_publish='Y' AND ";
$q .= "pc.product_id = p.product_id AND ";
$q .= "pc.category_id = c.category_id AND ";
$q .= "p.product_sales > 0 ";
$q .= "GROUP BY p.product_id ";
$q .= "ORDER BY sales DESC, p.product_name ";
$list .= $q . " LIMIT 0, $num_topsellers ";

$db = new ps_DB;
$db->query($list);

$tt_item=0;
$i = 0;
?>

<table width="101%" height="23" border="0" cellpadding="0" cellspacing="0">
<?php

  while ($db->next_record()) {
      if ($i == 0) {
          $sectioncolor = "sectiontableentry2";
          $i += 1;
      }
      else {
          $sectioncolor = "sectiontableentry1";
          $i -= 1;
      }
      if( !$db->f('category_flypage') ) {
         $flypage = ps_product::get_flypage( $db->f('product_id'));
      }
      else {
         $flypage = $db->f('category_flypage');
      }
      $tt_item++;
      $pid = $db->f("product_parent_id") ? $db->f("product_parent_id") : $db->f("product_id");

      ?>
<tr class="<?php echo $sectioncolor ?>">
  </tr>
<tr class="<?php echo $sectioncolor ?>">
  <td height="16" valign="top"><b><?php printf("%02d", $tt_item); ?></b></td>
  <td width="85%" valign="top"><a href="<?php  $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $pid . "&category_id=" . $db->f("category_id")) ?>">
    <?php $ps_product->show_snapshot($db->p("product_name")); ?>
  </a></td>
</tr>
    <?php
  } ?>
</table>


Top
 Profile  
 
PostPosted: Fri Jun 11, 2010 1:02 am 
Joomla! Intern
Joomla! Intern

Joined: Mon May 31, 2010 4:09 am
Posts: 54
Location: Maroochydore, QLD
try this code:

<img src="components/com_virtuemart/shop_image/product/<?php $db->p("product_thumb_image");?>" border="0" /><br />
<?php echo $db->p("product_name"); ?>


Top
 Profile  
 
PostPosted: Tue Jul 13, 2010 6:02 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Jul 13, 2010 5:50 pm
Posts: 2
Well it doesn't work for me, can someone confirm that please? Maybe I'm inserting that row to bad place. Thank you for any positive answer. This is what I got:

<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/*
* Best selling Products module for VirtueMart
* @version $Id: mod_virtuemart_topten.php 1160 2008-01-14 20:35:19Z soeren_nb $
* @package VirtueMart
* @subpackage modules
*
* @copyright (C) John Syben (john@webme.co.nz)
* Conversion to Mambo and the rest:
* @copyright (C) 2004-2005 Soeren Eberhardt
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.virtuemart.net
*----------------------------------------------------------------------
* This code creates a list of the bestselling products
* and displays it wherever you want
*----------------------------------------------------------------------
*/
global $mosConfig_absolute_path, $sess;

// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}

require_once(CLASSPATH.'ps_product.php');
$ps_product = new ps_product;

// change the number of items you wanna haved listed via module parameters
$num_topsellers = $params->get ('num_topsellers', 10);

$list = "SELECT p.product_id, p.product_sales as sales, p.product_parent_id, p.product_name, c.category_id, c.category_flypage ";
$list .= "FROM #__{vm}_product p, #__{vm}_product_category_xref pc, #__{vm}_category c WHERE ";
$q = "p.product_publish='Y' AND ";
$q .= "pc.product_id = p.product_id AND ";
$q .= "pc.category_id = c.category_id AND ";
$q .= "p.product_sales > 0 ";
$q .= "GROUP BY p.product_id ";
$q .= "ORDER BY sales DESC, p.product_name ";
$list .= $q . " LIMIT 0, $num_topsellers ";

$db = new ps_DB;
$db->query($list);

$tt_item=0;
$i = 0;
?>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<?php

while ($db->next_record()) {
if ($i == 0) {
$sectioncolor = "sectiontableentry2";
$i += 1;
}
else {
$sectioncolor = "sectiontableentry1";
$i -= 1;
}
if( !$db->f('category_flypage') ) {
$flypage = ps_product::get_flypage( $db->f('product_id'));
}
else {
$flypage = $db->f('category_flypage');
}
$tt_item++;
$pid = $db->f("product_parent_id") ? $db->f("product_parent_id") : $db->f("product_id");

?>
<tr class="<?php echo $sectioncolor ?>">
<td width="15%"><?php printf("%02d", $tt_item); ?></td>
<td width="85%">
<a href="<?php $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $pid . "&category_id=" . $db->f("category_id")) ?>">
<?php $db->p("product_name"); ?>
</a>
</td>
</tr>
<img src="components/com_virtuemart/shop_image/product/<?php $db->p("product_thumb_image");?>" border="0" /><br />
<?php echo $db->p("product_name"); ?>
<?php
} ?>
</table>

<!--Top 10 End-->


Top
 Profile  
 
PostPosted: Tue Jul 13, 2010 11:22 pm 
Joomla! Intern
Joomla! Intern

Joined: Mon May 31, 2010 4:09 am
Posts: 54
Location: Maroochydore, QLD
the problem is your select statement.

you have:
$list = "SELECT p.product_id, p.product_sales as sales, p.product_parent_id, p.product_name, c.category_id, c.category_flypage ";
$list .= "FROM #__{vm}_product p, #__{vm}_product_category_xref pc, #__{vm}_category c WHERE ";

it should be:

$list = "SELECT p.product_id, p.product_sales as sales, p.product_parent_id, d.product_price, d.shopper_group_id, p.product_thumb_image, p.product_name, c.category_id, c.category_flypage ";

$list .= "FROM #__{vm}_product p, #__{vm}_product_price d, #__{vm}_product_category_xref pc, #__{vm}_category c WHERE ";

see how you go with that.


Top
 Profile  
 
PostPosted: Wed Jul 14, 2010 12:07 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 17, 2006 3:41 am
Posts: 23
Yes, now it works fine. Thank you all very much!


Top
 Profile  
 
PostPosted: Wed Jul 14, 2010 6:03 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Jul 13, 2010 5:50 pm
Posts: 2
Thanks so much guys, works perfectly :) :)


Top
 Profile  
 
PostPosted: Fri Aug 06, 2010 3:11 am 
Joomla! Intern
Joomla! Intern

Joined: Fri Jan 22, 2010 4:01 pm
Posts: 75
Location: Thailand
That is the solution I'm looking for. Can someone tell me the file name and path that I can find and change the code?
It seems difficult to new user to usderstand with the previous details.
Intern user

_________________
http://www.24h-bag.com ขายกระเป๋า ออนไลน์ บทความกระเป๋า น่าอ่าน
http://www.bag24h.com ขายกระเป๋าแฟชั่น


Top
 Profile  
 
PostPosted: Mon May 16, 2011 5:19 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Thu Aug 17, 2006 9:27 am
Posts: 83
Location: United Kingdom
Thanks suncoastweb, this worked for me, wish I found it earlier!

File to change is /modules/mod_virtuemart_topten.php

_________________
http://www.starfishwebsites.com
In need of some loving... https://www.facebook.com/starfishwebsites


Top
 Profile  
 
PostPosted: Sat Jul 16, 2011 3:39 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jul 19, 2007 8:02 am
Posts: 5
Here is a quick (dirty) way to use the product snapshot:

Code:
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/*
* Best selling Products module for VirtueMart
* @version $Id: mod_virtuemart_topten.php 1160 2008-01-14 20:35:19Z soeren_nb $
* @package VirtueMart
* @subpackage modules
*
* @copyright (C) John Syben (john@webme.co.nz)
* Conversion to Mambo and the rest:
*    @copyright (C) 2004-2005 Soeren Eberhardt
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.virtuemart.net
*----------------------------------------------------------------------
* This code creates a list of the bestselling products
* and displays it wherever you want
*----------------------------------------------------------------------
*/
global $mosConfig_absolute_path, $sess;

// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
   require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
   require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}

require_once(CLASSPATH.'ps_product.php');
$ps_product = new ps_product;

// change the number of items you wanna haved listed via module parameters
$max_items = $num_topsellers = $params->get ('num_topsellers', 10);
$display_style = "horizontal";
$show_addtocart = 1;
$show_price = 1;

$db =& new ps_DB;
$q = "SELECT p.product_sku, p.product_id, p.product_sales as sales, p.product_parent_id, d.product_price, d.shopper_group_id, p.product_thumb_image, p.product_name, c.category_id, c.category_flypage ";
$q .= "FROM #__{vm}_product p, #__{vm}_product_price d, #__{vm}_product_category_xref pc, #__{vm}_category c WHERE ";
$q .= "p.product_publish='Y' AND ";
$q .= "pc.product_id = p.product_id AND ";
$q .= "pc.category_id = c.category_id AND ";
$q .= "p.product_sales > 0 ";
$q .= "GROUP BY p.product_id ";
$q .= "ORDER BY sales DESC, p.product_name ";
$q .= " LIMIT 0, $max_items ";
//echo $q;

$db->query($q);

if( $db->num_rows() > 0 ){ ?>
      <table border="0" cellpadding="0" cellspacing="0" width="100%">       
        <?php
        $i = 0;
        while($db->next_record() ){
         if ($i%2)
            $sectioncolor = "sectiontableentry2";
         else
            $sectioncolor = "sectiontableentry1";
             
         if( $display_style == "vertical" ) {
            ?>
            <tr align="center" class="<?php echo $sectioncolor ?>">
               <td><?php $ps_product->show_snapshot($db->f("product_sku"), $show_price, $show_addtocart); ?><br /></td>
            </tr>
            <?php
         }
         elseif( $display_style== "horizontal" ) {
            if( $i == 0 )
               echo "<tr>\n";
            echo "<td align=\"center\">";
            $ps_product->show_snapshot($db->f("product_sku"), $show_price, $show_addtocart);
            echo "</td>\n";
            if( ($i+1) == $max_items )
               echo "</tr>\n";
         }
         elseif( $display_style== "table" ) {
            if( $i == 0 )
               echo "<tr>\n";
            echo "<td align=\"center\">";
            $ps_product->show_snapshot($db->f("product_sku"), $show_price, $show_addtocart);
            echo "</td>\n";
            if ( ($i+1) % $products_per_row == 0)
               echo "</tr><tr>\n";
            if( ($i+1) == $max_items )
               echo "</tr>\n";
         }
         $i++;
        }
?>
</table>
<?php
}
?>


Top
 Profile  
 
PostPosted: Thu Nov 03, 2011 4:55 pm 
User avatar
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Nov 03, 2011 4:49 pm
Posts: 1
Perfect ! Thanks a lot


Top
 Profile  
 
PostPosted: Sun Dec 25, 2011 12:17 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Dec 25, 2011 12:12 pm
Posts: 1
Dear users,

After installing and building my offline website, I would like to go live, but I've this small problem with the Top Ten module.

Is there a way to clear the database so no products will be displayed at going live?

Now, after testing and making fake oders, a top 10 is displayed wich is complete nonsens.

I've cleared the database from orders and order history, but still the fake top 10 is displayed.

Anyone a solution?

Thanks a lot and Merry X-mas!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 



Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group