OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
actions_article_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_blAllowExtColumns = true;
14 
20  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
21  array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
22  array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
23  array( 'oxean', 'oxarticles', 1, 0, 0 ),
24  array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
25  array( 'oxprice', 'oxarticles', 0, 0, 0 ),
26  array( 'oxstock', 'oxarticles', 0, 0, 0 ),
27  array( 'oxid', 'oxarticles', 0, 0, 1 )
28  )
29  );
30 
36  protected function _getQuery()
37  {
38  $myConfig = $this->getConfig();
39  $oDb = oxDb::getDb();
40  $sArticleTable = $this->_getViewName( 'oxarticles' );
41  $sO2CView = $this->_getViewName( 'oxobject2category' );
42 
43  $sSelId = oxConfig::getParameter( 'oxid' );
44  $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
45 
46  // category selected or not ?
47  if ( !$sSelId ) {
48  $sQAdd = " from $sArticleTable where 1 ";
49  $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
50  } else {
51  // selected category ?
52  if ( $sSynchSelId ) {
53  $sQAdd = " from $sO2CView as oxobject2category left join $sArticleTable on ";
54  $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
55  $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
56  }
57  }
58  // #1513C/#1826C - skip references, to not existing articles
59  $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
60 
61  // skipping self from list
62  $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
63 
64  return $sQAdd;
65  }
66 
74  protected function _addFilter( $sQ )
75  {
76  $sArtTable = $this->_getViewName('oxarticles');
77  $sQ = parent::_addFilter( $sQ );
78 
79  // display variants or not ?
80  $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
81  return $sQ;
82  }
83 
89  public function removeActionArticle()
90  {
91  $sActionId = oxConfig::getParameter( 'oxid');
92  //$sActionId = $this->getConfig()->getConfigParam( 'oxid' );
93 
94  $oDb = oxDb::getDb();
95 
96  $oDb->Execute(
97  'delete from oxobject2action '
98  . 'where oxactionid='.$oDb->quote($sActionId)
99  . ' and oxclass = "oxarticle"'
100  );
101  }
102 
108  public function setActionArticle()
109  {
110  $sArticleId = oxConfig::getParameter( 'oxarticleid' );
111  $sActionId = oxConfig::getParameter( 'oxid' );
112  $oDb = oxDb::getDb();
113 
114  $oDb->Execute(
115  'delete from oxobject2action '
116  . 'where oxactionid='.$oDb->quote($sActionId)
117  . ' and oxclass = "oxarticle"'
118  );
119 
120  $oObject2Promotion = oxNew( "oxbase" );
121  $oObject2Promotion->init( 'oxobject2action' );
122  $oObject2Promotion->oxobject2action__oxactionid = new oxField( $sActionId );
123  $oObject2Promotion->oxobject2action__oxobjectid = new oxField( $sArticleId );
124  $oObject2Promotion->oxobject2action__oxclass = new oxField( "oxarticle" );
125  $oObject2Promotion->save();
126  }
127 }