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