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