manufacturer_main.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( '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         // looking for table/view
00036         $sArtTable = getViewName('oxarticles');
00037         $sO2CView  = getViewName('oxobject2category');
00038 
00039         $sManufacturerId      = oxConfig::getParameter( 'oxid' );
00040         $sSynchManufacturerId = oxConfig::getParameter( 'synchoxid' );
00041 
00042         // Manufacturer selected or not ?
00043         if ( !$sManufacturerId ) {
00044             // dodger performance
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             // selected category ?
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 
00068     public function removeManufacturer()
00069     {
00070         $myConfig   = $this->getConfig();
00071         $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00072 
00073         if ( oxConfig::getParameter( 'all' ) ) {
00074             $sArtTable = getViewName( 'oxarticles' );
00075             $aRemoveArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00076         }
00077 
00078         if ( is_array(  $aRemoveArt ) ) {
00079             $sSelect = "update oxarticles set oxmanufacturerid = null where oxid in ( '".implode("', '", $aRemoveArt )."') ";
00080             oxDb::getDb()->Execute( $sSelect);
00081 
00082             $this->resetCounter( "manufacturerArticle", oxConfig::getParameter( 'oxid' ) );
00083         }
00084     }
00085 
00091     public function addManufacturer()
00092     {
00093         $myConfig = $this->getConfig();
00094 
00095         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00096         $soxId       = oxConfig::getParameter( 'synchoxid' );
00097 
00098         if ( oxConfig::getParameter( 'all' ) ) {
00099             $sArtTable = getViewName( 'oxarticles' );
00100             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00101         }
00102 
00103         if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00104             $sSelect = "update oxarticles set oxmanufacturerid = '$soxId' where oxid in ( '".implode("', '", $aAddArticle )."' )";
00105 
00106             oxDb::getDb()->Execute( $sSelect);
00107             $this->resetCounter( "manufacturerArticle", $soxId );
00108         }
00109     }
00110 
00117     protected function _getQueryCols()
00118     {
00119         $myConfig = $this->getConfig();
00120         $sLangTag = oxLang::getInstance()->getLanguageTag();
00121 
00122         $sQ = '';
00123         $blSep = false;
00124         $aVisiblecols = $this->_getVisibleColNames();
00125         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00126             if ( $blSep )
00127                 $sQ .= ', ';
00128             $sViewTable = getViewName( $aCol[1] );
00129             // multilanguage
00130             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00131             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00132                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00133                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00134             } else {
00135                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00136             }
00137             $blSep = true;
00138         }
00139 
00140         $aIdentCols = $this->_getIdentColNames();
00141         foreach ( $aIdentCols as $iCnt => $aCol ) {
00142             if ( $blSep )
00143                 $sQ .= ', ';
00144 
00145             // multilanguage
00146             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00147             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00148         }
00149 
00150         return " $sQ ";
00151     }
00152 
00153 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5