News:

Support the VirtueMart project and become a member

Main Menu

Show all products on same category on product-detail-page

Started by mac99, July 06, 2013, 08:54:59 AM

Previous topic - Next topic

mac99

Hi,
I search for a module/extension/code to show all products of the same category on the product-detail-page.
I've done on a previous version of VM with this code, but it doesn't work with the new version of VM.

Thanks.


<div style="width: 720px; padding: 0 0 10px 0;  text-align: right;">
<?php   // find all the other products in this category
$q "SELECT p.product_id, p.product_name, p.product_sku, p.product_thumb_image, c.category_name, c.category_flypage
            FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
            WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '
$category_id' AND p.product_id != '$product_id'
            ORDER BY p.product_name "
;

$db = new ps_DB;
$db->query$q );

if( $db->next_record() )  {
   
//echo 'Other products in the category "'.$db->f('category_name').'"<br />';
   
$flypage $db->f('category_flypage');
   
$db->reset();
   
while( $db->next_record() ) {
?>


<!-- start products related item list cell template - HovenVision 2010 -->
<div style="width:180px; float: right;" >
<a href="<?php  $sess->purl(URL "index.php?page=shop.product_details&flypage=$flypage&product_id=" $db->f("product_id") . "&category_id=$category_id?>">
<img width="170" border="=&quot;0&quot;/" src="/components/com_virtuemart/shop_image/product/<?php $db->p("product_thumb_image"); ?>"/>
</a>

<div align="right" style="font-size: 10px; font-family: Helvetica;text-transform:uppercase">
<?php $db->p("product_name"); ?><br/><span style="text-transform: none">No. <?php $db->p("product_sku"); ?></span>
</div>

<?php echo $product_reviews ?><br>
<?php echo $related_products ?>
<?php if( $this->get_cfg('showVendorLink')) { ?>
        <div style="text-align: center;"><?php echo $vendor_link ?><br /></div><br />
<?php  ?>
<?php 
if( !empty( $recent_products )) { ?>

    <div class="vmRecent">
    <?php echo $recent_products?>
    </div>
<?php 
}
if( !empty( $navigation_childlist )) { ?>

    <?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES'?><br />
    <?php echo $navigation_childlist ?><br style="clear:both"/>
<?php 
?>

</div>
<!-- end products related item list cell template - HovenVision 2010 -->

<?php
    }
}
?>

</div>
<div style="clear:both"></div>


Maxim Pishnyak

Quote from: mac99 on July 06, 2013, 08:54:59 AM
Hi,
I search for a module/extension/code to show all products of the same category on the product-detail-page.
Hmm.. I see somewhere on this forum solution for your problem, BUT can't remember where.

Could you use search forum button youself?
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

spk063

Hello @mac99 , can u explain me where did you use  "ps_DB"    , if I run this code i get an error Fatal error: Class 'ps_DB' not found
I am too doing the same task with Virtuemart 2.0.22a . where you declared    Class 'ps_DB '??

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




Maxim Pishnyak

@ spk063:
Quote from: mac99 on July 06, 2013, 08:54:59 AM
I've done on a previous version of VM with this code, but it doesn't work with the new version of VM.
Previous version is VM 1, not VM2. Spk063, did you try forum search?
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

Eukereku

I'm also lokking for a solution to that.

I can make random products of the same category appear with the virtuemart products module but with that solution the module appears on every page (product, categories and category)...

I would like it to only appear on the product detail page...


spk063

i have used this query.. u may update this code for Virtuemart 2.02a.  I'm not good at joomla framework so i just used simple PHP code. this works good
the Code is
$tb_prefix=new JConfig();
echo $tb_prefix->dbprefix
$query="SELECT pc.virtuemart_category_id, pc.virtuemart_product_id, pm.virtuemart_product_id, pm.virtuemart_media_id, vm.virtuemart_media_id,vm.file_url,pn.product_name, pn.virtuemart_product_id
FROM
".$tb_prefix."virtuemart_products_en_gb pn,
".$tb_prefix."virtuemart_product_categories pc,
".$tb_prefix."virtuemart_product_medias pm,
".$tb_prefix."virtuemart_medias vm
WHERE pc.virtuemart_category_id='$category_id' AND pc.virtuemart_product_id=pm.virtuemart_product_id AND pm.virtuemart_media_id=vm.virtuemart_media_id AND pn.virtuemart_product_id=pc.virtuemart_product_id";
$query420=mysql_query($query);
   while($fetch=mysql_fetch_array($query420))
{
   echo "<div class='product_name'>".$fetch['product_name'];
   echo "<img src='/ecomm/".$fetch['file_url']."' class='select_free_img'/>";
   echo "<input type='hidden' name='virtuemart_product_id[]' value=".$fetch['virtuemart_product_id']."/>";
   echo "</span>";
   echo "</div>";
}   
      ?>


where $tb_prefix is the table Prefix.. get the Table prefix with joomla varaible