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( 'oxid', 'oxarticles', 0, 0, 1 )
00020 )
00021 );
00022
00026 class ajaxComponent extends ajaxListComponent
00027 {
00033 protected function _getQuery()
00034 {
00035 $myConfig = $this->getConfig();
00036
00037
00038 $sArtTable = getViewName('oxarticles');
00039 $sO2CView = getViewName('oxobject2category');
00040
00041 $sManufacturerId = oxConfig::getParameter( 'oxid' );
00042 $sSynchManufacturerId = oxConfig::getParameter( 'synchoxid' );
00043
00044
00045 if ( !$sManufacturerId ) {
00046
00047 $sQAdd = ' from '.$sArtTable.' where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and 1 ';
00048 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' ) ?'':" and $sArtTable.oxparentid = '' and $sArtTable.oxmanufacturerid != '$sSynchManufacturerId' ";
00049 } else {
00050
00051 if ( $sSynchManufacturerId && $sSynchManufacturerId != $sManufacturerId ) {
00052 $sQAdd = " from $sO2CView left join $sArtTable on ";
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid = $sO2CView.oxobjectid or $sArtTable.oxparentid = oxobject2category.oxobjectid )":" $sArtTable.oxid = $sO2CView.oxobjectid ";
00054 $sQAdd .= 'where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and '.$sO2CView.'.oxcatnid = "'.$sManufacturerId.'" and '.$sArtTable.'.oxmanufacturerid != "'. $sSynchManufacturerId .'" ';
00055 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00056 } else {
00057 $sQAdd = " from $sArtTable where $sArtTable.oxmanufacturerid = '$sManufacturerId' ";
00058 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00059 }
00060 }
00061
00062 return $sQAdd;
00063 }
00064
00072 protected function _addFilter( $sQ )
00073 {
00074 $sArtTable = getViewName('oxarticles');
00075 $sQ = parent::_addFilter( $sQ );
00076
00077
00078 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00079 return $sQ;
00080 }
00081
00087 public function removeManufacturer()
00088 {
00089 $myConfig = $this->getConfig();
00090 $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00091
00092 if ( oxConfig::getParameter( 'all' ) ) {
00093 $sArtTable = getViewName( 'oxarticles' );
00094 $aRemoveArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00095 }
00096
00097 if ( is_array( $aRemoveArt ) ) {
00098 $sSelect = "update oxarticles set oxmanufacturerid = null where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aRemoveArt ) ).") ";
00099 oxDb::getDb()->Execute( $sSelect);
00100
00101 $this->resetCounter( "manufacturerArticle", oxConfig::getParameter( 'oxid' ) );
00102 }
00103 }
00104
00110 public function addManufacturer()
00111 {
00112 $myConfig = $this->getConfig();
00113
00114 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00115 $soxId = oxConfig::getParameter( 'synchoxid' );
00116
00117 if ( oxConfig::getParameter( 'all' ) ) {
00118 $sArtTable = getViewName( 'oxarticles' );
00119 $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00120 }
00121
00122 if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00123 $sSelect = "update oxarticles set oxmanufacturerid = '$soxId' where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aAddArticle ) )." )";
00124
00125 oxDb::getDb()->Execute( $sSelect);
00126 $this->resetCounter( "manufacturerArticle", $soxId );
00127 }
00128 }
00129
00136 protected function _getQueryCols()
00137 {
00138 $myConfig = $this->getConfig();
00139 $sLangTag = oxLang::getInstance()->getLanguageTag();
00140
00141 $sQ = '';
00142 $blSep = false;
00143 $aVisiblecols = $this->_getVisibleColNames();
00144 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00145 if ( $blSep )
00146 $sQ .= ', ';
00147 $sViewTable = getViewName( $aCol[1] );
00148
00149 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00150 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00151 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00152 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00153 } else {
00154 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00155 }
00156 $blSep = true;
00157 }
00158
00159 $aIdentCols = $this->_getIdentColNames();
00160 foreach ( $aIdentCols as $iCnt => $aCol ) {
00161 if ( $blSep )
00162 $sQ .= ', ';
00163
00164
00165 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00166 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00167 }
00168
00169 return " $sQ ";
00170 }
00171
00172 }