Post by okibobo » Tue Aug 07, 2018 7:20 pm

Is it possible to use only the OC Event system for these overrides?

I need to override the core index function of the product controller. I want to edit the core file and add this line:

$data['quantity'] = $product_info['quantity'];
to the function index() in "class ControllerProductProduct extends Controller"

and then I need add this line in product.twig file:

<span>{{ quantity }}</span>
I want to use only the OC Event system, not ocmod or vqmod.

It is real?

Thanks for help.

Newbie

Posts

Joined
Fri Nov 23, 2012 9:56 pm

Post by straightlight » Tue Aug 07, 2018 7:43 pm

Better to use the Override Engine extension to accomplish this. While it won't override the core, it will at least merge the variables that you wish to declare into the same location. An alternative would be to create a TWIG function in order to define your own variable which this custom variable name can then be used over the same TWIG file without affecting what's been defined already from the core.

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 okibobo » Wed Aug 08, 2018 1:37 am

Thank you Straightlight for you help.

Do you know if in the future releases are planning to add events support for this kind of change? What is your opinion? Is it better to use for overrides Opencart Event system or 3rd party extension Override Engine?

One more question for the Override Engine module. How to make more complex changes of the twig file. I mean overrides in which the str_replace function is not enough. For example I want to add more lines of code to product.twig. And str_replace is not very practical then.

Newbie

Posts

Joined
Fri Nov 23, 2012 9:56 pm

Post by straightlight » Wed Aug 08, 2018 1:41 am

For example I want to add more lines of code to product.twig. And str_replace is not very practical then.
If you want to add more lines, you can either rely on the use of OCMod, VQMod or the Override Engine which each provides the ability to use the add case without the need to use the str_replace function or, as explained, to implement your own TWIG function by returning a new variable so that you can use it as a supplement into your target TWIG file.

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 okibobo » Wed Aug 08, 2018 1:52 am

Can you post here some example? Sorry, I am newbie in this override engine system.

Newbie

Posts

Joined
Fri Nov 23, 2012 9:56 pm

Post by straightlight » Wed Aug 08, 2018 1:54 am

See this post: viewtopic.php?f=24&t=85873&hilit=override+engine . In the mean time, I would highly recommend to see this post as well: viewtopic.php?f=190&t=165636

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 okibobo » Wed Aug 08, 2018 2:08 am

Ok, thanks. And what do you prefer? Override Engine or OC Event system?

Newbie

Posts

Joined
Fri Nov 23, 2012 9:56 pm

Post by straightlight » Wed Aug 08, 2018 2:18 am

Preferences are based on the required solution a programmer might need in order to avoid conflict with other extensions in the most possible ways to achieve.

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 okibobo » Wed Aug 08, 2018 2:27 am

Thanks for your time, I understand what you mean.

Newbie

Posts

Joined
Fri Nov 23, 2012 9:56 pm
Who is online

Users browsing this forum: No registered users and 18 guests