oxuserbasketitem.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxUserBasketItem extends oxBase
00008 {
00014     protected $_sClassName = 'oxuserbasketitem';
00015 
00021     protected $_oArticle = null;
00022 
00028     protected $_blParentBuyable = false;
00029 
00035     protected $_aSelList = null;
00036 
00042     protected $_aPersParam = null;
00043 
00047     public function __construct()
00048     {
00049         $this->setVariantParentBuyable( $this->getConfig()->getConfigParam( 'blVariantParentBuyable' ) );
00050         parent::__construct();
00051         $this->init( 'oxuserbasketitems' );
00052     }
00053 
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 excpetion 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             if ( $this->_blParentBuyable ) {
00090                 $this->_oArticle->setSkipAbPrice( true );
00091                 // removed due to #4178
00092                 // $this->_oArticle->setNoVariantLoading( true );
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         return $aRet;
00134     }
00135 
00141     public function getSelList()
00142     {
00143         if ( $this->_aSelList == null && $this->oxuserbasketitems__oxsellist->value ) {
00144             $this->_aSelList = unserialize( $this->oxuserbasketitems__oxsellist->value );
00145         }
00146 
00147         return $this->_aSelList;
00148     }
00149 
00157     public function setSelList( $aSelList )
00158     {
00159         $this->oxuserbasketitems__oxsellist = new oxField(serialize( $aSelList ), oxField::T_RAW);
00160     }
00161 
00167     public function getPersParams()
00168     {
00169         if ( $this->_aPersParam == null && $this->oxuserbasketitems__oxpersparam->value ) {
00170             $this->_aPersParam = unserialize( $this->oxuserbasketitems__oxpersparam->value );
00171         }
00172 
00173         return $this->_aPersParam;
00174     }
00175 
00183     public function setPersParams( $sPersParams )
00184     {
00185         $this->oxuserbasketitems__oxpersparam = new oxField(serialize($sPersParams), oxField::T_RAW);
00186     }
00187 
00197     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00198     {
00199         if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName)
00200             || 'oxpersparam' === strtolower($sFieldName) || 'oxuserbasketitems__oxpersparam' === strtolower($sFieldName)) {
00201             $iDataType = oxField::T_RAW;
00202         }
00203         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00204     }
00205 }