OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
article_bundle_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 removeArticleBundle()
90  {
91  $aChosenArt = oxConfig::getParameter( 'oxid');
92  $oDb = oxDb::getDb();
93 
94  $sQ = "update oxarticles set oxarticles.oxbundleid = '' where oxarticles.oxid = " . $oDb->quote( $aChosenArt ) . " ";
95  $oDb->Execute( $sQ );
96  }
97 
103  public function addArticleBundle()
104  {
105  $sChosenArt = oxConfig::getParameter( 'oxbundleid' );
106  $soxId = oxConfig::getParameter( 'oxid' );
107  $oDb = oxDb::getDb();
108 
109  $sQ = "update oxarticles set oxarticles.oxbundleid = " . $oDb->quote( $sChosenArt ) . " where oxarticles.oxid = " . $oDb->quote( $soxId ) . " ";
110  $oDb->Execute( $sQ );
111  }
112 }