Jump to content

Adding new tab in product creation page


Richard S

Recommended Posts

Hi,

 

I have looked trough AdminProducts.php and AdminCatalog.php classes and I was disappointed because many actions are created there by simple if, elseif sentences which are not very good if you want to add additional tab to the product creation or edit page.

 

Maybe I have missed something and is there a convenient way including less work on core updates and etc. with this?

 

Has anyone tried to add a tab there?

  • Like 1
Link to comment
Share on other sites

Hi

I have made some change on admin->tab->AdminProducts.php file to adding new tab for adding youtube vidio for each product

with the name of tab vidio.

this is independent of languge selection and you have to create a table manually in your database

 

 

CREATE TABLE  `ps_youtube` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`product_id` VARCHAR( 255 ) NOT NULL ,
`title` VARCHAR( 255 ) NOT NULL ,
`vidio` TEXT NOT NULL
) ENGINE = INNODB;

 

 

and replace your admin->tab->AdminProducts.php file code with the newly file code which I have attached below

to understand new code I have marked with the

/*************************** code to extend the AdminCatalog product detail start here************************************/

 

There is some limitation(language compatbility) but it works its shorted out my problem

I am still working to refine and making more easier way

AdminProducts.txt

  • Like 2
Link to comment
Share on other sites

  • 3 months later...

Hi,

 

Has anybody ever pulled this thing off? I would like to add a gallery tab to each product which is similar to the image tab. The image then will be stored to an additional table ps_gallery which also similar to ps_image but without cover column. But I'm having problem on saving the image to database. Can anybody explain how saving images or add() function work in Prestashop?

 

Thanks.

Link to comment
Share on other sites

Part 1:

In admin->tabs, open file adminProducts.php [PS1.4.5]

 

Add following piece of code in line 2870, make changes as per your requirement to text in color tag.

 

 echo '<tr>
  <td class="col-left">'.$this->l('[color=#006400]Shipping & Payment Information[/color]:').'<br /><br /><i>('.$this->l('appears in the body of the product page').')</i></td>
  <td style="padding-bottom:5px;" class="translatable">';
 foreach ($this->_languages as $language)
  echo '  <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
	<textarea class="rte" cols="100" rows="20" id="[color=#008000]shippinginfo[/color]_'.$language['id_lang'].'" name="[color=#006400]shippinginfo[/color]_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, '[color=#008000]shippinginfo[/color]', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
   </div>';
  echo ' </td>
</tr>';

 

Will take some time to come up with part 2 as i forgot how i did last time, but i m checking :)

Link to comment
Share on other sites

Part 2:

Open phpmyadmin to alter table [prefix]_product_lang

 

Insert a new column with the name you used in AdminProduct; in my case shippinginfo

Use same properties as description in case you want text to be inserted.

 

Part 3:

Can be done in two ways - simple and hard

 

Hard way: In case you dont understand what I have mentioned below, i will explain in detail

 

Simple Method: Open Classes->product.php

 

search for the word 'description' and copy the word/line and change it with 'shippinginfo/your keyword'. I have noted down the instances where you need to make changes.

 

/** @var stringShipping Info */
public   $shippinginfo;
protected $fieldsValidateLang = array(
 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName',
 'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'name' => 'isCatalogName',
 'description' => 'isString', 'shippinginfo' => 'isString', 'description_short' => 'isString', 'available_now' => 'isGenericName', 'available_later' => 'IsGenericName');
$fields[$language['id_lang']]['shippinginfo'] = (isset($this->shippinginfo[$language['id_lang']])) ? pSQL($this->shippinginfo[$language['id_lang']], true) : '';

 

Note: Till this part is for the backend i.e. When you add/update product.

Link to comment
Share on other sites

Part 4:

 

Add new tab in product page

 

your theme folder -> product.tpl

 

Search for "<!-- description and features -->"

 

Add

{if $product->shippinginfo}<li><a id="more_info_tab_more_info" href="#idTab10">{l s='Shipping info'}</a></li>{/if}

under

<ul id="more_info_tabs" class="idTabs idTabsShort">

 

Add it where you want it to be, i mean tab position. I have given it last position and referred it as #idTab10

 

Next add


{if $product->shippinginfo}
<!-- shipping info -->
<div id="idTab10" class="rte">{$product->shippinginfo}</div>
{/if}

after


{if $product->description}
<!-- full description -->
<div id="idTab1" class="rte">{$product->description}</div>
{/if}

 

Note: This will place the new tab in your product page and also displays the data

 

In case, this doesnt work out reply back.

 

Also would like to warn that you will loose the changes made when you update. But the process is simple and you can save money :)

Link to comment
Share on other sites

  • 6 months later...

Hello Vineshkumar,

 

Thanks for your replies bro. I have tried this process but when i am adding additional information & saving that product it become blank again. It seems like content is not going in database.

 

Can you suggest me what would be the problem?

 

Thanks,

Link to comment
Share on other sites

  • 1 year later...

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