Author Topic: how to sort product without price last  (Read 3021 times)

marvays

  • Jr. Member
  • **
  • Posts: 446
    • richta.cz
  • Skype Name: marvays
how to sort product without price last
« on: June 29, 2020, 08:57:27 am »
Hi all my friends.
I need to solve one problem. How to sort a product without price last? The customer has a sorting of products from the cheapest. I understand that VM will first display products without a specified price (because the price is 0). But can I set an exception so that products without a price are always the last? These are usually very expensive and complex products, where the price cannot be set in advance and must be calculated additionally according to the complex configuration of the product.

Thx

Ghost

  • Jr. Member
  • **
  • Posts: 422
Re: how to sort product without price last
« Reply #1 on: June 29, 2020, 10:14:49 am »
I don't know if such option exists. I had to resort to using a core hack in administrator/components/com_virtuemart/models/product.php.

Changed this:

Code: [Select]
case 'product_price':
$orderBy = ' ORDER BY `product_price` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;

to:

Code: [Select]
case 'product_price':
$orderBy = ' ORDER BY `product_price` IS NULL ASC, `product_price` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;

marvays

  • Jr. Member
  • **
  • Posts: 446
    • richta.cz
  • Skype Name: marvays
Re: how to sort product without price last
« Reply #2 on: July 09, 2020, 09:55:22 am »
Hi. Two days its work fine. Now dont work :( File is without changes. Maybe any in administration VM?

On czech website not workong: https://vybaveniprovozu.cz/reznicke-vybaveni/udirny
On slovak website are good: https://vybavenieprevadzky.sk/maesiarske-vybavenie/udiarne

marvays

  • Jr. Member
  • **
  • Posts: 446
    • richta.cz
  • Skype Name: marvays
Re: how to sort product without price last
« Reply #3 on: July 09, 2020, 11:12:54 am »
It's a very interesting bug. When I reopened the goods without the price and then saved them, it started to sort correctly at the bottom of the page.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1603
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: how to sort product without price last
« Reply #4 on: July 09, 2020, 11:53:36 am »
Martine,

problem is not: How to sort a product without price last?

but why developer created eshop, where is showing product without price on FE?

Do you see this option on alza.cz?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

marvays

  • Jr. Member
  • **
  • Posts: 446
    • richta.cz
  • Skype Name: marvays
Re: how to sort product without price last
« Reply #5 on: January 11, 2022, 17:51:36 pm »
I don't know if such option exists. I had to resort to using a core hack in administrator/components/com_virtuemart/models/product.php.

Changed this:

Code: [Select]
case 'product_price':
$orderBy = ' ORDER BY `product_price` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;

to:

Code: [Select]
case 'product_price':
$orderBy = ' ORDER BY `product_price` IS NULL ASC, `product_price` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;

Price isnt NULL but 0.

work this:
Code: [Select]
$orderBy = ' ORDER BY coalesce(`product_price`, 0) = 0 ASC, `product_price` '.$filterOrderDir.', p.`virtuemart_product_id` '.$filterOrderDir;

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1603
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: how to sort product without price last
« Reply #6 on: January 11, 2022, 20:23:45 pm »
Payment gate Gopay not function with product's price == 0.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products