[英]how to display the upc in product page with opencart3?
I want to display the upc in product page with opencart 3. How do I do that? 我想用opencart 3在产品页面中显示upc。我该怎么做?
I added the below code into my template file /catalog/view/theme/default/template/product/product.twig
,but it doesn't work. 我将以下代码添加到模板文件
/catalog/view/theme/default/template/product/product.twig
,但不起作用。
{% if upc %}
{{ upc }}
{% endif %}
Please do not forget to backup these files first. 请不要忘记先备份这些文件。
You have to add upc as a variable to the controller first and then echo it in the template. 您必须先将upc作为变量添加到控制器,然后在模板中回显它。 in order to do that: first edit controller file:
为了做到这一点:首先编辑控制器文件:
/catalog/controller/product/product.php
and search for 并搜索
$data['model'] = $product_info['model'];
after that add: 之后添加:
$data['upc'] = $product_info['upc'];
and save the file. 并保存文件。
After that your code in template file that you mentioned will work. 之后,您提到的模板文件中的代码将起作用。
ps: by this approach you lose these changes if you update opencart.A better approach would be to make an ocmod extension for it. ps:通过这种方法,如果更新opencart,则会丢失这些更改。更好的方法是为其进行ocmod扩展。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.