Page 1 of 1

[SOLVED] Add MPN, EAN and weight to products page

Posted: Sat Jun 23, 2018 5:50 pm
by storiqax
I want to add more info to products page like the MPN code, the weight of products etc, is that possible?

What's the abbreviation (like {{ text_manufacturer }} ) for MPN, EAN and weight?

Thank in advance!

Re: Add MPN, EAN and weight to products page

Posted: Sat Jun 23, 2018 7:50 pm
by straightlight
In catalog/controller/product/product.php file,

find:

Code: Select all

$data['points'] = $product_info['points'];
add below:

Code: Select all

$data['mpn'] = html_entity_decode($product_info['mpn'], ENT_QUOTES, 'UTF-8');
$data['ean'] = html_entity_decode($product_info['ean'], ENT_QUOTES, 'UTF-8');
$data['weight'] = $this->weight->format($product_info['weight'], $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
In catalog/language/your_language_code/product/product.php file,

add at the bottom:

Code: Select all

$_['text_mpn'] = 'MPN:';
$_['text_ean'] = 'EAN:';
$_['text_weight'] = 'Weight:';
In your catalog/view/theme/<your_theme>/template/product/product.twig file, add:

Code: Select all

{% if mpn %}
{{ text_mpn}} {{ mpn }}
{% endif %}

{% if ean %}
{{text_ean}} {{ ean }}
{% endif %}

{% if weight %}
{{text_weight}} {{ weight }}
{% endif %}
where you want.

Then, ensure to apply these steps: viewtopic.php?f=176&p=725084#p718325

This should resolved the issue.

Re: Add MPN, EAN and weight to products page

Posted: Mon Jun 25, 2018 1:41 am
by storiqax
Much appreciated, thank for your time!

Re: Add MPN, EAN and weight to products page

Posted: Mon Aug 27, 2018 7:18 am
by Marzy1357
Works as charm! Thanks a lot, you saved me as well!!

Re: Add MPN, EAN and weight to products page

Posted: Tue Sep 18, 2018 9:12 pm
by SubatWest
Hi
Thanks for the post as this is an issue I am looking at and cannot resolve. Here is the code that I am applying in the different files in context:

$data['product_id'] = (int)$this->request->get['product_id'];
$data['manufacturer'] = $product_info['manufacturer'];
$data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
$data['model'] = $product_info['model'];
$data['reward'] = $product_info['reward'];
$data['points'] = $product_info['points'];
$data['mpn'] = html_entity_decode($product_info['mpn'], ENT_QUOTES, 'UTF-8');
$data['ean'] = html_entity_decode($product_info['ean'], ENT_QUOTES, 'UTF-8');
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES,


$_['text_week'] = 'week';
$_['text_semi_month'] = 'half-month';
$_['text_month'] = 'month';
$_['text_year'] = 'year';
$_['text_mpn'] = 'MPN:';


{% if additionalfields %}
{% for key, additionalfield in additionalfields %}
<li id="customfield-{{ key }}">
<span class="text-bold">{{ additionalfield.title }}:</span>&nbsp;{{ additionalfield.text }}
</li>
{% endfor %}
{% endif %}

{% if mpn %}
{{ text_mpn}} {{ mpn }}
{% endif %}

{% if ean %}
{{text_ean}} {{ ean }}
{% endif %}

<li><span class="text-bold">{{ text_stock }}</span>&nbsp;<span class="{{ stock_color }}-text text-darken-1 text-bold">{{
stock }}</span></li>
{% if type_remainder == 'numerical' %}
<li><span class="text-bold">{{ text_remainder }}</span>:&nbsp;{{ remainder }}</li>
{% endif %}
I have done all the refreshes on Mods/Dashboard and even clear vqmod caches but nothing seems to work. Can you advise? Opencart 3.0.2.0. Thanks for your attention.
The result in product page is:

Re: Add MPN, EAN and weight to products page

Posted: Wed Sep 19, 2018 5:36 am
by straightlight
I don't see any relations between this topic request and the use of your: additionalfields array. You are setting the MPN, EAN and weight while conditioning the additionalfields array but not when it's excluded, according to your posted codes above.

Re: Add MPN, EAN and weight to products page

Posted: Wed Sep 19, 2018 2:27 pm
by SubatWest
Thanks for taking the time to reply.
I am trying to get the mpn etc to appear on product page as this thread suggests. I have followed your instructions. The additional fields are not my construction they were there as part of the theme I am using. I simply added the code as described in the thread.

Re: Add MPN, EAN and weight to products page

Posted: Wed Sep 19, 2018 6:14 pm
by straightlight
If you were adding the code as described on the above's instructions, it wouldn't be between the additionalfields variable. It has to be outside of the condition.