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.
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.
Try something like in default OpenCart code. This is working fine in latest opencart version 3.0.2.0
Step 1: Open file catalog/controller/product/category.php
Find:
'rating' => $result['rating'],
Add after:
'sku' => $result['sku'],
Step 2: Open file: catalog\language\en-gb(your language)\product\category.php
Find:
$_['text_price'] = 'Price:';
Add after:
$_['text_sku'] = 'SKU:';
Step 3: Open file: catalog/view/theme/default(your theme)/template/product/category.twig
Find:
<p>{{ product.description }}</p>
Add after:
{% if product.sku %}
<p>{{ text_sku }} {{ product.sku }}</p>
{% endif %}
Step 1: Open file catalog/controller/product/product.php
Find:
$data['heading_title'] = $product_info['name'];
Add after:
$data['sku'] = $product_info['sku'];
Step 2: Open file: catalog\language\en-gb(your language)\product\product.php
Find:
$_['text_model'] = 'Product Code:';
Add after:
$_['text_sku'] = 'SKU:';
Step 3: Open file: catalog/view/theme/default(your theme)/template/product/product.twig
Find:
<li>{{ text_model }} {{ model }}</li>
Add after:
{% if sku %}
<li>{{ text_sku }} {{ sku }}</li>
{% endif %}