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