OpenCart 3.0.2.0 - 如何在类别上显示 SKU &产品页面 [英] OpenCart 3.0.2.0 - how to display SKU on category & product pages

查看:60
本文介绍了OpenCart 3.0.2.0 - 如何在类别上显示 SKU &产品页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 OpenCart 3.0.2.0 中,我试图获取类别 &产品页面以显示每个产品的SKU"变量.该变量与其他产品数据一起在数据库中,但由于某些不道德的原因,OpenCart 没有显示它的选项.您可以显示产品名称、价格、库存状况等,但不能显示 SKU.

In OpenCart 3.0.2.0, I'm trying to get the category & product pages to display the "SKU" variable for each product. The variable is in the database, along with other product data, but for some ungodly reason, OpenCart doesn't have an option to display it. You can display the product name, price, stock availability, etc, but not the SKU.

有谁知道如何在 OC 3 中具体做到这一点?他们已将模板从 PHP 切换到 Twig,我不确定我做错了什么,但我在 OC 2.0 中使用的方法在 3.0 中不起作用.

Does anyone know how to do this specifically in OC 3? They've switched from PHP to Twig for the templates, and I'm not sure what I'm doing wrong but the method I was using in OC 2.0 is NOT working in 3.0.

{{ product.href }} displays the product URL
{{ product.description }} displays the description
{{ product.price }} displays the price
...but {{ product.sku }} or {{ sku }} or {{ product['sku'] }} does NOTHING.

推荐答案

尝试类似默认 OpenCart 代码的方法.这在最新的 opencart 版本 3.0.2.0 中运行良好

Try something like in default OpenCart code. This is working fine in latest opencart version 3.0.2.0

第一步:打开文件catalog/controller/product/category.php

查找:

'rating'      => $result['rating'],

添加后:

'sku'         => $result['sku'],


第 2 步: 打开文件:catalog\language\en-gb(your language)\product\category.php

查找:

$_['text_price']        = 'Price:';

添加后:

$_['text_sku']        = 'SKU:';


第 3 步: 打开文件:catalog/view/theme/default(your theme)/template/product/category.twig

查找:

<p>{{ product.description }}</p>

添加后:

{% if product.sku %}
 <p>{{ text_sku }} {{ product.sku }}</p>
{% endif %}



第一步:打开文件catalog/controller/product/product.php

查找:

$data['heading_title'] = $product_info['name'];

添加后:

$data['sku'] = $product_info['sku'];


第 2 步: 打开文件:catalog\language\en-gb(your language)\product\product.php

查找:

$_['text_model']               = 'Product Code:';

添加后:

$_['text_sku']               = 'SKU:';


第 3 步: 打开文件:catalog/view/theme/default(your theme)/template/product/product.twig

查找:

<li>{{ text_model }} {{ model }}</li>

添加后:

{% if sku %}
<li>{{ text_sku }} {{ sku }}</li>
{% endif %}

这篇关于OpenCart 3.0.2.0 - 如何在类别上显示 SKU &amp;产品页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆