oxuserbasketitem.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxUserBasketItem extends oxBase
00009 {
00010 
00016     protected $_sClassName = 'oxuserbasketitem';
00017 
00023     protected $_oArticle = null;
00024 
00030     protected $_blParentBuyable = false;
00031 
00037     protected $_aSelList = null;
00038 
00044     protected $_aPersParam = null;
00045 
00049     public function __construct()
00050     {
00051         $this->setVariantParentBuyable($this->getConfig()->getConfigParam('blVariantParentBuyable'));
00052         parent::__construct();
00053         $this->init('oxuserbasketitems');
00054     }
00055 
00061     public function setVariantParentBuyable($blBuyable = false)
00062     {
00063         $this->_blParentBuyable = $blBuyable;
00064     }
00065 
00075     public function getArticle($sItemKey)
00076     {
00077         if (!$this->oxuserbasketitems__oxartid->value) {
00078             //this exception may not be caught, anyhow this is a critical exception
00079             $oEx = oxNew('oxArticleException');
00080             $oEx->setMessage('EXCEPTION_ARTICLE_NOPRODUCTID');
00081             throw $oEx;
00082         }
00083 
00084         if ($this->_oArticle === null) {
00085 
00086             $this->_oArticle = oxNew('oxarticle');
00087 
00088             // performance
00089             /* removed due to #4178
00090              if ( $this->_blParentBuyable ) {
00091                 $this->_oArticle->setNoVariantLoading( true );
00092             }
00093             */
00094 
00095             if (!$this->_oArticle->load($this->oxuserbasketitems__oxartid->value)) {
00096                 return false;
00097             }
00098 
00099             $aSelList = $this->getSelList();
00100             if (($aSelectlist = $this->_oArticle->getSelectLists()) && is_array($aSelList)) {
00101                 foreach ($aSelList as $iKey => $iSel) {
00102 
00103                     if (isset($aSelectlist[$iKey][$iSel])) {
00104                         // cloning select list information
00105                         $aSelectlist[$iKey][$iSel] = clone $aSelectlist[$iKey][$iSel];
00106                         $aSelectlist[$iKey][$iSel]->selected = 1;
00107                     }
00108                 }
00109                 $this->_oArticle->setSelectlist($aSelectlist);
00110             }
00111 
00112             // generating item key
00113             $this->_oArticle->setItemKey($sItemKey);
00114         }
00115 
00116         return $this->_oArticle;
00117 
00118     }
00119 
00125     public function __sleep()
00126     {
00127         $aRet = array();
00128         foreach (get_object_vars($this) as $sKey => $sVar) {
00129             if ($sKey != '_oArticle') {
00130                 $aRet[] = $sKey;
00131             }
00132         }
00133 
00134         return $aRet;
00135     }
00136 
00142     public function getSelList()
00143     {
00144         if ($this->_aSelList == null && $this->oxuserbasketitems__oxsellist->value) {
00145             $this->_aSelList = unserialize($this->oxuserbasketitems__oxsellist->value);
00146         }
00147 
00148         return $this->_aSelList;
00149     }
00150 
00156     public function setSelList($aSelList)
00157     {
00158         $this->oxuserbasketitems__oxsellist = new oxField(serialize($aSelList), oxField::T_RAW);
00159     }
00160 
00166     public function getPersParams()
00167     {
00168         if ($this->_aPersParam == null && $this->oxuserbasketitems__oxpersparam->value) {
00169             $this->_aPersParam = unserialize($this->oxuserbasketitems__oxpersparam->value);
00170         }
00171 
00172         return $this->_aPersParam;
00173     }
00174 
00180     public function setPersParams($sPersParams)
00181     {
00182         $this->oxuserbasketitems__oxpersparam = new oxField(serialize($sPersParams), oxField::T_RAW);
00183     }
00184 
00194     protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00195     {
00196         if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName)
00197             || 'oxpersparam' === strtolower($sFieldName) || 'oxuserbasketitems__oxpersparam' === strtolower($sFieldName)
00198         ) {
00199             $iDataType = oxField::T_RAW;
00200         }
00201 
00202         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00203     }
00204 }