wird immer das letzte modul ausgeführt und der erste Eintrag wird irgendwie überschrieben bzw. ich kann
kein export ausfürhen, er führt immer das letzte Modul aus.
die beiden Module sind identisch nur die ausgabe der datein sind anders.
wird immer das letzte modul ausgeführt und der erste Eintrag wird irgendwie überschrieben bzw. ich kann
kein export ausfürhen, er führt immer das letzte Modul aus.
die beiden Module sind identisch nur die ausgabe der datein sind anders.
gruß exithh[/QUOTE]
Beide Module müssen in den überladenen Methoden auch die Parentmethoden aufrufen. Fehlt dieser Aufruf, wird nur das letzte Modul aufgerufen.
public function save()
{
// Tue irgendwas
$sRet = parent::save();
// Tue nochwas
return $sRet;
}
Hi nochmal ich hab mir das gerade angeguckt blos wenn ich jedes mal in der methode z.b nextTick parent aufrufe passiert wieder das selbe? so wie ich dich verstanden habe soll ich in jeder methode parent aufrufen?
was mach ich bei diesem Beispiel konkret falsch?
für jede hilfe wäre ich sehr dankbar!
Gruß exithh
<?php
/**
* This file is part of Google Base Export module.
*
* Google Base Export module is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* You can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* See <http://www.gnu.org/licenses/>.
*
* @link http://www.oxid-esales.com
*/
/**
* General export class.
*/
class GoogleBase_GenExport_Do extends GoogleBase_GenExport_Do_parent
{
public $sClass_do = "googlebase_GenExport_do";
//output paths and files
public $sExportFileType = "xls";
public $sExportFileName = "googlebase";
/**
* Does Export line by line on position iCnt
*
* @param integer $iCnt export position
*
* @return bool
*/
public function nextTick( $iCnt )
{
$myConfig = oxConfig::getInstance();
$iExportedItems = $iCnt;
if ( $oArticle = $this->getOneArticle( $iCnt, $blContinue ) ) {
$smarty = oxUtilsView::getInstance()->getSmarty();
$smarty->assign_by_ref( "linenr", $iCnt );
$smarty->assign_by_ref( "article", $oArticle );
$smarty->assign( "spr", $myConfig->getConfigParam( 'sCSVSign' ) );
$smarty->assign( "encl", $myConfig->getConfigParam( 'sGiCsvFieldEncloser' ) );
$smarty->assign( "sManufacturer", $this->_getManufactorTitle( $oArticle->oxarticles__oxmanufacturerid->value ) );
$smarty->assign( "sPictureUrl", $this->_checkPictureUrl( $oArticle ) );
$smarty->assign( "sCategory", $oArticle->getCategory()->oxcategories__oxtitle->value );
$this->write( $smarty->fetch( "googlebase_genexport.tpl", $this->getViewID() ) );
return ++$iExportedItems;
}
return $blContinue;
}
/**
* Give the manufacture title back.
*
* @param string $sOxManufactureId oxid from the manufactor of the current product
*
* @return string
*/
private function _getManufactorTitle( $sOxManufactureId )
{
$sQuery = "select oxtitle from `oxmanufacturers` where oxid = '".$sOxManufactureId."' LIMIT 1";
$oResult = oxDb::getDb()->Execute($sQuery);
return $oResult->fields[0];
}
/**
* Check the Pic URL. If there is no pic saved, give null back.
*
* @param object $oArticle Article object
* @param int $iIndex Picture index number
*
* @return mixed
*/
private function _checkPictureUrl( $oArticle, $iIndex = 1 )
{
$sPicUrl = null;
$sPicName = $oArticle->{"oxarticles__oxpic".$iIndex}->value;
if( strpos( $sPicName, 'nopic.jpg' ) === false ) {
$sPicUrl = $oArticle->getPictureUrl( $iIndex );
$sPicUrl = str_replace( '/$this->sTheme/tpl/../pictures/0/nopic.jpg', "/pictures/$iIndex/$sPicName", $sPicUrl );
}
return $sPicUrl;
}
}
```php
[QUOTE=exithh;44276]Hi nochmal ich hab mir das gerade angeguckt blos wenn ich jedes mal in der methode z.b nextTick parent aufrufe passiert wieder das selbe? so wie ich dich verstanden habe soll ich in jeder methode parent aufrufen?
was mach ich bei diesem Beispiel konkret falsch?
für jede hilfe wäre ich sehr dankbar!
Gruß exithh
…
[/QUOTE]
Hallo,
Gleich vornweg: Ich hab mich jetzt nicht in die Logik eingelesen. Ob die folgenden Aussagen auch das Problem lösen, mag ich Dir nicht garantieren. Das erfordert dann etwas mehr Aufwand, als einen Forumseintrag.
Die Module werden kaskadiert solang abgearbeitet, solang ein parent::Methodenname darin enthalten ist. Ansonsten wird jeder Quellcode der überladenen Methoden ignoriert.
Für Dein Beispiel sieht das so aus, wenn Du alle Methoden überladen willst:
class GoogleBase_GenExport_Do extends GoogleBase_GenExport_Do_parent
{
...
public function nextTick( $iCnt )
{
...
$mRet = parent::nextTick($iCnt);
...
}
private function _getManufactorTitle( $sOxManufactureId )
{
...
$mRet = parent::_getManufactorTitle( $sOxManufactureId );
...
}
private function _checkPictureUrl( $oArticle, $iIndex = 1 )
{
...
$mRet = parent::_checkPictureUrl( $oArticle, $iIndex);
...
}
}
Voraussetzung dafür ist natürlich, daß die Methoden auch in der Elternklasse oder deren Elternklassen enthalten ist. Das kannst Du aber ggf. mit method_exist(…) prüfen.
Schau mal, ist das nicht etwas als Lösungsvorschlag für dich?
Ich hatte das gleiche Problem und habe mich in dem anderen Thread schon dazu ausgelassen.