This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

pitbull

  • ***
  • 98 posts
[SOLVED] How can i get the number of business profiles?
« on: March 06, 2019, 10:36:00 AM »
Hi Frosticek. Is there any way/function to get the total number of users that have upgraded their profile to business just for stats reason? Something similar to this helper :
Code: [Select]
<?php echo osc_total_users(); ?>
I use the code above to display the total number of registered users. How can i do the same only for users that have business profiles?

Thanx mate.
« Last Edit: March 19, 2019, 03:15:31 PM by pitbull »

*

MB Themes

Re: How can i get the number of business profiles?
« Reply #1 on: March 06, 2019, 10:42:38 AM »
@pitbull
Best way is to create new count funtion in plugin model and use this one.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pitbull

  • ***
  • 98 posts
Re: How can i get the number of business profiles?
« Reply #2 on: March 19, 2019, 02:17:57 PM »
@pitbull
Best way is to create new count funtion in plugin model and use this one.

@Frosticek i tried something like that but didnt work:

Code: [Select]
function count_number_bpr($bprofiles) {

            $this->dao->select("COUNT(*) as i_total");
            $this->dao->from(DB_TABLE_PREFIX.'t_user_business_profile');
            $this->dao->where($sbpofiles);

            $result = $this->dao->get();

            if( $result == false || $result->numRows() == 0) {
                return 0;
            }

            $row = $result->row();
            return $row['i_total'];
        }

Could you point me to the right direction ?
Thanx mate

*

pitbull

  • ***
  • 98 posts
Re: How can i get the number of business profiles?
« Reply #3 on: March 19, 2019, 02:33:10 PM »
::UPDATE --

inside plugin model there is a function for counting sellers already:

Code: [Select]
public function countSellers($enabled = -1) {
  $this->dao->select('count(*) as i_count');
  $this->dao->from($this->getTable_bp());

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

  $result = $this->dao->get();
 
  if($result) {
    $data = $result->row();
    return $data['i_count'];
  }

  return 0;
}


but when i try to echo that function in front end like that :

Code: [Select]
<?php echo countSellers(); ?>
i m getting the error:

Code: [Select]
PHP Fatal error:  Uncaught Error: Call to undefined function countSellers()  ???

i cant understand why as the function is already defined in plugin's Model file.

*

pitbull

  • ***
  • 98 posts
Re: How can i get the number of business profiles?
« Reply #4 on: March 19, 2019, 03:14:10 PM »
OK Frosticek finally
Code: [Select]
ModelBPR::newInstance() did the job done. So mark this as solved as well ;)

Marked as best answer by frosticek on March 19, 2019, 03:19:11 PM
*

MB Themes

Re: [SOLVED] How can i get the number of business profiles?
« Reply #5 on: March 19, 2019, 03:18:38 PM »
@pibull
Nice journey :)

Code: [Select]
<?php echo ModelBPR::newInstance()->countSellers(); ?>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots