Post by storiqax » Sat Jun 23, 2018 5:50 pm

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!
Last edited by storiqax on Mon Sep 24, 2018 6:38 pm, edited 1 time in total.

User avatar
New member

Posts

Joined
Tue May 29, 2018 10:19 pm

Post by straightlight » Sat Jun 23, 2018 7:50 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by storiqax » Mon Jun 25, 2018 1:41 am

Much appreciated, thank for your time!

User avatar
New member

Posts

Joined
Tue May 29, 2018 10:19 pm

Post by Marzy1357 » Mon Aug 27, 2018 7:18 am

Works as charm! Thanks a lot, you saved me as well!!

Newbie

Posts

Joined
Sat Jan 16, 2016 6:09 pm

Post by SubatWest » Tue Sep 18, 2018 9:12 pm

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:

Code: Select all

		        $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:

Attachments

screen.png

screen.png (12.07 KiB) Viewed 4450 times

Last edited by straightlight on Thu Mar 26, 2020 2:09 am, edited 1 time in total.
Reason: Added code tags.

Active Member

Posts

Joined
Fri Oct 31, 2014 1:29 am

Post by straightlight » Wed Sep 19, 2018 5:36 am

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by SubatWest » Wed Sep 19, 2018 2:27 pm

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.

Active Member

Posts

Joined
Fri Oct 31, 2014 1:29 am

Post by straightlight » Wed Sep 19, 2018 6:14 pm

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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by vmkrose » Wed Mar 25, 2020 11:30 pm

The link for activating the changes doesn't work anymore - can you please explain what I need to do? Many thanks.

Newbie

Posts

Joined
Tue Mar 07, 2017 6:49 pm
Who is online

Users browsing this forum: No registered users and 265 guests