Hallo zusammen,
ich habe jetzt schon den ganzen Tag an einem Hook rumgefummelt und komme einfach nicht darauf, was ich falsch mache. Wahrscheinlich habe ich einfach nur ein Brett vorm Kopf und die Lösung ist ganz einfach.
In der Datei /lib/class.tx_commerce_product.php gibt es folgenden Abschnitt (line 123 ff)
/**
* @param integer uid of product
* @param integer integer language_uid , default 0
*/
function init($uid,$lang_uid=0) {
$this->database_class='tx_commerce_db_product';
$this->fieldlist=array('uid','title','subtitle','description','teaser','images','teaserimages','relatedpage','l18n_parent','manufacturer_uid');
if ($uid > 0) {
$this->uid=$uid;
$this->lang_uid=$lang_uid;
$this->conn_db=new $this->database_class;
$hookObjectsArr = array();
if (is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'] as $classRef) {
$hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
}
}
foreach($hookObjectsArr as $hookObj) {
if (method_exists($hookObj, 'postinit')) {
$hookObj->postinit($this);
}
}
return true;
}
else
{
return false;
}
}
Ich möchte das fieldlistarray einfach um ein paar Felder erweitern ohne dafür den Quellcode der Datei zu verändern.
Da es hier einen Hook gibt, dachte ich mir ich könnte es dafür nutzen.
Also habe ich in meine commerce Erweiterung eine ext_localconf.php angelegt und folgendes reingeschrieben:
require_once(t3lib_extMgm::extPath($_EXTKEY).'lib/class.tx_ofcpainit.php');
$TYPO3_CONF_VARS['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'][] = 'ofcpainit';
Dann habe ich entsprechende Datei angelegt und die Klasse ofcpainit mit der Methode postinit angelegt, welche das fieldarray um meine Felder erweitern soll.
Das sieht dann so aus:
class ofcpainit {
function postinit() {
$additionalfields=array('tx_ofcommerceproductsaddon_setup','tx_ofcommerceproductsaddon_constants','tx_ofcommerceproductsaddon_template');
$this->fieldlist=array_merge($additionalfields,$this->fieldlist);
}
}
Allerdings wird diese Datei nicht aufgerufen und ich habe keinen Plan wieso.
Bitte nagelt mir das Brett vorm Kopf weg!!!
Grüße
Sven