override VM module function (sortSearchListQuery from modules/product.php)

Started by caesarsk, October 21, 2018, 12:15:48 PM

Previous topic - Next topic

caesarsk

Hi all,

can be override VM core module function by my own (for example by vmcustom or system plugin)? I dont want to modify core file after each update.
I need modify function "sortSearchListQuery" from file "/administrator/com_virtuemart/modules/product.php" (add some own product sorting items).

thx for advice

GJC Web Design

you can add your own myproducts.php in the models folder and extend so

class VirtueMartModelMyproduct extends VirtueMartModelProduct {

      public function getProductListing ($group = FALSE, $nbrReturnProducts = FALSE, $withCalc = TRUE, $onlyPublished = TRUE, $single = FALSE, $filterCategory = TRUE, $category_id = 0, $filterManufacturer = TRUE, $manufacturer_id = 0) {
//blah blah

     $ids = $this->sortSearchListQuery ($onlyPublished, $this->virtuemart_category_id, $group, $nbrReturnProducts);
    return ids;

}

   function sortSearchListQuery ($onlyPublished = TRUE, $virtuemart_category_id = FALSE, $group = FALSE, $nbrReturnProducts = FALSE, $instock = 0) {

/* my code*/

    return $product_ids;


}
}

and call it by

$myproductModel = VmModel::getModel('Myproduct');

$products = $myproductModel->getProductListing(false,$pnumber, true, true, true, false, $catids, false, 0, $instock);

you get the idea

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation


Studio 42

Or you can do your own function, eg if you need to get ordered product by user or cart products ...