VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: faiqnaseem on November 30, 2012, 08:58:39 AM

Title: How to display the products of current category in product details page
Post by: faiqnaseem on November 30, 2012, 08:58:39 AM
How to display the products of current category in product details page.

My below code is displaying the products list of current category in category but cant show the same in product details page

<div id="cate_menu">
<span style="margin-left:30px;"><font size="3" color="#8F5700"><B>Products</B></font></span>
<?php
   // Category and Columns Counter
   $iBrowseCol = 1;
   $iBrowseProduct = 1;

   // Calculating Products Per Row
   $BrowseProducts_per_row = $this->perRow;
   $Browsecellwidth = ' width' . floor (100 / $BrowseProducts_per_row);

   // Separator
   $verticalseparator = " vertical-separator";

   // Count products ?? why not just count ($this->products)  ?? note by Max Milbers
   $BrowseTotalProducts = 0;
   foreach ($this->products as $product) {
      $BrowseTotalProducts++;
   }

   // Start the Output
   foreach ($this->products as $product) {

      // Show the horizontal seperator
      if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) {
         ?>
   <div class="horizontal-separator"></div>
         <?php
      }

      // this is an indicator wether a row needs to be opened or not
      if ($iBrowseCol == 1) {
         ?>
   <div class="row2">
   <?php
      }

      // Show the vertical seperator
      if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
         $show_vertical_separator = ' ';
      } else {
         $show_vertical_separator = $verticalseparator;
      }

      // Show Products
      ?>


<ul>
<li><?php echo JHTML::link ($product->link, $product->product_name); ?></li>
</ul>


</div>
<?php
}

?>
Title: Re: How to display the products of current category in product details page
Post by: bytelord on November 30, 2012, 17:34:51 PM
Hello,

I think you should try to bring the category model ... but need some work to get done.

$categoryModel= VmModel::getModel('category'); //Load the category model
$category = $categoryModel->getCategory($this->virtuemart_category_id);   //Load products in that category


Also you should bring the product model to list products the given category... like

$products = $productModel->getProductsInCategory($this->virtuemart_category_id);

This is some hits to bring the model on the view (based on MVC) ... then you should work a little bit to correct them ... this are loaded prior to your code.

Regards

Nikos

Title: Re: How to display the products of current category in product details page
Post by: faiqnaseem on November 30, 2012, 20:50:36 PM
Can you pls elaborate more,
Title: Re: How to display the products of current category in product details page
Post by: bytelord on November 30, 2012, 21:39:06 PM
Hello,

Nope sorry, i have to work some time on that and i am little bit pressure those days. You can try the job sections if you need a custom solution.

Regards
Title: Re: How to display the products of current category in product details page
Post by: encreplus on January 10, 2013, 17:02:50 PM
Where you abble to do it correctly ??