vendor_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         $sVendorId      = oxConfig::getParameter( 'oxid' );
00040         $sSynchVendorId = oxConfig::getParameter( 'synchoxid' );
00041 
00042         // vendor selected or not ?
00043         if ( !$sVendorId ) {
00044             // dodger performance
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             // selected category ?
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 
00068     public function removevendor()
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 oxvendorid = null where oxid in ( '".implode("', '", $aRemoveArt )."') ";
00080             oxDb::getDb()->Execute( $sSelect);
00081 
00082 
00083                 oxUtilsCount::getInstance()->resetVendorArticleCount( oxConfig::getParameter( 'oxid' ) );
00084         }
00085     }
00086 
00092     public function addvendor()
00093     {
00094         $myConfig = $this->getConfig();
00095 
00096         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00097         $soxId       = oxConfig::getParameter( 'synchoxid' );
00098 
00099         if ( oxConfig::getParameter( 'all' ) ) {
00100             $sArtTable = getViewName( 'oxarticles' );
00101             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00102         }
00103 
00104         if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00105             $sSelect = "update oxarticles set oxvendorid = '$soxId' where oxid in ( '".implode("', '", $aAddArticle )."' )";
00106 
00107             oxDb::getDb()->Execute( $sSelect);
00108 
00109 
00110                 oxUtilsCount::getInstance()->resetVendorArticleCount( $soxId );
00111         }
00112     }
00113 
00120     protected function _getQueryCols()
00121     {
00122         $myConfig      = $this->getConfig();
00123         $sQ = '';
00124         $blSep = false;
00125         $aVisiblecols = $this->_getVisibleColNames();
00126         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00127             if ( $blSep )
00128                 $sQ .= ', ';
00129             $sViewTable = getViewName( $aCol[1] );
00130             // multilanguage
00131             $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00132             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00133                 $sVarSelect = "$sViewTable.oxvarselect".oxLang::getInstance()->getLanguageTag();
00134                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00135             } else {
00136                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00137             }
00138             $blSep = true;
00139         }
00140 
00141         $aIdentCols = $this->_getIdentColNames();
00142         foreach ( $aIdentCols as $iCnt => $aCol ) {
00143             if ( $blSep )
00144                 $sQ .= ', ';
00145 
00146             // multilanguage
00147             $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00148             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00149         }
00150 
00151         return " $sQ ";
00152     }
00153 
00154 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5