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 $sManufacturerId = oxConfig::getParameter( 'oxid' );
00040 $sSynchManufacturerId = oxConfig::getParameter( 'synchoxid' );
00041
00042
00043 if ( !$sManufacturerId ) {
00044
00045 $sQAdd = ' from '.$sArtTable.' where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and 1 ';
00046 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' ) ?'':" and $sArtTable.oxparentid = '' and $sArtTable.oxmanufacturerid != '$sSynchManufacturerId' ";
00047 } else {
00048
00049 if ( $sSynchManufacturerId && $sSynchManufacturerId != $sManufacturerId ) {
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 = "'.$sManufacturerId.'" and '.$sArtTable.'.oxmanufacturerid != "'. $sSynchManufacturerId .'" ';
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00054 } else {
00055 $sQAdd = " from $sArtTable where $sArtTable.oxmanufacturerid = '$sManufacturerId' ";
00056 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00057 }
00058 }
00059
00060 return $sQAdd;
00061 }
00062
00070 protected function _getDataQuery( $sQ )
00071 {
00072 $sArtTable = getViewName('oxarticles');
00073 $sQ = parent::_getDataQuery( $sQ );
00074
00075
00076 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00077 return $sQ;
00078 }
00079
00085 public function removeManufacturer()
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 oxmanufacturerid = null where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aRemoveArt ) ).") ";
00097 oxDb::getDb()->Execute( $sSelect);
00098
00099 $this->resetCounter( "manufacturerArticle", oxConfig::getParameter( 'oxid' ) );
00100 }
00101 }
00102
00108 public function addManufacturer()
00109 {
00110 $myConfig = $this->getConfig();
00111
00112 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00113 $soxId = oxConfig::getParameter( 'synchoxid' );
00114
00115 if ( oxConfig::getParameter( 'all' ) ) {
00116 $sArtTable = getViewName( 'oxarticles' );
00117 $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00118 }
00119
00120 if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00121 $sSelect = "update oxarticles set oxmanufacturerid = '$soxId' where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aAddArticle ) )." )";
00122
00123 oxDb::getDb()->Execute( $sSelect);
00124 $this->resetCounter( "manufacturerArticle", $soxId );
00125 }
00126 }
00127
00134 protected function _getQueryCols()
00135 {
00136 $myConfig = $this->getConfig();
00137 $sLangTag = oxLang::getInstance()->getLanguageTag();
00138
00139 $sQ = '';
00140 $blSep = false;
00141 $aVisiblecols = $this->_getVisibleColNames();
00142 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00143 if ( $blSep )
00144 $sQ .= ', ';
00145 $sViewTable = getViewName( $aCol[1] );
00146
00147 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00148 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00149 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00150 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00151 } else {
00152 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00153 }
00154 $blSep = true;
00155 }
00156
00157 $aIdentCols = $this->_getIdentColNames();
00158 foreach ( $aIdentCols as $iCnt => $aCol ) {
00159 if ( $blSep )
00160 $sQ .= ', ';
00161
00162
00163 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00164 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00165 }
00166
00167 return " $sQ ";
00168 }
00169
00170 }