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 $_blAllowExtColumns = true;
00034
00040 protected function _getQuery()
00041 {
00042 $myConfig = $this->getConfig();
00043
00044
00045 $sArtTable = $this->_getViewName('oxarticles');
00046 $sO2CView = $this->_getViewName('oxobject2category');
00047 $oDb = oxDb::getDb();
00048 $sVendorId = oxConfig::getParameter( 'oxid' );
00049 $sSynchVendorId = oxConfig::getParameter( 'synchoxid' );
00050
00051
00052 if ( !$sVendorId ) {
00053
00054 $sQAdd = ' from '.$sArtTable.' where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and 1 ';
00055 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' ) ?'':" and $sArtTable.oxparentid = '' and $sArtTable.oxvendorid != ".$oDb->quote( $sSynchVendorId );
00056 } else {
00057
00058 if ( $sSynchVendorId && $sSynchVendorId != $sVendorId ) {
00059 $sQAdd = " from $sO2CView left join $sArtTable on ";
00060 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid = $sO2CView.oxobjectid or $sArtTable.oxparentid = oxobject2category.oxobjectid )":" $sArtTable.oxid = $sO2CView.oxobjectid ";
00061 $sQAdd .= 'where '.$sArtTable.'.oxshopid="'.$myConfig->getShopId().'" and '.$sO2CView.'.oxcatnid = '.$oDb->quote( $sVendorId ).' and '.$sArtTable.'.oxvendorid != '. $oDb->quote( $sSynchVendorId );
00062 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00063 } else {
00064 $sQAdd = " from $sArtTable where $sArtTable.oxvendorid = ".$oDb->quote( $sVendorId );
00065 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00066 }
00067 }
00068
00069 return $sQAdd;
00070 }
00071
00079 protected function _addFilter( $sQ )
00080 {
00081 $sArtTable = $this->_getViewName('oxarticles');
00082 $sQ = parent::_addFilter( $sQ );
00083
00084
00085 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00086 return $sQ;
00087 }
00088
00094 public function removevendor()
00095 {
00096 $myConfig = $this->getConfig();
00097 $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00098
00099 if ( oxConfig::getParameter( 'all' ) ) {
00100 $sArtTable = $this->_getViewName( 'oxarticles' );
00101 $aRemoveArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00102 }
00103
00104 if ( is_array( $aRemoveArt ) ) {
00105 $sSelect = "update oxarticles set oxvendorid = null where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aRemoveArt ) ) . ") ";
00106 oxDb::getDb()->Execute( $sSelect);
00107 $this->resetCounter( "vendorArticle", oxConfig::getParameter( 'oxid' ) );
00108 }
00109 }
00110
00116 public function addvendor()
00117 {
00118 $myConfig = $this->getConfig();
00119
00120 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00121 $soxId = oxConfig::getParameter( 'synchoxid' );
00122
00123 if ( oxConfig::getParameter( 'all' ) ) {
00124 $sArtTable = $this->_getViewName( 'oxarticles' );
00125 $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00126 }
00127
00128 if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00129 $oDb = oxDb::getDb();
00130 $sSelect = "update oxarticles set oxvendorid = ".$oDb->quote( $soxId )." where oxid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aAddArticle ) )." )";
00131
00132 $oDb->Execute( $sSelect);
00133 $this->resetCounter( "vendorArticle", $soxId );
00134 }
00135 }
00136 }