OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
article_bundle_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  $sView = $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  $sVariantsSqlSnippet = $blVariantsSelectionParameter ? $sSqlIfTrue : $sSqlIfFalse;
59 
60  $sQAdd = " from {$sView} as oxobject2category left join {$sArticleTable} on {$sVariantsSqlSnippet}" .
61  " where oxobject2category.oxcatnid = " . $oDb->quote($sSelId) . " ";
62  }
63  }
64  // #1513C/#1826C - skip references, to not existing articles
65  $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
66 
67  // skipping self from list
68  $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote($sSynchSelId) . " ";
69 
70  return $sQAdd;
71  }
72 
80  protected function _addFilter($sQ)
81  {
82  $sArtTable = $this->_getViewName('oxarticles');
83  $sQ = parent::_addFilter($sQ);
84 
85  // display variants or not ?
86  $sQ .= $this->getConfig()->getConfigParam('blVariantsSelection') ? ' group by ' . $sArtTable . '.oxid ' : '';
87 
88  return $sQ;
89  }
90 
94  public function removeArticleBundle()
95  {
96  $oDb = oxDb::getDb();
97  $sQuotedChosenArt = $oDb->quote(oxRegistry::getConfig()->getRequestParameter('oxid'));
98 
99  $sQ = "update oxarticles set oxarticles.oxbundleid = '' where oxarticles.oxid = {$sQuotedChosenArt} ";
100  $oDb->Execute($sQ);
101  }
102 
106  public function addArticleBundle()
107  {
108  $oDb = oxDb::getDb();
109  $sQuotedChosenArt = $oDb->quote(oxRegistry::getConfig()->getRequestParameter('oxbundleid'));
110  $sQuotedOxId = $oDb->quote(oxRegistry::getConfig()->getRequestParameter('oxid'));
111 
112  $sQ = "update oxarticles set oxarticles.oxbundleid = {$sQuotedChosenArt} " .
113  "where oxarticles.oxid = {$sQuotedOxId} ";
114  $oDb->Execute($sQ);
115  }
116 }