Post by cssninjah » Fri Apr 05, 2019 6:23 pm

Greetings everyone,
here is my short guide to solving a common problem with the lack of support for outputting html content in product custom attributes.

Advantages of my approach are:
- No headache
- No plugins

So all we need is just a single file that located /catalog/model/catalog/product.php. Find this code around line 319:

Code: Select all

			foreach ($product_attribute_query->rows as $product_attribute) {
				$product_attribute_data[] = array(
					'attribute_id' => $product_attribute['attribute_id'],
					'name'         => $product_attribute['name'],
					 'text'         => $product_attribute['text']
				);
			}
and replace last key => value like this:

Code: Select all

'text'         => html_entity_decode($product_attribute['text'], ENT_QUOTES, 'UTF-8')
Voila. Now you able to put your HTML in custom product attribute field from admin area and get correct output that you can easily beautify via css ;)
Last edited by cssninjah on Tue Apr 09, 2019 8:16 pm, edited 1 time in total.

User avatar
Newbie

Posts

Joined
Fri Mar 29, 2019 7:59 pm

Post by straightlight » Mon Apr 08, 2019 8:22 am

/catalog/model/catalog/products.php
Except that this PHP file does not exist from the controller or model folders originally. The singular filename does.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by cssninjah » Tue Apr 09, 2019 8:27 pm

straightlight wrote:
Mon Apr 08, 2019 8:22 am
/catalog/model/catalog/products.php
Except that this PHP file does not exist from the controller or model folders originally. The singular filename does.
um, I accidentally made a typo and already fixed it. soz.

incorrect path is
/catalog/model/catalog/products.php
and correct path is almost the same as above, but without "s" in filename :)
/catalog/model/catalog/product.php
image below is clickable.
Image

User avatar
Newbie

Posts

Joined
Fri Mar 29, 2019 7:59 pm

Post by adifyz » Thu Nov 07, 2019 12:23 pm

can you use the twig editor in 3.0.3.2 is so where do I find, in not where do I find php ?
Best regards

Newbie

Posts

Joined
Wed Oct 02, 2019 9:57 am

Post by OSWorX » Thu Nov 07, 2019 3:17 pm

adifyz wrote:
Thu Nov 07, 2019 12:23 pm
can you use the twig editor in 3.0.3.2 is so where do I find, in not where do I find php ?
Beside the fact that what you are posting is not understandable, why should someone use a twig editor when you have to edit a php file?

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 1 guest