Jump to content
  • 0

Adding new tabs and fields to Prestashop products’ back office von nemops.com


prestaAnwender77

Question

Hallo,

ich bin im Internet auf die Anleitung

http://nemops.com/prestashop-products-new-tabs-fields/#.WFg0TWUxnmg

 

gestossen in der gezeigt wird wie man im Back Office ein Neues Product Tab und ein Feld einfügt, das hat auch soweit geklappt, ich würde nun jetzt gerne weiter Felder hinzufügen aber leider bin ich in PHP nicht ganz so fit darum wollte ich mal fragen ob mir jemand helfen kann

 

ich habe die funktion "alterTable" erweitert

	public function alterTable($method)
	{
		switch ($method) {
			case 'add':
				$sql = 'ALTER TABLE ' . _DB_PREFIX_ . 'product_lang ADD `custom_field` TEXT NOT NULL';
				break;
			
			case 'remove':
				$sql = 'ALTER TABLE ' . _DB_PREFIX_ . 'product_lang DROP COLUMN `custom_field`';
				break;
				
			case 'add':
				$sql = 'ALTER TABLE' . _DB_PREFIX_ . 'product_lang ADD `plz_field` TEXT NOT NULL';
				break;
				
			case 'remove':
				$sql = 'ALTER TABLE' . _DB_PREFIX_ . 'product_lang DROP COLUMN `plz_field`';
				break;
		}

jetzt geht es noch um die funktion hookActionProductUpdate

public function hookActionProductUpdate($params)
	{
		// get all languages
		// for each of them, store the custom field!

		$id_product = (int)Tools::getValue('id_product');
		$languages = Language::getLanguages(true);
		foreach ($languages as $lang) {
			if(!Db::getInstance()->update('product_lang', array('custom_field'=> pSQL(Tools::getValue('custom_field_'.$lang['id_lang']))) ,'id_lang = ' . $lang['id_lang'] .' AND id_product = ' .$id_product ))
				$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
		}

	}

und um die Funktion getCustomField

	public function getCustomField($id_product)
	{
		$result = Db::getInstance()->ExecuteS('SELECT custom_field, id_lang FROM '._DB_PREFIX_.'product_lang WHERE id_product = ' . (int)$id_product);
		if(!$result)
			return array();

		foreach ($result as $field) {
			$fields[$field['id_lang']] = $field['custom_field'];
		
		}

		return $fields;
	}
}

wie genau muss ich diese noch erweitern damit das abrufen und speichern klappt ? in der tpl habe ich das zweite feld auch schon eingefügt und es wird auch schon angezeigt.

 

Danke für die hilfe und ich wünsche allen schonmal Frohe Weihnachten und ein guten Rutsch

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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