i have a module that shows categories of virtuemart products in front page. I dont want the products that are not in stock available to be shown.

there is a function in the module code to select the products:

public static function _CountProduct($catids, $params)
    if ($catids == '*') {
        $_catids = $params->get('catid');
        $catids = self::_getChildCategories($_catids, $params);
        $catids = self::_getPublishCategories($catids);
    if (empty($catids)) return;

    $limitation = 999;
    $source_group = null;
    $ordering_direction = $params->get('product_ordering_direction');
    $source_order = $params->get('source_order', 'group.featured');
    $p_special = $params->get('show_front');
    $categoryModel = VmModel::getModel('Category');
    $categoryModel->_noLimit = true;

    $list = array();
    if (!empty($catids)) {
        $productModel = VmModel::getModel('Product');
        $productModel = new VirtuemartModelProductExtend();
        $productModel->filter_order = $source_order;
        $productModel->specail_product = $p_special;
        $productModel->ordering_direction = $ordering_direction;
        $desc_maxlength = $params->get('item_des_maxlength');
        $items = $productModel->getProductListing($source_group, $limitation, true, true, false, true, $catids);
        $ratingModel = VmModel::getModel('ratings');
        foreach ($items as $item) {
            $item->title = $item->product_name;
            $item->id = $item->virtuemart_product_id;
            $item->description = $item->product_desc;
            self::getVmImages($item, $params);
            $item->short_desc = self::_cleanText($item->product_s_desc);
            $item->_description = self::_cleanText($item->description);
            $item->_description = ($item->_description != '') ? self::truncate($item->_description, $desc_maxlength) : self::truncate($item->short_desc, $desc_maxlength);
            $item->vote = $ratingModel->getVoteByProduct($item->virtuemart_product_id);
            $item->rating = $ratingModel->getRatingByProduct($item->virtuemart_product_id);
            $list[] = $item;

    return count($list);

how should i change this function to do so? I'm using the last version of joomla and virtuemart.

any help would be appreciated. thanks

  • What cart component are you using? Virtuemart? Hikashop? What is the module - is a part of the cart component or a stand alone module? – Dtorr1981 Jul 25 '17 at 1:49
  • I'm using virtuemart – kiasaty Jul 31 '17 at 14:58

This is a standard Vm function - if you select Configuration > Shopfront on the right hand side there are options available for when products are out of stock...Change this to 'Do not display product'.

Hide products when out of stock

Apologies for the delayed response, I have been away.

Regards Donna

| improve this answer | |
  • but i want them to display. i dont want them to display only in this module. so i think i have to edit the code part above – kiasaty Aug 5 '17 at 14:51
  • You still haven't advised what module you are using - Virtuemart is the component? – Dtorr1981 Aug 7 '17 at 10:54
  • component: virtuemart, module: sj ajax tabs for vm – kiasaty Aug 11 '17 at 13:49

In your module, as you have $productModel you can check $productModel->orderable. Now where ever your products in module are rendered make a check like -

if ($productModel->orderable == false) {
    //Do not render product
} else {
    //Render product
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.