VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: dslove on June 06, 2017, 11:09:28 AM

Title: "Rebel products" when sorting by price
Post by: dslove on June 06, 2017, 11:09:28 AM
Hi all,
I have this issue bugging me and I really cannot figure out the root of the problem. In VM config I have set product order to be by price, ascending (lowest -> highest). The sorting seems to work fine, apart from 1-2 "rebel" products in each category that don't seem to agree with the order settings.

Setup is Joomla 3.7.2 with VM 3.2.2, and PHP 7 with MySQL 5.6

Any ideas?
Title: Re: "Rebel products" when sorting by price
Post by: Ghost on June 06, 2017, 11:40:47 AM
Do you have any discounts applied?
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 06, 2017, 13:08:41 PM
No, no discounts are applied.

Also, all products have two prices, retail and wholesale.
Title: Re: "Rebel products" when sorting by price
Post by: Milbo on June 06, 2017, 13:20:23 PM
Dslove, the ordering takes the values stored in the db. But the price you see is dynamically calculated on your shoppergroup settings and so on.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 06, 2017, 13:25:52 PM
Milbo thanks for the reply, what is your suggestion on the issue?
Title: Re: "Rebel products" when sorting by price
Post by: jjk on June 06, 2017, 16:06:51 PM
If you enable 'Sort by price' in VM configuration, VM sorts the cost price, because that is the only price stored in the database. All other prices are calculated. So if you want to sort by 'Final sales price', VM would need an additional temporary price table in the database. But that would not solve all possible price sorting possibilities, because there might be different taxes, discounts, shopper groups, child products, etc.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 06, 2017, 16:46:00 PM
Hi jjk, thanks for the info.

There is only one active tax (24%), there are only simple products (no parents/children), there are no discounts. All products are available to same shopper groups, there is only a wholesale price for the Wholesale shopper group (this is on every product).

Here is a typical product ordering (retail prices/available to all):

As you can see, there is no logic in the sorting above  :(
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 07, 2017, 23:03:19 PM
It is the same in the back end too. Ideas, anyone?
Title: Re: "Rebel products" when sorting by price
Post by: jjk on June 08, 2017, 21:59:40 PM
Note that products should be sorted by the price which is stored in the database table. Looking through my product lists in the backend, I can see 'sorting issues' similar to yours, but I couldn't figure out yet why this happens.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 09, 2017, 16:42:11 PM

These are all "retail prices", available to all shoppers. As I mentioned in an earlier post, all my products have a retail price and a wholesale price, available only to shoppers from a specific group ("wholesale shoppers"). JJK, does this also apply to your installation?
Title: Re: "Rebel products" when sorting by price
Post by: jjk on June 09, 2017, 21:54:28 PM
Quote from: dslove on June 09, 2017, 16:42:11 PM
JJK, does this also apply to your installation?

No. I enter the actual cost price and let VM calculate the final sales price. Everything else doesn't make sense when you buy products from suppliers in different countries.
However, it makes no difference for the sorting issue, because VM sorts whatever is entered into the cost price field, which is stored in the database.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 10, 2017, 06:43:54 AM
I have a separate set of wholesale prices for wholesale buyers because there is no standard way of calculating this according to cost price. Products different profit margins (e.g. anywhere between 10% and 30%).
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 10, 2017, 06:44:45 AM
So, we conclude that this is an unexplained, unfixable VM bug?
Title: Re: "Rebel products" when sorting by price
Post by: jjk on June 10, 2017, 09:21:45 AM
I'm sure it can be fixed. But we need to wait until a developer has been able to reproduce it and has identified the source of the problem.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 10, 2017, 17:06:38 PM
Quote from: jjk on June 10, 2017, 09:21:45 AM
I'm sure it can be fixed. But we need to wait until a developer has been able to reproduce it and has identified the source of the problem.

I'm willing to contribute to the solution of this issue by providing DB backups or whatever information is required.
It's a little embarrassing to explain the issue to the client, I hope it can be fixed soon...  :-[
Title: Re: "Rebel products" when sorting by price
Post by: Milbo on June 13, 2017, 00:28:28 AM
Which db do you use? which mysql or mariadb version? You can also uncomment one line in the product model to see the used sql, when you use the vmdebug and use it directly on the db. Maybe you see then the problem.
Title: Re: "Rebel products" when sorting by price
Post by: dslove on June 13, 2017, 08:03:14 AM
Hi Milbo, please let me know which line to uncomment & where.

Setup is as following:

DB type => mysqli
Database Version => 5.6.35
Database Collation => utf8_general_ci
Database Connection Collation => utf8mb4_general_ci
PHP Version => 7.0.19
Web Server => Apache
Joomla Version => 3.7.2
Virtuemart Version => 3.2.2
Title: Re: "Rebel products" when sorting by price
Post by: Milbo on June 13, 2017, 09:19:37 AM
Please install this version http://dev.virtuemart.net/attachments/download/1081/com_virtuemart.3.2.3.9577.zip

and then open the product model in /administrator/components/com_virtuemart/models and uncomment the line 259, $this->setDebugSql(1);

Then enable the vmdebug and you should see the sql. Then post the sql here and we can discuss it.