*

Cephas

  • ***
  • 54 posts
Random ordering of business profiles
« on: October 24, 2022, 02:54:01 AM »
Hello,

The business profiles on my home page show the latest business profile first. How can I order them randomly?

*

MB Themes

Re: Random ordering of business profiles
« Reply #1 on: October 24, 2022, 02:58:36 PM »
Go to model/ModelBPR.php and search for "public function getSellers"

You have different order methods here, like:
Code: [Select]
$this->dao->orderby('uv.i_items DESC');
$this->dao->orderby('b.pk_i_id DESC');
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ivan Kataev

  • ***
  • 54 posts
Re: Random ordering of business profiles
« Reply #2 on: October 26, 2022, 10:57:31 AM »

What needs to be changed here?
Quote

// GET ALL SELLERS
public function getSellers($enabled = -1, $verified = -1, $type = -1, $limit = array(), $pattern = '', $city = '', $category = '', $order = 'RANDOM', $ids = array()) {
  $this->dao->select('b.*');
  $this->dao->from($this->getTable_bp() . ' as b');

  if($enabled <> -1) {
    $this->dao->where('b.b_enabled', $enabled);
  }

  if($verified <> -1) {
    $this->dao->where('b.b_verified', $verified);
  }

  if($type <> -1) {
    $this->dao->where('b.i_type', $type);
  }

  if($order == 'RANDOM' && is_array($ids) && !empty($ids)) {
    $ids = implode(',', $ids);
    $this->dao->where('b.pk_i_id in (' . $ids . ')');
  }

  if($order == 'NEW') {
    $this->dao->orderby('b.pk_i_id DESC');
  }

  if($order == 'ITEMS') {
    $this->dao->join($this->getTable_user() . ' as uv', '(b.fk_i_user_id = uv.pk_i_id)', 'INNER');
    $this->dao->orderby('uv.i_items DESC');
  }

 

*

MB Themes

Re: Random ordering of business profiles
« Reply #3 on: October 26, 2022, 11:06:53 AM »
Change
Code: [Select]
    $this->dao->orderby('b.pk_i_id DESC');

To whatever you need.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ivan Kataev

  • ***
  • 54 posts
Re: Random ordering of business profiles
« Reply #4 on: October 26, 2022, 11:39:38 AM »
Strange, the changes are not showing up.

*

Hugo

  • ****
  • 182 posts
Re: Random ordering of business profiles
« Reply #5 on: October 26, 2022, 01:54:48 PM »
Have you cleared the cache and CDN?

*

Ivan Kataev

  • ***
  • 54 posts
Re: Random ordering of business profiles
« Reply #6 on: October 27, 2022, 01:07:17 PM »
Have you cleared the cache and CDN?
Yes.

*

Brandso

  • ****
  • 108 posts
Re: Random ordering of business profiles
« Reply #7 on: October 27, 2022, 07:10:38 PM »
Strange, the changes are not showing up.


Thanks for asking this question and Thanks to MB Themes for showing the path.
Even I was thinking this for a while but forgot to ask this question here.
So, if you are using Epsilon theme you can try the following as I am not sure if it works with any other themes.


Replace this code
Code: [Select]
    $this->dao->orderby('b.pk_i_id DESC');


With this code
Code: [Select]
    $this->dao->orderby('rand()','b.pk_i_id');

*

Ivan Kataev

  • ***
  • 54 posts
Re: Random ordering of business profiles
« Reply #8 on: October 28, 2022, 06:37:38 AM »
Strange, the changes are not showing up.


Thanks for asking this question and Thanks to MB Themes for showing the path.
Even I was thinking this for a while but forgot to ask this question here.
So, if you are using Epsilon theme you can try the following as I am not sure if it works with any other themes.


Replace this code
Code: [Select]
    $this->dao->orderby('b.pk_i_id DESC');


With this code
Code: [Select]
    $this->dao->orderby('rand()','b.pk_i_id');

This also works in Delta. But only in the widget on the main page. On the company page sorting from old to new.

*

MB Themes

Re: Random ordering of business profiles
« Reply #9 on: October 28, 2022, 01:40:32 PM »
One function in model holds multiple scenarios of plugin.
There are multiple orderby functions based on type
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Brandso

  • ****
  • 108 posts
Re: Random ordering of business profiles
« Reply #10 on: October 28, 2022, 07:36:11 PM »
Strange, the changes are not showing up.


Thanks for asking this question and Thanks to MB Themes for showing the path.
Even I was thinking this for a while but forgot to ask this question here.
So, if you are using Epsilon theme you can try the following as I am not sure if it works with any other themes.


Replace this code
Code: [Select]
    $this->dao->orderby('b.pk_i_id DESC');


With this code
Code: [Select]
    $this->dao->orderby('rand()','b.pk_i_id');

This also works in Delta. But only in the widget on the main page. On the company page sorting from old to new.

Hi,
What I did is just created a new function

Just Below

Code: [Select]
if($order == 'NEW') {
    $this->dao->orderby('rand()','b.pk_i_id');
  }

I created

Code: [Select]
if($order == '') {
    $this->dao->orderby('rand()','b.pk_i_id');
  }

In the above code I just removed NEW and kept 'Apostrophe'

It worked for me. But its good that the developers of this plugin confirm if its correct because I am not sure if this will affect the plugins functionality anyhow.

*

MB Themes

Re: Random ordering of business profiles
« Reply #11 on: October 30, 2022, 11:46:12 AM »
It looks good.
It only can affect ordering in front/backoffice.
You can always see current ordering by reviewing SQL queries
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ivan Kataev

  • ***
  • 54 posts
Re: Random ordering of business profiles
« Reply #12 on: October 31, 2022, 10:35:28 AM »
Strange, the changes are not showing up.


Thanks for asking this question and Thanks to MB Themes for showing the path.
Even I was thinking this for a while but forgot to ask this question here.
So, if you are using Epsilon theme you can try the following as I am not sure if it works with any other themes.


Replace this code
Code: [Select]
    $this->dao->orderby('b.pk_i_id DESC');


With this code
Code: [Select]
    $this->dao->orderby('rand()','b.pk_i_id');

This also works in Delta. But only in the widget on the main page. On the company page sorting from old to new.

Hi,
What I did is just created a new function

Just Below

Code: [Select]
if($order == 'NEW') {
    $this->dao->orderby('rand()','b.pk_i_id');
  }

I created

Code: [Select]
if($order == '') {
    $this->dao->orderby('rand()','b.pk_i_id');
  }

In the above code I just removed NEW and kept 'Apostrophe'

It worked for me. But its good that the developers of this plugin confirm if its correct because I am not sure if this will affect the plugins functionality anyhow.

Thanks! This is what you need!

*

Hugo

  • ****
  • 182 posts
Re: Random ordering of business profiles
« Reply #13 on: April 17, 2023, 06:08:59 PM »
Hi,

I would also like to change the order (randomize) of the companies on the "/companies" page.

However i can't find the file where you made the above mentioned changes in the code.

Could someone inform me in which file this needs to be changed?

*

MB Themes

Re: Random ordering of business profiles
« Reply #14 on: April 17, 2023, 07:06:53 PM »
Its model/ModelBPR.php, there is general function for profiles search
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots