Author Topic: override VM module function (sortSearchListQuery from modules/product.php)  (Read 760 times)

caesarsk

  • Jr. Member
  • **
  • Posts: 50
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9176
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

caesarsk

  • Jr. Member
  • **
  • Posts: 50
ou, nice. thx you very much

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4042
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Or you can do your own function, eg if you need to get ordered product by user or cart products ...