Jump to content
sscardefield

Add manufacturer part number to product page

Recommended Posts

I am trying to figure out how to add the manufacturer's part number to the individual product pages. I have sorted through quite a few threads but have come up empty handed. This seems like pretty basic functionality. Is there something I'm missing?

Share this post


Link to post
Share on other sites

hello,

 

what about "reference" field ?

Share this post


Link to post
Share on other sites

I tried that, but I don't think it will do. It just doesn't cut it. "Reference:  XXXXXXX". Some people might be able to look at that and figure out it is the part number, but the majority I don't think will. I need it to say "MPN: XXXXXX".

 

KLSHpah.jpg

I know I could probably just find out which .tpl that "Reference" is in and change it to "MPN, but I feel like it should be it's own field, like there should be a field in the product details page called MPN or something. I just went through a lot of the various places that I buy from online and every single one of them has at minimum a manufacturer part number listed and most also have a manufacturer listed, both in that same spot where Reference is.

 

If there is no easy way to to accomplish that, does anybody know what .tpl that "Reference" is in?

Edited by sscardefield (see edit history)

Share this post


Link to post
Share on other sites

in this case you have to extend product object and define new fields in database.

 

(1)

in ps_product table create field named "mpn"

i9pGp9d.png

 

 

(2)

in file: ADMIN/themes/default/template/controllers/products/informations.tpl right after code:

<tr>
			<td class="col-left"><label>{$bullet_common_field} {l s='Reference:'}</label></td>
			<td style="padding-bottom:5px;">
				<input size="55" type="text" name="reference" value="{$product->reference|htmlentitiesUTF8}" style="width: 130px; margin-right: 44px;" />
				<span class="hint" name="help_box">{l s='Special characters allowed:'}.-_#\<span class="hint-pointer"> </span></span>
			</td>
		</tr>

add code:

<tr>
<td class="col-left"><label>{$bullet_common_field} {l s='Part number:'}</label></td>
<td style="padding-bottom:5px;">
<input size="55" type="text" name="mpn" value="{$product->mpn|htmlentitiesUTF8}" style="width: 130px; margin-right: 44px;" />
</span>
</td>
</tr>

effect:

5CqZrdm.png

 

 

(3)

open classes/Product.tpl file

 

right after:

class ProductCore extends ObjectModel
{
	/** @var string Tax name */
	public $tax_name;

add:

 

 

public $mpn;

 

 

then right after:

public static $definition = array(
		'table' => 'product',
		'primary' => 'id_product',
		'multilang' => true,
		'multilang_shop' => true,
		'fields' => array(
			// Classic fields
			'id_shop_default' => 			array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_manufacturer' => 			array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_supplier' => 				array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'reference' => 					array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),

add:

'mpn' => 					array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),

(4) now your field works in back office well.

Just modify product.tpl file and add code to display your new variable somewhere {$product->mpn}

  • Like 3

Share this post


Link to post
Share on other sites

Awesome, thank you for taking the time to type that out, I really appreciate it. I'll give it a try tonight and report back.

Share this post


Link to post
Share on other sites

how did it go? have you tried it? 

waiting for your response in this case

thanks in advance,

Milos

Share this post


Link to post
Share on other sites

Hello vekia,
I try to find a solution for 3 days now to add a field in prestashop 1.5.5, the category page with override imposiible but I tried everything but it does not work ... Is anyone can us help give us the steps please?

Share this post


Link to post
Share on other sites

Hi,

 

I am a prestashop developer as well as I run an online mobile shop. Usually products have lot of attributes. It is not required to add those attributes as separate fields unless you want them to be indexed. For example in mobiles we have so many attributes, technical specifications, etc. The best way to achieve them is to add them in product description (or short description if you want). I do that all the time . Like this :

 

https://www.diigo.com/item/image/4h50p/91ak

 

If you do not know HTML, you can simply use word document to create a table and use "Paste from Word" option in the Product Description editor to paste the table. (or if you know HTML you can simply create HTML tables)

 

 

Hope this helps.

Edited by ibndawood (see edit history)

Share this post


Link to post
Share on other sites

Hello vekia,

I try to find a solution for 3 days now to add a field in prestashop 1.5.5, the category page with override imposiible but I tried everything but it does not work ... Is anyone can us help give us the steps please?

 

what you exactly expect? i don't understand, guide above allows to create new field for product. you want to category? or what?

Share this post


Link to post
Share on other sites

This was the only mod that actually worked. Thanks a lot. I know that PS 1.6 comes already with a "Supplier Reference" field, but never managed to get it on the Frontend because is on a diferent table.

 

 

 

in this case you have to extend product object and define new fields in database.

 

(1)

in ps_product table create field named "mpn"

i9pGp9d.png

 

 

(2)

in file: ADMIN/themes/default/template/controllers/products/informations.tpl right after code:

<tr>
			<td class="col-left"><label>{$bullet_common_field} {l s='Reference:'}</label></td>
			<td style="padding-bottom:5px;">
				<input size="55" type="text" name="reference" value="{$product->reference|htmlentitiesUTF8}" style="width: 130px; margin-right: 44px;" />
				<span class="hint" name="help_box">{l s='Special characters allowed:'}.-_#\<span class="hint-pointer"> </span></span>
			</td>
		</tr>

add code:

<tr>
<td class="col-left"><label>{$bullet_common_field} {l s='Part number:'}</label></td>
<td style="padding-bottom:5px;">
<input size="55" type="text" name="mpn" value="{$product->mpn|htmlentitiesUTF8}" style="width: 130px; margin-right: 44px;" />
</span>
</td>
</tr>

effect:

5CqZrdm.png

 

 

(3)

open classes/Product.tpl file

 

right after:

class ProductCore extends ObjectModel
{
	/** @var string Tax name */
	public $tax_name;

add:

 

 

 

then right after:

public static $definition = array(
		'table' => 'product',
		'primary' => 'id_product',
		'multilang' => true,
		'multilang_shop' => true,
		'fields' => array(
			// Classic fields
			'id_shop_default' => 			array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_manufacturer' => 			array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'id_supplier' => 				array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
			'reference' => 					array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),

add:

'mpn' => 					array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),

(4) now your field works in back office well.

Just modify product.tpl file and add code to display your new variable somewhere {$product->mpn}

Share this post


Link to post
Share on other sites

Could this be done with an override?  Or does it have to go into the main class file?

Share this post


Link to post
Share on other sites
On 11/27/2016 at 10:51 PM, doanthitoan1960 said:

Hello vekia

Cant i add this to 1.7 version?

Any help for PS 1.7.6.5 version?

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More