dynexportbase.php

Go to the documentation of this file.
00001 <?php
00002 
00006 DEFINE("ERR_SUCCESS", -2);
00007 DEFINE("ERR_GENERAL", -1);
00008 DEFINE("ERR_FILEIO", 1);
00009 
00015 class DynExportBase extends oxAdminDetails
00016 {
00022     public $sClassDo            = "";
00023 
00029     public $sClassMain          = "";
00030 
00036     public $sExportPath          = "export/";
00037 
00043     public $sExportFileType      = "txt";
00044 
00050     public $sExportFileName      = "dynexport";
00051 
00057     public $fpFile               = null;
00058 
00064     public $iExportPerTick       = 30;
00065 
00071     protected $_sFilePath        = null;
00072 
00078     protected $_aExportResultset = array();
00079 
00085     protected $_sThisTemplate = "dynexportbase.tpl";
00086 
00092     protected $_aCatLvlCache = null;
00093 
00099     public function __construct()
00100     {
00101         parent::__construct();
00102 
00103         // set generic frame template
00104         $this->_sFilePath = $this->getConfig()->getConfigParam( 'sShopDir' ) . "/". $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00105     }
00106 
00113     public function render()
00114     {
00115         parent::render();
00116 
00117         // assign all member variables to template
00118         $aClassVars = get_object_vars( $this );
00119         while ( list( $name, $value ) = each( $aClassVars ) ) {
00120             $this->_aViewData[$name] = $value;
00121         }
00122 
00123         $this->_aViewData['sOutputFile']     = $this->_sFilePath;
00124         $this->_aViewData['sDownloadFile']   = $this->getConfig()->getConfigParam( 'sShopURL' ) . $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00125 
00126         return $this->_sThisTemplate;
00127     }
00128 
00134     public function createMainExportView()
00135     {
00136         // parent categorie tree
00137         $this->_aViewData["cattree"] = oxNew( "oxCategoryList" );
00138         $this->_aViewData["cattree"]->buildList( $this->getConfig()->getConfigParam( 'bl_perfLoadCatTree' ) );
00139 
00140         $oLangObj = oxNew( 'oxLang' );
00141         $aLangs = $oLangObj->getLanguageArray();
00142         foreach ( $aLangs as $id => $language) {
00143             $language->selected = ($id == $this->_iEditLang);
00144             $this->_aViewData["aLangs"][$id] = clone $language;
00145         }
00146     }
00147 
00153     public function start()
00154     {
00155         // delete file, if its already there
00156         $this->fpFile = @fopen( $this->_sFilePath, "w" );
00157         if ( !isset( $this->fpFile ) || !$this->fpFile ) {
00158             // we do have an error !
00159             $this->stop( ERR_FILEIO );
00160         } else {
00161             $this->_aViewData['refresh'] = 0;
00162             $this->_aViewData['iStart']  = 0;
00163             fclose( $this->fpFile );
00164 
00165             // prepare it
00166             $iEnd = $this->prepareExport();
00167             oxSession::setVar( "iEnd", $iEnd );
00168             $this->_aViewData['iEnd'] = $iEnd;
00169         }
00170     }
00171 
00179     public function stop( $iError = 0 )
00180     {
00181         if ( $iError ) {
00182             $this->_aViewData['iError'] = $iError;
00183         }
00184 
00185         // delete temporary heap table
00186         oxDb::getDb()->execute( "drop TABLE if exists ". $this->_getHeapTableName() );
00187     }
00188 
00196     public function nextTick( $iCnt)
00197     {
00198         return false;
00199     }
00200 
00208     public function write( $sLine )
00209     {
00210         $sLine = $this->removeSID( $sLine );
00211         $sLine = str_replace( array("\r\n","\n"), "", $sLine);
00212         fwrite( $this->fpFile, $sLine."\r\n");
00213     }
00214 
00220     public function run()
00221     {
00222         $blContinue = true;
00223         $iExportedItems = 0;
00224 
00225         $this->fpFile = @fopen( $this->_sFilePath, "a");
00226         if ( !isset( $this->fpFile) || !$this->fpFile) {
00227             // we do have an error !
00228             $this->stop( ERR_FILEIO);
00229         } else {
00230             // file is open
00231             $iStart = oxConfig::getParameter("iStart");
00232             // load from session
00233             $this->_aExportResultset = oxConfig::getParameter( "aExportResultset");
00234 
00235             for ( $i = $iStart; $i < $iStart + $this->iExportPerTick; $i++) {
00236                 if ( ( $iExportedItems = $this->nextTick( $i ) ) === false ) {
00237                     // end reached
00238                     $this->stop( ERR_SUCCESS);
00239                     $blContinue = false;
00240                     break;
00241                 }
00242             }
00243             if ( $blContinue) {
00244                 // make ticker continue
00245                 $this->_aViewData['refresh'] = 0;
00246                 $this->_aViewData['iStart']  = $i;
00247                 $this->_aViewData['iExpItems'] = $iExportedItems;
00248             }
00249             fclose( $this->fpFile);
00250         }
00251     }
00252 
00260     public function removeSid( $sInput )
00261     {
00262         $sSid = $this->getSession()->getId();
00263 
00264         // remove sid from link
00265         $sOutput = str_replace( "sid={$sSid}/", "", $sInput);
00266         $sOutput = str_replace( "sid/{$sSid}/", "", $sOutput);
00267         $sOutput = str_replace( "sid={$sSid}&amp;", "", $sOutput);
00268         $sOutput = str_replace( "sid={$sSid}&", "", $sOutput);
00269         $sOutput = str_replace( "sid={$sSid}", "", $sOutput);
00270 
00271         return $sOutput;
00272     }
00273 
00283     public function shrink( $sInput, $iMaxSize, $blRemoveNewline = true )
00284     {
00285         if ( $blRemoveNewline ) {
00286             $sInput = str_replace( "\r\n", " ", $sInput );
00287             $sInput = str_replace( "\n", " ", $sInput );
00288         }
00289 
00290         $sInput = str_replace( "\t", "    ", $sInput );
00291 
00292         // remove html entities, remove html tags
00293         $sInput = $this->_unHTMLEntities( strip_tags( $sInput ) );
00294 
00295         $oStr = getStr();
00296         if ( $oStr->strlen( $sInput ) > $iMaxSize - 3 ) {
00297             $sInput = $oStr->substr( $sInput, 0, $iMaxSize - 5 ) . "...";
00298         }
00299 
00300         return $sInput;
00301     }
00302 
00311     public function getCategoryString( $oArticle, $sSeparator = "/" )
00312     {
00313         $sCatStr = '';
00314 
00315         $sLang = oxLang::getInstance()->getBaseLanguage();
00316         $oDB = oxDb::getDb();
00317 
00318         $sCatView = getViewName( 'oxcategories', $sLang );
00319         $sO2CView = getViewName( 'oxobject2category', $sLang );
00320 
00321         //selecting category
00322         $sQ  = "select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00323         $sQ .= "where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() )." and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00324 
00325         $oRs = $oDB->execute( $sQ );
00326         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00327             $sLeft   = $oRs->fields[0];
00328             $sRight  = $oRs->fields[1];
00329             $sRootId = $oRs->fields[2];
00330 
00331             //selecting all parent category titles
00332             $sQ = "select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";
00333 
00334             $oRs = $oDB->execute( $sQ );
00335             if ( $oRs != false && $oRs->recordCount() > 0 ) {
00336                 while ( !$oRs->EOF ) {
00337                     if ( $sCatStr ) {
00338                         $sCatStr .= $sSeparator;
00339                     }
00340                     $sCatStr .= $oRs->fields[0];
00341                     $oRs->moveNext();
00342                 }
00343             }
00344         }
00345 
00346         return $sCatStr;
00347     }
00348 
00356     public function getDefaultCategoryString( $oArticle )
00357     {
00358         $sLang = oxLang::getInstance()->getBaseLanguage();
00359         $oDB = oxDb::getDb();
00360 
00361         $sCatView = getViewName( 'oxcategories', $sLang );
00362         $sO2CView = getViewName( 'oxobject2category', $sLang );
00363 
00364         //selecting category
00365         $sQ =  "select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00366         $sQ .= "where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() )." and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00367 
00368         return $oDB->getOne( $sQ);
00369     }
00370 
00378     public function prepareCSV( $sInput )
00379     {
00380         $sInput = oxUtilsString::getInstance()->prepareCSVField( $sInput );
00381         return str_replace( array( "&nbsp;", "&euro;", "|" ), array( " ", "", "" ), $sInput );
00382     }
00383 
00391     public function prepareXML( $sInput )
00392     {
00393         $sOutput = str_replace( "&", "&amp;", $sInput );
00394         $sOutput = str_replace( "\"", "&quot;", $sOutput );
00395         $sOutput = str_replace( ">", "&gt;", $sOutput );
00396         $sOutput = str_replace( "<", "&lt;", $sOutput );
00397         $sOutput = str_replace( "'", "&apos;", $sOutput );
00398 
00399         return $sOutput;
00400     }
00401 
00409     public function getDeepestCategoryPath( $oArticle )
00410     {
00411         return $this->_findDeepestCatPath( $oArticle );
00412     }
00413 
00419     public function prepareExport()
00420     {
00421         $oDB = oxDb::getDb();
00422         $sHeapTable = $this->_getHeapTableName();
00423 
00424         // #1070 Saulius 2005.11.28
00425         // check mySQL version
00426         $oRs = $oDB->execute( "SHOW VARIABLES LIKE 'version'" );
00427         $sTableCharset = $this->_generateTableCharSet( $oRs->fields[1] );
00428 
00429         // create heap table
00430         if ( !( $this->_createHeapTable( $sHeapTable, $sTableCharset ) ) ) {
00431             // error
00432             oxUtils::getInstance()->showMessageAndExit( "Could not create HEAP Table {$sHeapTable}\n<br>" );
00433         }
00434 
00435         $sCatAdd = $this->_getCatAdd( oxConfig::getParameter( "acat" ) );
00436         if ( !$this->_insertArticles( $sHeapTable, $sCatAdd ) ) {
00437             oxUtils::getInstance()->showMessageAndExit( "Could not insert Articles in Table {$sHeapTable}\n<br>" );
00438         }
00439 
00440         $this->_removeParentArticles( $sHeapTable );
00441         $this->_setSessionParams();
00442 
00443         // get total cnt
00444         return $oDB->getOne( "select count(*) from {$sHeapTable}" );
00445     }
00446 
00455     public function getOneArticle( $iCnt, & $blContinue )
00456     {
00457         $myConfig  = $this->getConfig();
00458 
00459         //[Alfonsas 2006-05-31] setting specific parameter
00460         //to be checked in oxarticle.php init() method
00461         $myConfig->setConfigParam( 'blExport', true );
00462         $blContinue = false;
00463 
00464         if ( ( $oArticle = $this->_initArticle( $this->_getHeapTableName(), $iCnt, $blContinue ) ) ) {
00465             $blContinue = true;
00466             $oArticle = $this->_setCampaignDetailLink( $oArticle );
00467         }
00468 
00469         //[Alfonsas 2006-05-31] unsetting specific parameter
00470         //to be checked in oxarticle.php init() method
00471         $myConfig->setConfigParam( 'blExport', false );
00472 
00473         return $oArticle;
00474     }
00475 
00484     public function assureContent( $sInput, $sReplace = null)
00485     {
00486         $oStr = getStr();
00487         if ( !$oStr->strlen( $sInput ) ) {
00488             if ( !isset( $sReplace ) || !$oStr->strlen( $sReplace ) ) {
00489                 $sReplace = "-";
00490             }
00491             $sInput = $sReplace;
00492         }
00493         return $sInput;
00494     }
00495 
00504     protected function _unHtmlEntities( $sInput )
00505     {
00506         $aTransTbl = array_flip( get_html_translation_table( HTML_ENTITIES ) );
00507         return strtr( $sInput, $aTransTbl );
00508     }
00509 
00515     protected function _getHeapTableName()
00516     {
00517         // table name must not start with any digit
00518         return "tmp_".str_replace( "0", "", md5( $this->getSession()->getId() ) );
00519     }
00520 
00528     protected function _generateTableCharSet( $sMysqlVersion )
00529     {
00530         $sTableCharset = "";
00531 
00532         //if MySQL >= 4.1.0 set charsets and collations
00533         if ( version_compare( $sMysqlVersion, '4.1.0', '>=' ) > 0 ) {
00534             $oDB = oxDb::getDb( true );
00535             $oRs = $oDB->execute( "SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" );
00536             if ( isset( $oRs->fields['Collation'] ) && ( $sMysqlCollation = $oRs->fields['Collation'] ) ) {
00537                 $oRs = $oDB->execute( "SHOW COLLATION LIKE '{$sMysqlCollation}'" );
00538                 if ( isset( $oRs->fields['Charset'] ) && ( $sMysqlCharacterSet = $oRs->fields['Charset'] ) ) {
00539                     $sTableCharset = "DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}";
00540                 }
00541             }
00542 
00543         }
00544         return $sTableCharset;
00545     }
00546 
00555     protected function _createHeapTable( $sHeapTable, $sTableCharset )
00556     {
00557         $blDone = false;
00558 
00559         $oDB = oxDb::getDb();
00560         $sQ = "CREATE TABLE IF NOT EXISTS {$sHeapTable} ( `oxid` CHAR(32) NOT NULL default '' ) ENGINE=InnoDB {$sTableCharset}";
00561         if ( ( $oDB->execute( $sQ ) ) !== false ) {
00562             $blDone = true;
00563             $oDB->execute( "TRUNCATE TABLE {$sHeapTable}" );
00564         }
00565 
00566         return $blDone;
00567     }
00568 
00576     protected function _getCatAdd( $aChosenCat )
00577     {
00578         $sCatAdd = null;
00579         if ( is_array( $aChosenCat ) && count( $aChosenCat ) ) {
00580             $oDB = oxDb::getDb();
00581             $sCatAdd = " and ( ";
00582             $blSep = false;
00583             foreach ( $aChosenCat as $sCat ) {
00584                 if ( $blSep ) {
00585                     $sCatAdd .= " or ";
00586                 }
00587                 $sCatAdd .= "oxobject2category.oxcatnid = ".$oDB->quote( $sCat );
00588                 $blSep = true;
00589             }
00590             $sCatAdd .= ")";
00591         }
00592         return $sCatAdd;
00593     }
00594 
00603     protected function _insertArticles( $sHeapTable, $sCatAdd )
00604     {
00605         $oDB = oxDb::getDb();
00606 
00607         $iExpLang = oxConfig::getParameter( "iExportLanguage" );
00608         if (!isset($iExpLang)) {
00609             $iExpLang = oxSession::getVar( "iExportLanguage" );
00610         }
00611 
00612         $oArticle = oxNew( 'oxarticle' );
00613         $oArticle->setLanguage( $iExpLang );
00614 
00615         $sO2CView = getViewName( 'oxobject2category', $iExpLang );
00616         $sArticleTable = getViewName( "oxarticles", $iExpLang );
00617 
00618         $sSelect  = "insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where ";
00619         $sSelect .= $oArticle->getSqlActiveSnippet();
00620 
00621         if ( ! oxConfig::getParameter( "blExportVars" ) ) {
00622             $sSelect .= " and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' ";
00623         } else {
00624             $sSelect .= " and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) ";
00625         }
00626 
00627         $sSearchString = oxConfig::getParameter( "search" );
00628         if ( isset( $sSearchString ) ) {
00629             $sSelect .= "and ( {$sArticleTable}.OXTITLE like ".$oDB->quote( "%{$sSearchString}%" );
00630             $sSelect .= " or {$sArticleTable}.OXSHORTDESC like ".$oDB->quote( "%$sSearchString%" );
00631             $sSelect .= " or {$sArticleTable}.oxsearchkeys like ".$oDB->quote( "%$sSearchString%" ) ." ) ";
00632         }
00633 
00634         if ( $sCatAdd ) {
00635             $sSelect .= $sCatAdd;
00636         }
00637 
00638             if ( !$sCatAdd ) {
00639                 $sShopID = $this->getConfig()->getShopId();
00640                 $sSelect .= " and {$sArticleTable}.oxshopid = '$sShopID' ";
00641             }
00642 
00643         // add minimum stock value
00644         if ( $this->getConfig()->getConfigParam( 'blUseStock' ) && ( $dMinStock = oxConfig::getParameter( "sExportMinStock" ) ) ) {
00645             $dMinStock = str_replace( array( ";", " ", "/", "'"), "", $dMinStock );
00646             $sSelect .= " and {$sArticleTable}.oxstock >= ".$oDB->quote( $dMinStock );
00647         }
00648 
00649         $sSelect .= " group by {$sArticleTable}.oxid";
00650 
00651         return $oDB->execute( $sSelect ) ? true : false;
00652     }
00653 
00661     protected function _removeParentArticles( $sHeapTable )
00662     {
00663         if ( !( oxConfig::getParameter( "blExportMainVars" ) ) ) {
00664 
00665             $oDB = oxDb::getDb();
00666             $sArticleTable = getViewName('oxarticles');
00667 
00668             // we need to remove again parent articles so that we only have the variants itself
00669             $sQ = "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where
00670                           $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid";
00671 
00672             $oRs = $oDB->execute( $sQ );
00673             $sDel = "delete from $sHeapTable where oxid in ( ";
00674             $blSep = false;
00675             if ($oRs != false && $oRs->recordCount() > 0) {
00676                 while ( !$oRs->EOF ) {
00677                     if ( $blSep ) {
00678                         $sDel .= ",";
00679                     }
00680                     $sDel .= $oDB->quote( $oRs->fields[0] );
00681                     $blSep = true;
00682                     $oRs->moveNext();
00683                 }
00684             }
00685             $sDel .= " )";
00686             $oDB->execute( $sDel );
00687         }
00688     }
00689 
00696     protected function _setSessionParams()
00697     {
00698         // reset it from session
00699         oxSession::deleteVar( "sExportDelCost" );
00700         $dDelCost = oxConfig::getParameter( "sExportDelCost");
00701         if ( isset( $dDelCost ) ) {
00702             $dDelCost = str_replace( array( ";", " ", "/", "'"), "", $dDelCost );
00703             $dDelCost = str_replace( ",", ".", $dDelCost );
00704             oxSession::setVar( "sExportDelCost", $dDelCost );
00705         }
00706 
00707         oxSession::deleteVar( "sExportMinPrice" );
00708         $dMinPrice = oxConfig::getParameter( "sExportMinPrice" );
00709         if ( isset( $dMinPrice ) ) {
00710             $dMinPrice = str_replace( array( ";", " ", "/", "'"), "", $dMinPrice);
00711             $dMinPrice = str_replace( ",", ".", $dMinPrice);
00712             oxSession::setVar( "sExportMinPrice", $dMinPrice);
00713         }
00714 
00715         // #827
00716         oxSession::deleteVar( "sExportCampaign" );
00717         $sCampaign = oxConfig::getParameter( "sExportCampaign" );
00718         if ( isset( $sCampaign ) ) {
00719             $sCampaign = str_replace( array( ";", " ", "/", "'"), "", $sCampaign );
00720             oxSession::setVar( "sExportCampaign", $sCampaign );
00721         }
00722 
00723         // reset it from session
00724         oxSession::deleteVar("blAppendCatToCampaign" );
00725         // now retrieve it from get or post.
00726         $blAppendCatToCampaign = oxConfig::getParameter( "blAppendCatToCampaign" );
00727         if ( $blAppendCatToCampaign ) {
00728             oxSession::setVar( "blAppendCatToCampaign", $blAppendCatToCampaign );
00729         }
00730 
00731         // reset it from session
00732         oxSession::deleteVar("iExportLanguage" );
00733         oxSession::setVar( "iExportLanguage", oxConfig::getParameter( "iExportLanguage" ) );
00734 
00735         //setting the custom header
00736         oxSession::setVar("sExportCustomHeader", oxConfig::getParameter( "sExportCustomHeader" ));
00737     }
00738 
00744     protected function _loadRootCats()
00745     {
00746         if ( $this->_aCatLvlCache === null ) {
00747             $this->_aCatLvlCache = array();
00748 
00749             $sCatView = getViewName('oxcategories');
00750             $oDb = oxDb::getDb();
00751 
00752             // Load all root cat's == all trees
00753             $sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'";
00754             $oRs = $oDb->execute( $sSQL);
00755             if ( $oRs != false && $oRs->recordCount() > 0 ) {
00756                 while ( !$oRs->EOF ) {
00757                     // now load each tree
00758                     $sSQL = "SELECT s.oxid, s.oxtitle,
00759                              s.oxparentid, count( * ) AS LEVEL FROM $sCatView v,
00760                              $sCatView s WHERE s.oxrootid = '".$oRs->fields[0]."' and
00761                              v.oxrootid='".$oRs->fields[0]."' and s.oxleft BETWEEN
00762                              v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
00763 
00764                     $oRs2 = $oDb->Execute( $sSQL );
00765                     if ( $oRs2 != false && $oRs2->recordCount() > 0 ) {
00766                         while ( !$oRs2->EOF ) {
00767                             // store it
00768                             $oCat = new OxStdClass();
00769                             $oCat->_sOXID     = $oRs2->fields[0];
00770                             $oCat->oxtitle    = $oRs2->fields[1];
00771                             $oCat->oxparentid = $oRs2->fields[2];
00772                             $oCat->ilevel     = $oRs2->fields[3];
00773                             $this->_aCatLvlCache[$oCat->_sOXID] = $oCat;
00774 
00775                             $oRs2->moveNext();
00776                         }
00777                     }
00778                     $oRs->moveNext();
00779                 }
00780             }
00781         }
00782 
00783         return $this->_aCatLvlCache;
00784     }
00785 
00793     protected function _findDeepestCatPath( $oArticle )
00794     {
00795         $sRet = "";
00796 
00797         // find deepest
00798         $aIds = $oArticle->getCategoryIds();
00799         if ( is_array( $aIds ) && count( $aIds ) ) {
00800             if ( $aCatLvlCache = $this->_loadRootCats() ) {
00801                 $sIdMax  = null;
00802                 $dMaxLvl = 0;
00803                 foreach ( $aIds as $sCatId ) {
00804                     if ( $dMaxLvl < $aCatLvlCache[$sCatId]->ilevel ) {
00805                         $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
00806                         $sIdMax  = $sCatId;
00807                         $sRet    = $aCatLvlCache[$sCatId]->oxtitle;
00808                     }
00809                 }
00810 
00811                 // endless
00812                 for ( ;; ) {
00813                     if ( !isset( $aCatLvlCache[$sIdMax]->oxparentid ) || $aCatLvlCache[$sIdMax]->oxparentid == "oxrootid" ) {
00814                         break;
00815                     }
00816                     $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
00817                     $sRet = $aCatLvlCache[$sIdMax]->oxtitle."/".$sRet;
00818                 }
00819             }
00820         }
00821         return $sRet;
00822     }
00823 
00833     protected function _initArticle( $sHeapTable, $iCnt, & $blContinue )
00834     {
00835 
00836 
00837         $oRs = oxDb::getDb()->selectLimit( "select oxid from $sHeapTable", 1, $iCnt );
00838         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00839             $oArticle = oxNew( 'oxarticle' );
00840             $oArticle->setLoadParentData( true );
00841 
00842             $oArticle->setLanguage( oxSession::getVar( "iExportLanguage" ) );
00843 
00844             if ( $oArticle->load( $oRs->fields[0] ) ) {
00845                 // if article exists, do not stop export
00846                 $blContinue = true;
00847                 // check price
00848                 $dMinPrice = oxConfig::getParameter( "sExportMinPrice" );
00849                 if ( !isset( $dMinPrice ) || ( isset( $dMinPrice ) && ( $oArticle->getPrice()->getBruttoPrice() >= $dMinPrice ) ) ) {
00850 
00851                     //Saulius: variant title added
00852                     $sTitle = $oArticle->oxarticles__oxvarselect->value ? " " .$oArticle->oxarticles__oxvarselect->value : "";
00853                     $oArticle->oxarticles__oxtitle->setValue( $oArticle->oxarticles__oxtitle->value . $sTitle );
00854 
00855 
00856                     return $oArticle;
00857                 }
00858             }
00859         }
00860     }
00861 
00869     protected function _setCampaignDetailLink( $oArticle )
00870     {
00871         // #827
00872         if ( $sCampaign = oxConfig::getParameter( "sExportCampaign" ) ) {
00873             // modify detaillink
00874             //#1166R - pangora - campaign
00875             $oArticle->appendLink( "campaign={$sCampaign}" );
00876 
00877             if ( oxConfig::getParameter( "blAppendCatToCampaign") &&
00878                  ( $sCat = $this->getCategoryString( $oArticle ) ) ) {
00879                 $oArticle->appendLink( "/$sCat" );
00880             }
00881         }
00882         return $oArticle;
00883     }
00884 
00890     public function getViewId()
00891     {
00892         return 'dyn_interface';
00893     }
00894 }
00895