Go to the documentation of this file.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 );
00016 class ajaxComponent extends ajaxListComponent
00017 {
00023 protected $_blAllowExtColumns = true;
00024
00030 protected function _getQuery()
00031 {
00032 $myConfig = $this->getConfig();
00033 $oDb = oxDb::getDb();
00034 $sArticleTable = $this->_getViewName( 'oxarticles' );
00035 $sO2CView = $this->_getViewName( 'oxobject2category' );
00036
00037 $sSelId = oxConfig::getParameter( 'oxid' );
00038 $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00039
00040
00041 if ( !$sSelId ) {
00042 $sQAdd = " from $sArticleTable where 1 ";
00043 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00044 } else {
00045
00046 if ( $sSynchSelId ) {
00047 $sQAdd = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00048 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00049 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00050 }
00051 }
00052
00053 $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00054
00055
00056 $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
00057
00058 return $sQAdd;
00059 }
00060
00068 protected function _addFilter( $sQ )
00069 {
00070 $sArtTable = $this->_getViewName('oxarticles');
00071 $sQ = parent::_addFilter( $sQ );
00072
00073
00074 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00075 return $sQ;
00076 }
00077
00083 public function removeactionarticle()
00084 {
00085 $sActionId = oxConfig::getParameter( 'oxid');
00086 $oDb = oxDb::getDb();
00087
00088 $oDb->Execute(
00089 'delete from oxobject2action '
00090 . 'where oxactionid='.$oDb->quote($sActionId)
00091 . ' and oxclass = "oxarticle"'
00092 );
00093 }
00094
00100 public function setactionarticle()
00101 {
00102 $sArticleId = oxConfig::getParameter( 'oxarticleid' );
00103 $sActionId = oxConfig::getParameter( 'oxid' );
00104 $oDb = oxDb::getDb();
00105
00106 $oDb->Execute(
00107 'delete from oxobject2action '
00108 . 'where oxactionid='.$oDb->quote($sActionId)
00109 . ' and oxclass = "oxarticle"'
00110 );
00111
00112 $oObject2Promotion = oxNew( "oxbase" );
00113 $oObject2Promotion->init( 'oxobject2action' );
00114 $oObject2Promotion->oxobject2action__oxactionid = new oxField( $sActionId );
00115 $oObject2Promotion->oxobject2action__oxobjectid = new oxField( $sArticleId );
00116 $oObject2Promotion->oxobject2action__oxclass = new oxField( "oxarticle" );
00117 $oObject2Promotion->save();
00118 }
00119 }