Go to the documentation of this file.00001 <?php
00002
00006 class actions_article_ajax extends ajaxListComponent
00007 {
00013 protected $_blAllowExtColumns = true;
00014
00020 protected $_aColumns = array( 'container1' => array(
00021 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00022 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00023 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00024 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00025 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00026 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00027 array( 'oxid', 'oxarticles', 0, 0, 1 )
00028 )
00029 );
00030
00036 protected function _getQuery()
00037 {
00038 $myConfig = $this->getConfig();
00039 $oDb = oxDb::getDb();
00040 $sArticleTable = $this->_getViewName( 'oxarticles' );
00041 $sO2CView = $this->_getViewName( 'oxobject2category' );
00042
00043 $sSelId = oxConfig::getParameter( 'oxid' );
00044 $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00045
00046
00047 if ( !$sSelId ) {
00048 $sQAdd = " from $sArticleTable where 1 ";
00049 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00050 } else {
00051
00052 if ( $sSynchSelId ) {
00053 $sQAdd = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00054 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00055 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00056 }
00057 }
00058
00059 $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00060
00061
00062 $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
00063
00064 return $sQAdd;
00065 }
00066
00074 protected function _addFilter( $sQ )
00075 {
00076 $sArtTable = $this->_getViewName('oxarticles');
00077 $sQ = parent::_addFilter( $sQ );
00078
00079
00080 $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00081 return $sQ;
00082 }
00083
00089 public function removeActionArticle()
00090 {
00091 $sActionId = oxConfig::getParameter( 'oxid');
00092
00093
00094 $oDb = oxDb::getDb();
00095
00096 $oDb->Execute(
00097 'delete from oxobject2action '
00098 . 'where oxactionid='.$oDb->quote($sActionId)
00099 . ' and oxclass = "oxarticle"'
00100 );
00101 }
00102
00108 public function setActionArticle()
00109 {
00110 $sArticleId = oxConfig::getParameter( 'oxarticleid' );
00111 $sActionId = oxConfig::getParameter( 'oxid' );
00112 $oDb = oxDb::getDb();
00113
00114 $oDb->Execute(
00115 'delete from oxobject2action '
00116 . 'where oxactionid='.$oDb->quote($sActionId)
00117 . ' and oxclass = "oxarticle"'
00118 );
00119
00120 $oObject2Promotion = oxNew( "oxbase" );
00121 $oObject2Promotion->init( 'oxobject2action' );
00122 $oObject2Promotion->oxobject2action__oxactionid = new oxField( $sActionId );
00123 $oObject2Promotion->oxobject2action__oxobjectid = new oxField( $sArticleId );
00124 $oObject2Promotion->oxobject2action__oxclass = new oxField( "oxarticle" );
00125 $oObject2Promotion->save();
00126 }
00127 }