Post by mattltm » Sat Apr 06, 2024 11:21 pm

I'm using V 3.0.4.0.

Is there a cron job that I can create to keep statistics up to date? I have to manually go into statistics and update all of them at the moment and the "Order Sales" total is always higher than the actual value until I manually update it.

Thanks.

Matt

Newbie

Posts

Joined
Mon Aug 02, 2021 4:56 am

Post by straightlight » Sun Apr 07, 2024 3:05 am

mattltm wrote:
Sat Apr 06, 2024 11:21 pm
I'm using V 3.0.4.0.

Is there a cron job that I can create to keep statistics up to date? I have to manually go into statistics and update all of them at the moment and the "Order Sales" total is always higher than the actual value until I manually update it.

Thanks.

Matt
Unless using OC v4.x releases, it requires an extension.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mattltm » Tue Apr 09, 2024 4:43 pm

Thanks for the reply. Can you suggest and extensions that are suitable?

Thanks!

Newbie

Posts

Joined
Mon Aug 02, 2021 4:56 am

Post by nonnedelectari » Tue Apr 09, 2024 5:44 pm

You could create an OCMOD where you:

add:

Code: Select all

$this->refresh_all();
in function index() just before:

Code: Select all

$this->getList();
then add a new function:

Code: Select all

	private function refresh_all () {
		if ($this->validate()) {
			$this->load->model('sale/order');
			$this->model_report_statistics->editValue('order_sale', $this->model_sale_order->getTotalSales(array('filter_order_status' => implode(',', array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status'))))));
			$this->model_report_statistics->editValue('order_processing', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $this->config->get('config_processing_status')))));
			$this->model_report_statistics->editValue('order_complete', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $this->config->get('config_complete_status')))));		
			$this->load->model('localisation/order_status');
			$order_status_data = array();
			$results = $this->model_localisation_order_status->getOrderStatuses();
			foreach ($results as $result) {
				if (!in_array($result['order_status_id'], array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status')))) {
					$order_status_data[] = $result['order_status_id'];
				}
			}		
			$this->load->model('sale/order');
			$this->model_report_statistics->editValue('order_other', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $order_status_data))));			
			$this->load->model('sale/return');
			$this->model_report_statistics->editValue('return', $this->model_sale_return->getTotalReturns(array('filter_return_status_id' => $this->config->get('config_return_status_id'))));
			$this->load->model('customer/customer');	
			$this->model_report_statistics->editValue('customer', $this->model_customer_customer->getTotalCustomers(array('filter_approved' => 0)));
			$this->model_report_statistics->editValue('affiliate', $this->model_customer_customer->getTotalAffiliates(array('filter_approved' => 0)));
			$this->load->model('catalog/product');
			$this->model_report_statistics->editValue('product', $this->model_catalog_product->getTotalProducts(array('filter_quantity' => 0)));
			$this->load->model('catalog/review');
			$this->model_report_statistics->editValue('review', $this->model_catalog_review->getTotalReviews(array('filter_status' => 0)));	
			$this->session->data['success'] = $this->language->get('text_success');
		}
	}
all in file:
admin/controller/report/statistics.php

that would do all updates whenever you visit that page prior to displaying the list..

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm
Who is online

Users browsing this forum: No registered users and 18 guests