Hi guys
why is this method returning different response if i am currently viewing the category or not?
i've modified the mod_virtuemart_category/all.php to show products in a "tree manner" as a sidebar.
But when i click on a category sometimes some of the products inside it are no longer being displayed?
See here: https://imgur.com/a/wt6RF
The image on the right is when you click the category STORFORMAT - thats why its marked with red.
Code looks as follow right now:
<?php // no direct access
defined('_JEXEC') or die('Restricted access');
//JHTML::stylesheet ( 'menucss.css', 'modules/mod_virtuemart_category/css/', false );
$productModel = VmModel::getModel('Product');
?>
<ul class="sidebar-menu<?php echo $class_sfx ?>" >
<?php foreach ($categories as $category) {
$active_menu = '';
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$nemprint_products = $productModel->getProductsInCategory ($category->virtuemart_category_id);
$cattext = $category->category_name;
//if ($active_category_id == $category->virtuemart_category_id) $active_menu = 'class="active"';
if (in_array( $category->virtuemart_category_id, $parentCategories)) $active_menu = 'active';
?>
<li class="<?php echo $active_menu ?>">
<div>
<?php echo JHTML::link($caturl, $cattext); ?>
</div>
<?php if (!empty($category->childs)) { ?>
<ul class="sidebar-menu<?php echo $class_sfx; ?>">
<?php
foreach ($category->childs as $child) {
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id);
$cattext = vmText::_($child->category_name);
?>
<li>
<div ><?php echo JHTML::link($caturl, $cattext); ?></div>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php
if(count($nemprint_products) > 0){
// print $category->virtuemart_category_id;
print '<ul class="sidebar-menu'.$class_sfx.'">';
// get products inside the category and display
foreach($nemprint_products as $nemprint_product){
print "<li>".$nemprint_product->product_name."</li>";
}
print '</ul>';
}
// print_r($nemprint_products);
?>
<?php
} ?>
</ul>
I have found the issue to be that i had to change a setting in the backend that seems to be a global setting. Configuration -> Templates (tab) -> Shopfront Settings (section) -> Show products of the selected category (the actual setting)