00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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 'container2' => array(
00013 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00014 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00015 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00016 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00017 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00018 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00019 array( 'oxitmartid', 'oxdiscount', 0, 0, 1 )
00020 )
00021 );
00022
00026 class ajaxComponent extends ajaxListComponent
00027 {
00033 protected function _getQuery()
00034 {
00035 $myConfig = $this->getConfig();
00036
00037 $sArticleTable = getViewName('oxarticles');
00038 $sCatTable = getViewName('oxcategories');
00039 $sO2CView = getViewName('oxobject2category');
00040 $sDiscTable = getViewName('oxdiscount');
00041
00042 $sOxid = oxConfig::getParameter( 'oxid' );
00043 $sSynchOxid = oxConfig::getParameter( 'synchoxid' );
00044
00045
00046 if ( !$sOxid && $sSynchOxid ) {
00047 $sQAdd = " from $sArticleTable where 1 ";
00048 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':"and $sArticleTable.oxparentid = '' ";
00049 } else {
00050
00051 if ( $sSynchOxid && $sOxid != $sSynchOxid ) {
00052 $sQAdd = " from $sO2CView left join $sArticleTable on ";
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?"($sArticleTable.oxid=$sO2CView.oxobjectid or $sArticleTable.oxparentid=$sO2CView.oxobjectid)":" $sArticleTable.oxid=$sO2CView.oxobjectid ";
00054 $sQAdd .= " where $sO2CView.oxcatnid = '$sOxid' and $sArticleTable.oxid is not null ";
00055
00056
00057 $sId = null;
00058 } else {
00059 $sQAdd = " from $sDiscTable left join $sArticleTable on $sArticleTable.oxid=$sDiscTable.oxitmartid ";
00060 $sQAdd .= " where $sDiscTable.oxid = '$sOxid' and $sDiscTable.oxitmartid != '' ";
00061 }
00062 }
00063
00064 if ( $sSynchOxid && $sSynchOxid != $sOxid) {
00065
00066 $sSubSelect .= " select $sArticleTable.oxid from $sDiscTable, $sArticleTable where $sArticleTable.oxid=$sDiscTable.oxitmartid ";
00067 $sSubSelect .= " and $sDiscTable.oxid = '$sSynchOxid' ";
00068
00069 if ( stristr( $sQAdd, 'where' ) === false )
00070 $sQAdd .= ' where ';
00071 else
00072 $sQAdd .= ' and ';
00073 $sQAdd .= " $sArticleTable.oxid not in ( $sSubSelect ) ";
00074 }
00075
00076 return $sQAdd;
00077 }
00078
00086 protected function _addFilter( $sQ )
00087 {
00088 $sArtTable = getViewName('oxarticles');
00089 $sQ = parent::_addFilter( $sQ );
00090
00091
00092 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00093 return $sQ;
00094 }
00095
00101 public function removediscart()
00102 {
00103 $soxId = oxConfig::getParameter( 'oxid');
00104 $aChosenArt = $this->_getActionIds( 'oxdiscount.oxitmartid' );
00105 if ( is_array( $aChosenArt ) ) {
00106 $sQ = "update oxdiscount set oxitmartid = '' where oxid = ? and oxitmartid = ?";
00107 oxDb::getDb()->execute( $sQ, array( $soxId, reset( $aChosenArt ) ) );
00108 }
00109 }
00110
00116 public function adddiscart()
00117 {
00118 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00119 $soxId = oxConfig::getParameter( 'synchoxid');
00120 if ( $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00121 $sQ = "update oxdiscount set oxitmartid = ? where oxid = ?";
00122 oxDb::getDb()->execute( $sQ, array( reset( $aChosenArt ), $soxId ) );
00123 }
00124 }
00125
00132 protected function _getQueryCols()
00133 {
00134 $myConfig = $this->getConfig();
00135 $sLangTag = oxLang::getInstance()->getLanguageTag();
00136
00137 $sQ = '';
00138 $blSep = false;
00139 $aVisiblecols = $this->_getVisibleColNames();
00140 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00141 if ( $blSep )
00142 $sQ .= ', ';
00143 $sViewTable = getViewName( $aCol[1] );
00144
00145 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00146 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00147 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00148 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00149 } else {
00150 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00151 }
00152 $blSep = true;
00153 }
00154
00155 $aIdentCols = $this->_getIdentColNames();
00156 foreach ( $aIdentCols as $iCnt => $aCol ) {
00157 if ( $blSep )
00158 $sQ .= ', ';
00159
00160
00161 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00162 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00163 }
00164
00165 return " $sQ ";
00166 }
00167
00168 }