Hi there,
I have a suggestion regarding the "RANDOM" sorting logic for the Business Profile Plugin.
The Problem: Currently, when the $order parameter is set to 'RANDOM', the plugin successfully picks random IDs via the getIds() function. However, when these IDs are passed to getSellers() to fetch the full profiles, the SQL query does not specify a display order.
As a result, MySQL typically returns the results sorted by their Primary Key (pk_i_id) in ascending order. This creates a "Static Random" effect where the user with the lowest ID (e.g., ID: 4) always appears at the very beginning of the list whenever they are selected. This gives an unfair visibility advantage to older accounts with smaller ID numbers and makes the widget look static on mobile devices.
The Solution: To achieve a truly dynamic and fair experience, we should shuffle the results in PHP after they are fetched from the database but before they are rendered.
Suggested Code Change: In oc-content/plugins/business_profile/form/block.php, we can update the logic as follows:
Current Code:
PHP
$sellers = ModelBPR::newInstance()->getSellers(1, -1, -1, $limit, '', '', '', $order, $ids);Recommended Update:
PHP
$sellers = ModelBPR::newInstance()->getSellers(1, -1, -1, $limit, '', '', '', $order, $ids);
// Ensure the display order is also randomized to avoid ID-based sorting bias
if($order == 'RANDOM' && is_array($sellers)) {
shuffle($sellers);
}Why this matters:
- Fairness: Every selected company gets an equal chance to be in the first position, regardless of their ID.
User Engagement: The website feels more alive and dynamic as the first item changes on every refresh.
Mobile Optimization: Since mobile users usually only see the first 1-2 items at a glance, true randomization ensures a fresh experience every time.
I hope you consider adding this small but impactful change to the next update!
Best regards,