Jump to content

Add a custom field to Back-office


Recommended Posts

Hi,

   I want to create a new text field "Author" in back-office(Products -> Information) and display the same in store front in product page below product name.

 

I don't need a text box by using customization option in product edit page. I need a permanent field which can affect in all products.

 

All I know is the files required to do this are information.tpl, product.tpl, product.php in classes folder and a sql column in ps_products. I tried with some codes. But the page went blank.

 

post-797605-0-71977600-1403017557_thumb.jpg

 

Need help with this.

 

Thanks in Advance.

Edited by mani8289 (see edit history)
Link to comment
Share on other sites

Hi,

   I have got the field on back-office through this article "http://mypresta.eu/en/art/developer/new-field-product-backoffice.html".

 

This is how I modified things,

 

Created a column "b_author" in ps_product

 

product.php:

 

/** @var string author name */
    public $b_author;

 

'b_author' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'),

 

information.tpl:

 

 <div>
            <div class="col-left">
                <label>{l s='Author Name:'}</label>
            </div>
            <div style="padding-bottom:5px;">
                <input type="text" id="b_author" name="b_author" value="{$product->b_author|default:''}"/>
            </div>
        </div>

 

product.tpl:

 

<p>
                <label>{l s='Author:'} </label>
                <span class="editable" itemprop="sku">{if !isset($groups)}{$product->b_author|escape:'html':'UTF-8'}{/if}</span>
            </p>

 

I am able to see the field but when I give it a value and save it gives an error "An error occurred while updating an object. product ()".

 

Its not saving in database and not showing in store front.

 

Anyone help with this

 

Thanks in Advance

Link to comment
Share on other sites

  • 1 month later...

I have the same issue.

 

The database is updated correctly but with error code "An error occurred while updating an object. product ()". I turned on error report and it says the "preorder" field (preorder is the field i added) was not found in the list, which I have already added to my DB table and was updated correctly.

 

When trying to add a new product, the new product shows up in the DB but not in the backoffice. The error when I got after clicking on the "save" button was "An error occurred while adding an object. product ()"

 

Anyone got a solution for this?

 

Hi,

   I have got the field on back-office through this article "http://mypresta.eu/en/art/developer/new-field-product-backoffice.html".

 

This is how I modified things,

 

Created a column "b_author" in ps_product

 

product.php:

 

/** @var string author name */
    public $b_author;

 

'b_author' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'),

 

information.tpl:

 

 <div>
            <div class="col-left">
                <label>{l s='Author Name:'}</label>
            </div>
            <div style="padding-bottom:5px;">
                <input type="text" id="b_author" name="b_author" value="{$product->b_author|default:''}"/>
            </div>
        </div>

 

product.tpl:

 

<p>
                <label>{l s='Author:'} </label>
                <span class="editable" itemprop="sku">{if !isset($groups)}{$product->b_author|escape:'html':'UTF-8'}{/if}</span>
            </p>

 

I am able to see the field but when I give it a value and save it gives an error "An error occurred while updating an object. product ()".

 

Its not saving in database and not showing in store front.

 

Anyone help with this

 

Thanks in Advance

 

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...