Post by trujve » Mon Nov 27, 2023 10:00 pm

Hello folks,

i am programming an extension for OC4 and i am trying to change the product title in thumb.twig by trigger.
What i have so far is:


admin/controller/module

Code: Select all

'trigger' => 'catalog/view/product/thumb/after',


view/template/module

Code: Select all

public function somefunction(string &$route, array &$data, mixed &$output): void {	
$output = str_replace('</a></h4>',  '</a><br/><b>Product ID: {{ product_id }}</h4>',  $output);
}
}

But something does not fit here, because in the thumb.twig (Product Category Page) i did not see the product_id. It only shows "{{ product_id }}" as plain text.

Can you please help me how to get the product_id here?

Best,
Jack

New member

Posts

Joined
Tue Jul 09, 2019 7:25 pm

Post by khnaz35 » Mon Nov 27, 2023 10:46 pm

Hello Jack,

The issue here is likely due to the way the product ID is being passed to the thumb.twig template. In OpenCart, data is passed to the template files (.twig files) through the controller, not directly within the view files.

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by trujve » Mon Nov 27, 2023 11:28 pm

khnaz35 wrote:
Mon Nov 27, 2023 10:46 pm
The issue here is likely due to the way the product ID is being passed to the thumb.twig template. In OpenCart, data is passed to the template files (.twig files) through the controller, not directly within the view files.
Ah, thank you very much khnaz35. That makes sense then! As I'm still at the very beginning of my extension skills, what would be the next best steps?

New member

Posts

Joined
Tue Jul 09, 2019 7:25 pm
Who is online

Users browsing this forum: No registered users and 3 guests