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( 'oxprice', 'oxarticles', 0, 0, 0 ),
00008 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00009 array( 'oxid', 'oxarticles', 0, 0, 1 )
00010 ),
00011 'container2' => array(
00012 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00013 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00014 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00015 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00016 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00017 array( 'oxid', 'oxarticles', 0, 0, 1 )
00018 )
00019 );
00020
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031 protected function _getQuery()
00032 {
00033 $myConfig = $this->getConfig();
00034
00035
00036 $sArtTable = getViewName('oxarticles');
00037 $sO2CView = getViewName('oxobject2category');
00038
00039 $sVendorId = oxConfig::getParameter( 'oxid' );
00040 $sSynchVendorId = oxConfig::getParameter( 'synchoxid' );
00041
00042
00043 if ( !$sVendorId ) {
00044
00045 $sQAdd = ' from '.$sArtTable.' where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and 1 ';
00046 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' ) ?'':" and $sArtTable.oxparentid = '' and $sArtTable.oxvendorid != '$sSynchVendorId' ";
00047 } else {
00048
00049 if ( $sSynchVendorId && $sSynchVendorId != $sVendorId ) {
00050 $sQAdd = " from $sO2CView left join $sArtTable on ";
00051 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid = $sO2CView.oxobjectid or $sArtTable.oxparentid = oxobject2category.oxobjectid )":" $sArtTable.oxid = $sO2CView.oxobjectid ";
00052 $sQAdd .= 'where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and '.$sO2CView.'.oxcatnid = "'.$sVendorId.'" and '.$sArtTable.'.oxvendorid != "'. $sSynchVendorId .'" ';
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00054 } else {
00055 $sQAdd = " from $sArtTable where $sArtTable.oxvendorid = '$sVendorId' ";
00056 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00057 }
00058 }
00059
00060 return $sQAdd;
00061 }
00062
00070 protected function _addFilter( $sQ )
00071 {
00072 $sArtTable = getViewName('oxarticles');
00073 $sQ = parent::_addFilter( $sQ );
00074
00075
00076 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00077 return $sQ;
00078 }
00079
00085 public function removevendor()
00086 {
00087 $myConfig = $this->getConfig();
00088 $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00089
00090 if ( oxConfig::getParameter( 'all' ) ) {
00091 $sArtTable = getViewName( 'oxarticles' );
00092 $aRemoveArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00093 }
00094
00095 if ( is_array( $aRemoveArt ) ) {
00096 $sSelect = "update oxarticles set oxvendorid = null where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aRemoveArt ) ) . ") ";
00097 oxDb::getDb()->Execute( $sSelect);
00098 $this->resetCounter( "vendorArticle", oxConfig::getParameter( 'oxid' ) );
00099 }
00100 }
00101
00107 public function addvendor()
00108 {
00109 $myConfig = $this->getConfig();
00110
00111 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00112 $soxId = oxConfig::getParameter( 'synchoxid' );
00113
00114 if ( oxConfig::getParameter( 'all' ) ) {
00115 $sArtTable = getViewName( 'oxarticles' );
00116 $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00117 }
00118
00119 if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00120 $sSelect = "update oxarticles set oxvendorid = '$soxId' where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aAddArticle ) )." )";
00121
00122 oxDb::getDb()->Execute( $sSelect);
00123 $this->resetCounter( "vendorArticle", $soxId );
00124 }
00125 }
00126
00133 protected function _getQueryCols()
00134 {
00135 $myConfig = $this->getConfig();
00136 $sLangTag = oxLang::getInstance()->getLanguageTag();
00137
00138 $sQ = '';
00139 $blSep = false;
00140 $aVisiblecols = $this->_getVisibleColNames();
00141 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00142 if ( $blSep )
00143 $sQ .= ', ';
00144 $sViewTable = getViewName( $aCol[1] );
00145
00146 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00147 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00148 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00149 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00150 } else {
00151 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00152 }
00153 $blSep = true;
00154 }
00155
00156 $aIdentCols = $this->_getIdentColNames();
00157 foreach ( $aIdentCols as $iCnt => $aCol ) {
00158 if ( $blSep )
00159 $sQ .= ', ';
00160
00161
00162 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00163 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00164 }
00165
00166 return " $sQ ";
00167 }
00168
00169 }