Post by aminmix » Mon May 29, 2023 8:48 pm

I stored some data in "catalog/controller/product.php" by using

Code: Select all

    $this->document->setSomeData("data");
I need to read the data in "system/library/response.php" by using

Code: Select all

    $this->document->getSomeData();
But the document class is not reachable there. what can i do?

Newbie

Posts

Joined
Sat Mar 19, 2016 7:07 pm

Post by ADD Creative » Tue May 30, 2023 5:17 am

What version of OpenCart?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by halfhope » Tue May 30, 2023 5:42 am

Hi!

You can pass $registry into response class in your system/framework.php like this:

Code: Select all

$response = new Response($registry);
In your response class add:

Code: Select all

private $registry;
public function __construct($registry){
    $this->registry = $registry;
}
use:

Code: Select all

$document = $this->registry->get('document');
$document->setSomeData("data");

My extensions in marketplace. [ security | flexibility | speedup ]


User avatar
Active Member

Posts

Joined
Tue Dec 10, 2013 9:44 pm
Location - San Diego

Post by straightlight » Tue May 30, 2023 7:51 am

OC version.

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 aminmix » Thu Jun 01, 2023 2:23 pm

halfhope wrote:
Tue May 30, 2023 5:42 am
Hi!

You can pass $registry into response class in your system/framework.php like this:

Code: Select all

$response = new Response($registry);
In your response class add:

Code: Select all

private $registry;
public function __construct($registry){
    $this->registry = $registry;
}
use:

Code: Select all

$document = $this->registry->get('document');
$document->setSomeData("data");
Thank you dude it worked for me, oC v2.0.3.1 :-*

Newbie

Posts

Joined
Sat Mar 19, 2016 7:07 pm
Who is online

Users browsing this forum: No registered users and 13 guests