Jump to content

How to get my BO ExtraField in FO product-list.tpl?


Magicalname

Recommended Posts

Hey and Hello ,

 

I want to add just 1 Extra Field to my BO that ich can showup everywhere in the Front Office

 

What i have done....

 

I added a new field to database in ps_product_lang i add my table/row/whatever "untertitel"

 

In admin/themes/default/template/controllers/product/informations.tpl

 

After the Product Name field i add this (copy&paste the name field with modification)

	<div class="form-group">
		<div class="col-lg-1"><span class="pull-right"></span></div>
		<label class="control-label col-lg-2" for="untertitel_{$id_lang}">
			<span class="label-tooltip" data-toggle="tooltip" title="{l s='Untertitel fuer dieses Produkt.'} {l s='Invalid characters:'} <>;=#{}">
				{l s='Untertitel'}
			</span>
		</label>
        <div class="col-lg-5">
			{include file="controllers/products/input_text_lang.tpl"
				languages=$languages
				input_value=$product->untertitel
				input_name="untertitel"
			}
		</div>
	</div>
Next i modified the

classes/Product.php and add my Array, between Name and Description Array

'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'untertitel' => array('type' => self::TYPE_STRING, 'lang' => true),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
here i have my field between name and description too in classes/Product.php

9c6j3xgp.jpg

 

And my SQL Query Fuction in classes/Product.php after "public static function getShopsByProduct"

	public static function getUntertitelByProduct($id_product)
	{
		return Db::getInstance()->executeS('
			SELECT `untertitel`
			FROM `'._DB_PREFIX_.'product_lang`
			WHERE `untertitel` = '.(int)$id_product);
	}
Now my New field wil be saved in database succesfully and i can display it in my product.tpl with

<h2>{$product->untertitel|escape:'html':'UTF-8'}/h2> 
 

But now if i Try it on product-list.tpl i get

 

Trying to get property of non-object in /cache/smarty/compile/da/09/62/da09629e6ee00744f967f154821add741f27f134.file.product-list.tpl.php

 

 

I know its not good to modify core-files but its just 1 field not 10& more 

 

What is wrong please???

 

Many Thx

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...