News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

not to list products that are not in stock

Started by kiasati, July 23, 2017, 17:31:50 PM

Previous topic - Next topic

kiasati

Hi

i have a module that shows categories of 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);
$productModel->addImages($items);
$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?

any help would be appreciated.
thanks

technext2k

I think there should an API function to get stock but if none is there, you can directly get product_in_stock field from products table.

kiasati

Quote from: technext2k on August 01, 2017, 23:03:33 PM
I think there should an API function to get stock but if none is there, you can directly get product_in_stock field from products table.
i didnt get it. :/

ANY HELP EVERYBODY??!

jjk

Did you try 'Action when a Product is Out of Stock' > 'Do not Display Product' in 'VM configuration' > 'Shopfront' tab?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

kiasati

#4
Quote from: jjk on August 05, 2017, 18:44:12 PM
Did you try 'Action when a Product is Out of Stock' > 'Do not Display Product' in 'VM configuration' > 'Shopfront' tab?
I do want to display the products that are out of stock. but i don't want them to display only in a specific module.
so i have to edit this part of code in the module