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

product list ordering

Started by guardiano78, September 10, 2015, 17:35:22 PM

Previous topic - Next topic

guardiano78

Hello,
in configuration i set ordering product by stock descending.
i need to add to the query, product_price asc and product_availability asc, simultaneously.
with debug i found this query:

SELECT SQL_CALC_FOUND_ROWS  p.`virtuemart_product_id`
  FROM `jos_virtuemart_products` as p 

  LEFT JOIN `jos_virtuemart_product_shoppergroups` as ps
  ON p.`virtuemart_product_id` = `ps`.`virtuemart_product_id` 

  LEFT JOIN `jos_virtuemart_product_categories` as pc
  ON p.`virtuemart_product_id` = `pc`.`virtuemart_product_id` 

  LEFT JOIN `jos_virtuemart_categories` as c
  ON c.`virtuemart_category_id` = `pc`.`virtuemart_category_id`

  WHERE ( `pc`.`virtuemart_category_id` = 152
  AND  `c`.`published` = 1 
  AND  ( `ps`.`virtuemart_shoppergroup_id`= "108"  OR `ps`.`virtuemart_shoppergroup_id` IS NULL  ) 
  AND  p.`published`="1" )

  group by p.`virtuemart_product_id`

  ORDER BY `p`.product_in_stock  DESC
  LIMIT 0, 10

i hope that this is the right query that i have to modify.
in which file i can do this? and how?

thanks.

Studio 42

Yes, but not, if you change this directly in the model, this is applied in all product lists.(random, featured ...)

guardiano78

I understand. I would try anyway.
how can I do?

Milbo

product.php in models folder function sortSearchListQuery

There are switches, you can add it there. You can also write a plugin, to modify the query.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

guardiano78

#4
This function works for all sorts or just research?

I can not understand what is the line to be changed

thanks.

GJC Web Design

imho for ALL product by cat displays, searches etc
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

guardiano78

I can not understand what is the line to be changed... sorry

GJC Web Design

search for the comment 
// special  orders case

in the product.php file
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

guardiano78

please... can you tell me the line specific that i need to modify?

Studio 42

Quote from: guardiano78 on September 15, 2015, 10:38:45 AM
please... can you tell me the line specific that i need to modify?
admin/components/virtuemart/models/product.php

Milbo

Patrick, I told him already, the file and the function.

Quote from: Milbo on September 13, 2015, 22:09:16 PM
product.php in models folder function sortSearchListQuery

There are switches, you can add it there. You can also write a plugin, to modify the query.

guardiano78, There is no line to modify, you must change some more lines of the function, but as I said before, instead of hacking the core, you should write a plugin.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/