The solution is just unload child product in SQL query in administrator/components/com_virtuemart/models/product.php but if you modify query string, backend will unload child product too. So i show you below:
File 1: administrator/components/com_virtuemart/models/product.php
somewhere near line 189 (function sortSearchListQuery)
change
function sortSearchListQuery ($onlyPublished = TRUE, $virtuemart_category_id = FALSE, $group = FALSE, $nbrReturnProducts = FALSE)
to
function sortSearchListQuery ($onlyPublished = TRUE, $virtuemart_category_id = FALSE, $group = FALSE, $nbrReturnProducts = FALSE, $noChildProduct = FALSE)
some where near line 486
change
if (count ($where) > 0) {
$whereString = ' WHERE (' . implode (' AND ', $where) . ') ';
}
else {
$whereString = '';
}
to
if (count ($where) > 0) {
//ngockhoavo hide child products with condition $noChildProduct
if($noChildProduct){
$whereString = ' WHERE (' . implode (' AND ', $where) . ') AND product_parent_id=0 ';
}else{
$whereString = ' WHERE (' . implode (' AND ', $where) . ') ';
}
}
else {
$whereString = '';
}
somewhere near line 1161 function getProductsInCategory
change
public function getProductsInCategory ($categoryId) {
$ids = $this->sortSearchListQuery (TRUE, $categoryId);
$this->products = $this->getProducts ($ids);
return $this->products;
}
to
public function getProductsInCategory ($categoryId,$noChildProduct = FALSE) {
//ngockhoavo custom this function to load no child product
//$ids = $this->sortSearchListQuery (TRUE, $categoryId);
$ids = $this->sortSearchListQuery (TRUE, $categoryId,null,null,$noChildProduct);
$this->products = $this->getProducts ($ids);
return $this->products;
}
file 2: components/com_virtuemart/views/category/view.html.php
somewhere near line 174
change
$products = $productModel->getProductsInCategory($categoryId);
to
$products = $productModel->getProductsInCategory($categoryId,true);
Done
If you want to show child product again you should change $products = $productModel->getProductsInCategory($categoryId,false);
again.
*Unload child product at virtuemart frontpage
File 1 administrator/components/com_virtuemart/models/product.php
somewhere near 1204
change
$ids = $this->sortSearchListQuery ($onlyPublished, $this->virtuemart_category_id, $group, $nbrReturnProducts);
to
$ids = $this->sortSearchListQuery ($onlyPublished, $this->virtuemart_category_id, $group, $nbrReturnProducts, $noChildProduct);
File 2 components/com_virtuemart/views/virtuemart/view.html.php
somewhere near line 110
change
$products['latest']= $productModel->getProductListing('latest', $latest_products_count);
to
$products['latest']= $productModel->getProductListing('latest', $latest_products_count,null,null,null,null,null,TRUE);
Thanks for read it ;D
----------------------------------------------------
ngockhoavo
84972459147
ngockhoavo@gmail.com