Post by samdz » Mon Dec 18, 2023 6:14 am

Hi,
I am having to try to make small modification using event system.

I have made for admin and catalog folder, it's working, but when I have tried to make modification on files under extentions folder, it not working.
I have tried to use startup system, but no result, I want to edit Customer Orders Report.

I do this for the file in :
extension/customerid/admin/controller/startup/customer_id.php

Code: Select all

namespace Opencart\Admin\Controller\Extension\CustomerID\Startup;
class CustomerID extends \Opencart\System\Engine\Controller {

	public function index(): void {
		$this->event->register('extension/opencart/report/customer_order_list/before', new \Opencart\System\Engine\Action('extension/customerid/startup/customer_id.event'));
	}

	public function event(string &$route, array &$args, mixed &$output): void {

		$html = '<td class="text-start">Customer ID</td>';
		$find = '<td class="text-start">{{ column_customer }}</td>';
		$output = str_replace($find, $html . $find, $output);

		$html = '<td class="text-start">{{ customer.customer_id }}</td>';
		$find = '<td class="text-start">{{ customer.customer }}</td>';
		$output = str_replace($find, $html . $find, $output);
	
	}

}
and for this file :
extension/customerid/admin/controller/module/customer_id.php

Code: Select all

	public function install(): void {

			$startup_data = [
				'code'        => 'customer_id',
				'description' => 'Customer ID Column',
				'action'      => 'admin/extension/customerid/startup/customer_id',
				'status'      => 1,
				'sort_order'  => 0
			];

			$this->load->model('setting/startup');
			$this->model_setting_startup->addStartup($startup_data);
	}

	public function uninstall(): void {
			$this->load->model('setting/startup');
			$this->model_setting_startup->deleteStartupByCode('theme_example');
	}
Please, any help or idea for the mods to works to get the Customer ID column in opencart report (Customer Orders Report)

Thanks

Active Member

Posts

Joined
Fri Jan 28, 2011 3:02 am

Post by straightlight » Fri Dec 22, 2023 10:18 pm

samdz wrote:
Mon Dec 18, 2023 6:14 am
Hi,
I am having to try to make small modification using event system.

I have made for admin and catalog folder, it's working, but when I have tried to make modification on files under extentions folder, it not working.
I have tried to use startup system, but no result, I want to edit Customer Orders Report.

I do this for the file in :
extension/customerid/admin/controller/startup/customer_id.php

Code: Select all

namespace Opencart\Admin\Controller\Extension\CustomerID\Startup;
class CustomerID extends \Opencart\System\Engine\Controller {

	public function index(): void {
		$this->event->register('extension/opencart/report/customer_order_list/before', new \Opencart\System\Engine\Action('extension/customerid/startup/customer_id.event'));
	}

	public function event(string &$route, array &$args, mixed &$output): void {

		$html = '<td class="text-start">Customer ID</td>';
		$find = '<td class="text-start">{{ column_customer }}</td>';
		$output = str_replace($find, $html . $find, $output);

		$html = '<td class="text-start">{{ customer.customer_id }}</td>';
		$find = '<td class="text-start">{{ customer.customer }}</td>';
		$output = str_replace($find, $html . $find, $output);
	
	}

}
and for this file :
extension/customerid/admin/controller/module/customer_id.php

Code: Select all

	public function install(): void {

			$startup_data = [
				'code'        => 'customer_id',
				'description' => 'Customer ID Column',
				'action'      => 'admin/extension/customerid/startup/customer_id',
				'status'      => 1,
				'sort_order'  => 0
			];

			$this->load->model('setting/startup');
			$this->model_setting_startup->addStartup($startup_data);
	}

	public function uninstall(): void {
			$this->load->model('setting/startup');
			$this->model_setting_startup->deleteStartupByCode('theme_example');
	}
Please, any help or idea for the mods to works to get the Customer ID column in opencart report (Customer Orders Report)

Thanks
It doesn't need to be done from the startup folder to achieve this. An event could be used directly from the report page whereas the customer_id is being pulled. It can also be pulled from the orders and going back to the customers report page but that would be lease suggested as even less from the startup since you seem to be looking to propagate the customer ID through the entire admin-end by doing that in the meantime since I don't see a specific route location in your code above but only the $route being passed in the method's parameter.

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 samdz » Tue Jan 09, 2024 2:33 am

straightlight wrote:
Fri Dec 22, 2023 10:18 pm
samdz wrote:
Mon Dec 18, 2023 6:14 am
Hi,
I am having to try to make small modification using event system.

I have made for admin and catalog folder, it's working, but when I have tried to make modification on files under extentions folder, it not working.
I have tried to use startup system, but no result, I want to edit Customer Orders Report.

I do this for the file in :
extension/customerid/admin/controller/startup/customer_id.php

Code: Select all

namespace Opencart\Admin\Controller\Extension\CustomerID\Startup;
class CustomerID extends \Opencart\System\Engine\Controller {

	public function index(): void {
		$this->event->register('extension/opencart/report/customer_order_list/before', new \Opencart\System\Engine\Action('extension/customerid/startup/customer_id.event'));
	}

	public function event(string &$route, array &$args, mixed &$output): void {

		$html = '<td class="text-start">Customer ID</td>';
		$find = '<td class="text-start">{{ column_customer }}</td>';
		$output = str_replace($find, $html . $find, $output);

		$html = '<td class="text-start">{{ customer.customer_id }}</td>';
		$find = '<td class="text-start">{{ customer.customer }}</td>';
		$output = str_replace($find, $html . $find, $output);
	
	}

}
and for this file :
extension/customerid/admin/controller/module/customer_id.php

Code: Select all

	public function install(): void {

			$startup_data = [
				'code'        => 'customer_id',
				'description' => 'Customer ID Column',
				'action'      => 'admin/extension/customerid/startup/customer_id',
				'status'      => 1,
				'sort_order'  => 0
			];

			$this->load->model('setting/startup');
			$this->model_setting_startup->addStartup($startup_data);
	}

	public function uninstall(): void {
			$this->load->model('setting/startup');
			$this->model_setting_startup->deleteStartupByCode('theme_example');
	}
Please, any help or idea for the mods to works to get the Customer ID column in opencart report (Customer Orders Report)

Thanks
It doesn't need to be done from the startup folder to achieve this. An event could be used directly from the report page whereas the customer_id is being pulled. It can also be pulled from the orders and going back to the customers report page but that would be lease suggested as even less from the startup since you seem to be looking to propagate the customer ID through the entire admin-end by doing that in the meantime since I don't see a specific route location in your code above but only the $route being passed in the method's parameter.
thank you for your reply,
But I have used the code in this topic : viewtopic.php?t=221533#p807608
I think the problem in getTemplateBuffer function.
when I used the modification without that getTemplateBuffer function I got the result, but I want to use that function, it's better way but not working for me.
Please, I have you idea to be working on the opncart extention folder (extention/opencart) ?

Active Member

Posts

Joined
Fri Jan 28, 2011 3:02 am
Who is online

Users browsing this forum: No registered users and 3 guests