Jump to content

Modify Product Edit Page


nbarnum

Recommended Posts

I want to add a coming soon check box to the Product informations.tpl.  I can get the TPL to recognize if the database has a 0 or a 1 in that column but I can't change it through prestashop.  I have to manually edit the database for it to work.  I deleted the class_index.php in cache.  What am I misising?

 

I tried using a tutorial by NemoPs but I must be missing something.

http://nemops.com/extending-prestashop-objects

 

I added these two lines to the informations.tpl

{if isset($display_multishop_checkboxes) && $display_multishop_checkboxes}
{include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="available_for_order" type="default"}
{include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="show_price" type="show_price"}
{include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="online_only" type="default"}
{include file="controllers/products/multishop/checkbox.tpl" only_checkbox="true" field="coming_soon" type="default"}
{/if}
<div class="checkbox">
<label for="coming_soon">
<input type="checkbox" name="coming_soon" id="coming_soon" value="1" {if $product->coming_soon}checked="checked"{/if} >
{l s='Coming Soon'}</label>
</div>

To the /override/controllers/admin/AdminProductsController.php I added:

<?php 
class AdminProductsController extends AdminProductsControllerCore
{

protected function copyFromPost(&$object, $table)
{
parent::copyFromPost($object, $table);
if (get_class($object) != 'Product')
return;

$object->coming_soon = (int)Tools::getValue('coming_soon');
}
}
?>

 

I added an override for the product class.  /override/classes/Product.php

<?php 
Class Product extends ProductCore
{

	public $coming_soon;
	public function _construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
	{
	
	self::$definition['fields']['coming_soon'] = array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool');
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
	
	
	}
}
?>
Edited by nbarnum (see edit history)
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...