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.
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.
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
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.
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.
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.For example I want to add more lines of code to product.twig. And str_replace is not very practical then.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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
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
Who is online
Users browsing this forum: No registered users and 18 guests