oxuserbasketitem.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxUserBasketItem extends oxBase
00009 {
00015     protected $_sClassName = 'oxuserbasketitem';
00016 
00022     protected $_oArticle = null;
00023 
00029     protected $_blParentBuyable = false;
00030 
00036     protected $_aSelList = null;
00037 
00041     public function __construct()
00042     {
00043         $this->setVariantParentBuyable( $this->getConfig()->getConfigParam( 'blVariantParentBuyable' ) );
00044         parent::__construct();
00045         $this->init( 'oxuserbasketitems' );
00046     }
00047 
00055     public function setVariantParentBuyable( $blBuyable = false )
00056     {
00057         $this->_blParentBuyable = $blBuyable;
00058     }
00059 
00069     public function getArticle( $sItemKey )
00070     {
00071         if ( !$this->oxuserbasketitems__oxartid->value ) {
00072             //this excpetion may not be caught, anyhow this is a critical exception
00073             $oEx = oxNew( 'oxArticleException' );
00074             $oEx->setMessage( 'EXCEPTION_ARTICLE_NOPRODUCTID' );
00075             throw $oEx;
00076         }
00077 
00078         if ( $this->_oArticle === null ) {
00079 
00080             $this->_oArticle = oxNew( 'oxarticle' );
00081 
00082             // performance
00083             if ( $this->_blParentBuyable ) {
00084                 $this->_oArticle->setSkipAbPrice( true );
00085                 $this->_oArticle->setNoVariantLoading( true );
00086             }
00087 
00088             if ( !$this->_oArticle->load( $this->oxuserbasketitems__oxartid->value ) ) {
00089                 return false;
00090             }
00091 
00092             $aSelList = $this->getSelList();
00093             if ( ( $aSelectlist = $this->_oArticle->getSelectLists() ) && is_array( $aSelList ) ) {
00094                 foreach ( $aSelList as $iKey => $iSel ) {
00095 
00096                     if ( isset( $aSelectlist[$iKey][$iSel] ) ) {
00097                         // cloning select list information
00098                         $aSelectlist[$iKey][$iSel] = clone $aSelectlist[$iKey][$iSel];
00099                         $aSelectlist[$iKey][$iSel]->selected = 1;
00100                     }
00101                 }
00102                 $this->_oArticle->setSelectlist( $aSelectlist );
00103             }
00104             // formatting title if variant
00105             if ( $this->_oArticle->oxarticles__oxparentid->value ) {
00106                 $oParent = oxNew( 'oxarticle' );
00107                 if ( $oParent->load( $this->_oArticle->oxarticles__oxparentid->value ) ) {
00108                     if ( $this->_oArticle->oxarticles__oxvarselect->value ) {
00109                         $this->_oArticle->oxarticles__oxtitle->value .= ', '.$this->_oArticle->oxarticles__oxvarselect->value;
00110                     }
00111                 }
00112             }
00113 
00114             // generating item key
00115             $this->_oArticle->setItemKey( $sItemKey );
00116         }
00117 
00118         return $this->_oArticle;
00119 
00120     }
00121 
00127     public function __sleep()
00128     {
00129         $aRet = array();
00130         foreach ( get_object_vars( $this ) as $sKey => $sVar ) {
00131             if ( $sKey != '_oArticle' ) {
00132                 $aRet[] = $sKey;
00133             }
00134         }
00135         return $aRet;
00136     }
00137 
00143     public function getSelList()
00144     {
00145         if ( $this->_aSelList == null && $this->oxuserbasketitems__oxsellist->value ) {
00146             $this->_aSelList = unserialize( $this->oxuserbasketitems__oxsellist->value );
00147         }
00148 
00149         return $this->_aSelList;
00150     }
00151 
00159     public function setSelList( $aSelList )
00160     {
00161         $this->oxuserbasketitems__oxsellist = new oxField(serialize( $aSelList ), oxField::T_RAW);
00162     }
00163 
00173     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00174     {
00175         if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName)) {
00176             $iDataType = oxField::T_RAW;
00177         }
00178         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00179     }
00180 }

Generated on Fri Dec 19 14:20:29 2008 for OXID eShop CE by  doxygen 1.5.5