article_bundle.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00005                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00006                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00007                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00008                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00009                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00010                                         )
00011                     );
00015 class ajaxComponent extends ajaxListComponent
00016 {
00022     protected function _getQuery()
00023     {
00024         $myConfig      = $this->getConfig();
00025         $oDb           = oxDb::getDb();
00026         $sArticleTable = getViewName( 'oxarticles' );
00027         $sO2CView      = getViewName( 'oxobject2category' );
00028 
00029         $sSelId      = oxConfig::getParameter( 'oxid' );
00030         $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         // category selected or not ?
00033         if ( !$sSelId ) {
00034             $sQAdd  = " from $sArticleTable where 1 ";
00035             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00036         } else {
00037             // selected category ?
00038             if ( $sSynchSelId ) {
00039                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00040                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00041                 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00042             }
00043         }
00044         // #1513C/#1826C - skip references, to not existing articles
00045         $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00046 
00047         // skipping self from list
00048         $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
00049 
00050         return $sQAdd;
00051     }
00052 
00060     protected function _getDataQuery( $sQ )
00061     {
00062         $sArtTable = getViewName('oxarticles');
00063         $sQ = parent::_getDataQuery( $sQ );
00064 
00065         // display variants or not ?
00066         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00067         return $sQ;
00068     }
00069 
00075     public function removearticlebundle()
00076     {
00077         $aChosenArt = oxConfig::getParameter( 'oxid');
00078         $oDb        = oxDb::getDb();
00079 
00080         $sQ = "update oxarticles set oxarticles.oxbundleid = '' where oxarticles.oxid  =  " . $oDb->quote( $aChosenArt ) . " ";
00081         $oDb->Execute( $sQ );
00082     }
00083 
00089     public function addarticlebundle()
00090     {
00091         $sChosenArt = oxConfig::getParameter( 'oxbundleid' );
00092         $soxId      = oxConfig::getParameter( 'oxid' );
00093         $oDb        = oxDb::getDb();
00094 
00095         $sQ = "update oxarticles set oxarticles.oxbundleid =  " . $oDb->quote( $sChosenArt ) . " where oxarticles.oxid  =  " . $oDb->quote( $soxId ) . " ";
00096         $oDb->Execute( $sQ );
00097     }
00104     protected function _getQueryCols()
00105     {
00106         $myConfig = $this->getConfig();
00107         $sLangTag = oxLang::getInstance()->getLanguageTag();
00108 
00109         $sQ = '';
00110         $blSep = false;
00111         $aVisiblecols = $this->_getVisibleColNames();
00112         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00113             if ( $blSep )
00114                 $sQ .= ', ';
00115             $sViewTable = getViewName( $aCol[1] );
00116             // multilanguage
00117             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00118             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00119                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00120                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00121             } else {
00122                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00123             }
00124             $blSep = true;
00125         }
00126 
00127         $aIdentCols = $this->_getIdentColNames();
00128         foreach ( $aIdentCols as $iCnt => $aCol ) {
00129             if ( $blSep )
00130                 $sQ .= ', ';
00131 
00132             // multilanguage
00133             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00134             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00135         }
00136 
00137         return " $sQ ";
00138     }
00139 }

Generated on Tue Sep 29 16:45:12 2009 for OXID eShop CE by  doxygen 1.5.5