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 
00040     public function __construct()
00041     {
00042         $this->setVariantParentBuyable( $this->getConfig()->getConfigParam( 'blVariantParentBuyable' ) );
00043         parent::__construct();
00044         $this->init( 'oxuserbasketitems' );
00045     }
00046 
00054     public function setVariantParentBuyable( $blBuyable = false )
00055     {
00056         $this->_blParentBuyable = $blBuyable;
00057     }
00058 
00068     public function getArticle( $sItemKey )
00069     {
00070         if ( !$this->oxuserbasketitems__oxartid->value ) {
00071             //this excpetion may not be caught, anyhow this is a critical exception
00072             $oEx = oxNew( 'oxArticleException' );
00073             $oEx->setMessage( 'EXCEPTION_ARTICLE_NOPRODUCTID' );
00074             throw $oEx;
00075         }
00076 
00077         if ( $this->_oArticle === null ) {
00078 
00079             $this->_oArticle = oxNew( 'oxarticle' );
00080 
00081             // performance
00082             if ( $this->_blParentBuyable ) {
00083                 $this->_oArticle->setSkipAbPrice( true );
00084                 $this->_oArticle->setNoVariantLoading( true );
00085             }
00086 
00087             if ( !$this->_oArticle->load( $this->oxuserbasketitems__oxartid->value ) ) {
00088                 return false;
00089             }
00090 
00091             $aSelList = $this->getSelList();
00092             if ( ( $aSelectlist = $this->_oArticle->getSelectLists() ) && is_array( $aSelList ) ) {
00093                 foreach ( $aSelList as $iKey => $iSel ) {
00094 
00095                     if ( isset( $aSelectlist[$iKey][$iSel] ) ) {
00096                         // cloning select list information
00097                         $aSelectlist[$iKey][$iSel] = clone $aSelectlist[$iKey][$iSel];
00098                         $aSelectlist[$iKey][$iSel]->selected = 1;
00099                     }
00100                 }
00101                 $this->_oArticle->setSelectlist( $aSelectlist );
00102             }
00103             // formatting title if variant
00104             if ( $this->_oArticle->oxarticles__oxparentid->value ) {
00105                 $oParent = oxNew( 'oxarticle' );
00106                 if ( $oParent->load( $this->_oArticle->oxarticles__oxparentid->value ) ) {
00107                     if ( $this->_oArticle->oxarticles__oxvarselect->value ) {
00108                         $this->_oArticle->oxarticles__oxtitle->value .= ', '.$this->_oArticle->oxarticles__oxvarselect->value;
00109                     }
00110                 }
00111             }
00112 
00113             // generating item key
00114             $this->_oArticle->setItemKey( $sItemKey );
00115         }
00116 
00117         return $this->_oArticle;
00118 
00119     }
00120 
00126     public function __sleep()
00127     {
00128         $aRet = array();
00129         foreach ( get_object_vars( $this ) as $sKey => $sVar ) {
00130             if ( $sKey != '_oArticle' ) {
00131                 $aRet[] = $sKey;
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 
00158     public function setSelList( $aSelList )
00159     {
00160         $this->oxuserbasketitems__oxsellist = new oxField(serialize( $aSelList ), oxField::T_RAW);
00161     }
00162 
00172     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00173     {
00174         if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName)) {
00175             $iDataType = oxField::T_RAW;
00176         }
00177         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00178     }
00179 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5