OXID eShop CE  4.9.10
 All Classes Files Functions Variables Pages
oxuserbasketitem.php
Go to the documentation of this file.
1 <?php
2 
8 class oxUserBasketItem extends oxBase
9 {
10 
16  protected $_sClassName = 'oxuserbasketitem';
17 
23  protected $_oArticle = null;
24 
30  protected $_blParentBuyable = false;
31 
37  protected $_aSelList = null;
38 
44  protected $_aPersParam = null;
45 
49  public function __construct()
50  {
51  $this->setVariantParentBuyable($this->getConfig()->getConfigParam('blVariantParentBuyable'));
53  $this->init('oxuserbasketitems');
54  }
55 
61  public function setVariantParentBuyable($blBuyable = false)
62  {
63  $this->_blParentBuyable = $blBuyable;
64  }
65 
75  public function getArticle($sItemKey)
76  {
77  if (!$this->oxuserbasketitems__oxartid->value) {
78  //this exception may not be caught, anyhow this is a critical exception
79  $oEx = oxNew('oxArticleException');
80  $oEx->setMessage('EXCEPTION_ARTICLE_NOPRODUCTID');
81  throw $oEx;
82  }
83 
84  if ($this->_oArticle === null) {
85 
86  $this->_oArticle = oxNew('oxarticle');
87 
88  // performance
89  /* removed due to #4178
90  if ( $this->_blParentBuyable ) {
91  $this->_oArticle->setNoVariantLoading( true );
92  }
93  */
94 
95  if (!$this->_oArticle->load($this->oxuserbasketitems__oxartid->value)) {
96  return false;
97  }
98 
99  $aSelList = $this->getSelList();
100  if (($aSelectlist = $this->_oArticle->getSelectLists()) && is_array($aSelList)) {
101  foreach ($aSelList as $iKey => $iSel) {
102 
103  if (isset($aSelectlist[$iKey][$iSel])) {
104  // cloning select list information
105  $aSelectlist[$iKey][$iSel] = clone $aSelectlist[$iKey][$iSel];
106  $aSelectlist[$iKey][$iSel]->selected = 1;
107  }
108  }
109  $this->_oArticle->setSelectlist($aSelectlist);
110  }
111 
112  // generating item key
113  $this->_oArticle->setItemKey($sItemKey);
114  }
115 
116  return $this->_oArticle;
117 
118  }
119 
125  public function __sleep()
126  {
127  $aRet = array();
128  foreach (get_object_vars($this) as $sKey => $sVar) {
129  if ($sKey != '_oArticle') {
130  $aRet[] = $sKey;
131  }
132  }
133 
134  return $aRet;
135  }
136 
142  public function getSelList()
143  {
144  if ($this->_aSelList == null && $this->oxuserbasketitems__oxsellist->value) {
145  $this->_aSelList = unserialize($this->oxuserbasketitems__oxsellist->value);
146  }
147 
148  return $this->_aSelList;
149  }
150 
156  public function setSelList($aSelList)
157  {
158  $this->oxuserbasketitems__oxsellist = new oxField(serialize($aSelList), oxField::T_RAW);
159  }
160 
166  public function getPersParams()
167  {
168  if ($this->_aPersParam == null && $this->oxuserbasketitems__oxpersparam->value) {
169  $this->_aPersParam = unserialize($this->oxuserbasketitems__oxpersparam->value);
170  }
171 
172  return $this->_aPersParam;
173  }
174 
180  public function setPersParams($sPersParams)
181  {
182  $this->oxuserbasketitems__oxpersparam = new oxField(serialize($sPersParams), oxField::T_RAW);
183  }
184 
194  protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
195  {
196  if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName)
197  || 'oxpersparam' === strtolower($sFieldName) || 'oxuserbasketitems__oxpersparam' === strtolower($sFieldName)
198  ) {
199  $iDataType = oxField::T_RAW;
200  }
201 
202  return parent::_setFieldData($sFieldName, $sValue, $iDataType);
203  }
204 }