details.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Details extends oxUBase
00010 {
00016     protected $_aVariantList = null;
00017 
00023     protected $_sThisTemplate = 'page/details/details.tpl';
00024 
00030     protected $_oParentProd = null;
00031 
00037     protected $_blCanRate = null;
00038 
00043     protected $_blShowSorting = true;
00044 
00049     protected $_blEditTags = null;
00050 
00055     protected $_blCanEditTags = null;
00056 
00061     protected $_aTags = null;
00062 
00067     protected $_aUserRecommList = null;
00068 
00073     protected $_oCaptcha = null;
00074 
00079     protected $_aMediaFiles = null;
00080 
00085     protected $_aLastProducts = null;
00086 
00091     protected $_oVendor = null;
00092 
00097     protected $_oManufacturer = null;
00098 
00103     protected $_oCategory = null;
00104 
00109     protected $_aAttributes = null;
00110 
00115     protected $_sParentName = null;
00116 
00121     protected $_sParentUrl = null;
00122 
00127     protected $_aPicGallery = null;
00128 
00133     protected $_aSelectLists = null;
00134 
00139     protected $_aReviews = null;
00140 
00145     protected $_oCrossSelling = null;
00146 
00151     protected $_oSimilarProducts = null;
00152 
00157     protected $_oRecommList = null;
00158 
00163     protected $_oAccessoires = null;
00164 
00169     protected $_aAlsoBoughtArts = null;
00170 
00175     protected $_sSearchTitle = null;
00176 
00182     protected $_blIsInitialized = false;
00183 
00189     protected $_iLinkType = null;
00190 
00196     protected $_blMdView = null;
00197 
00202     protected $_dRatingValue = null;
00203 
00208     protected $_iRatingCnt = null;
00209 
00214     protected $_blTop5Action = false;
00215 
00220     protected $_sBidPrice = null;
00221 
00226     protected $_iPriceAlarmStatus = null;
00227 
00232     protected $_sSearchParamForHtml = null;
00233 
00239     protected $_aSimilarRecommListIds = null;
00240 
00241 
00249     protected function _getParentProduct( $sParentId )
00250     {
00251         if ( $sParentId && $this->_oParentProd === null ) {
00252             $this->_oParentProd = false;
00253             if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00254                 $this->_processProduct( $oParent );
00255                 $this->_oParentProd = $oParent;
00256             }
00257         }
00258         return $this->_oParentProd;
00259     }
00260 
00267     public function loadVariantInformation()
00268     {
00269         if ( $this->_aVariantList === null ) {
00270             $oProduct = $this->getProduct();
00271 
00272             //if we are child and do not have any variants then let's load all parent variants as ours
00273             if ( $oParent = $oProduct->getParentArticle() ) {
00274                 $myConfig = $this->getConfig();
00275 
00276                 $oParent->setNoVariantLoading(false);
00277                 $this->_aVariantList = $oParent->getFullVariants( false );
00278 
00279                 //lets additionally add parent article if it is sellable
00280                 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00281                     //#1104S if parent is buyable load selectlists too
00282                     $oParent->enablePriceLoad();
00283                     $oParent->aSelectlist = $oParent->getSelectLists();
00284                     $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00285                 }
00286             } else {
00287                 //loading full list of variants
00288                 $this->_aVariantList = $oProduct->getFullVariants( false );
00289             }
00290 
00291             // setting link type for variants ..
00292             foreach ( $this->_aVariantList as $oVariant ) {
00293                 $this->_processProduct( $oVariant );
00294             }
00295 
00296         }
00297 
00298         return $this->_aVariantList;
00299     }
00300 
00306     protected function _getAddUrlParams()
00307     {
00308         if ( $this->getListType() == "search" ) {
00309             return $this->getDynUrlParams();
00310         }
00311     }
00312 
00320     protected function _processProduct( $oProduct )
00321     {
00322         $oProduct->setLinkType( $this->getLinkType() );
00323         if ( $sAddParams = $this->_getAddUrlParams() ) {
00324             $oProduct->appendLink( $sAddParams );
00325         }
00326     }
00327 
00333     public function getViewId()
00334     {
00335         if ( isset( $this->_sViewId )) {
00336             return $this->_sViewId;
00337         }
00338 
00339             $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00340 
00341 
00342         return $this->_sViewId = $sViewId;
00343     }
00344 
00345 
00357     public function render()
00358     {
00359         $myConfig = $this->getConfig();
00360 
00361         $oProduct = $this->getProduct();
00362 
00363         // assign template name
00364         if ( $oProduct->oxarticles__oxtemplate->value ) {
00365             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00366         }
00367 
00368         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00369             $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00370         }
00371 
00372         parent::render();
00373 
00374         $sPartial = oxConfig::getParameter('renderPartial');
00375         $this->addTplParam('renderPartial', $sPartial);
00376 
00377         switch ($sPartial) {
00378             case "productInfo":
00379                 return 'page/details/ajax/fullproductinfo.tpl';
00380                 break;
00381             case "detailsMain":
00382                 return 'page/details/ajax/productmain.tpl';
00383                 break;
00384             default:
00385                 // #785A loads and sets locator data
00386                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00387                 $oLocator->setLocatorData( $oProduct, $this );
00388 
00389                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
00390                     $oRss = oxNew('oxrssfeed');
00391                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00392                 }
00393 
00394                 return $this->_sThisTemplate;
00395         }
00396     }
00397 
00409     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00410     {
00411         if ( !$sMeta ) {
00412             $oProduct = $this->getProduct();
00413 
00414             $sMeta = $oProduct->getLongDescription()->value;
00415             if ( $sMeta == '' ) {
00416                 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00417             }
00418             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00419         }
00420         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00421     }
00422 
00433     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00434     {
00435         if ( !$sKeywords ) {
00436             $oProduct = $this->getProduct();
00437             $sKeywords = trim( $this->getTitle() );
00438 
00439             if ( $oCatTree = $this->getCategoryTree() ) {
00440                 foreach ( $oCatTree->getPath() as $oCat ) {
00441                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00442                 }
00443             }
00444 
00445             //adding searchkeys info
00446             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00447                 $sKeywords .= ", ". $sSearchKeys;
00448             }
00449 
00450             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00451         }
00452 
00453         return $sKeywords;
00454     }
00455 
00461     public function ratingIsActive()
00462     {
00463         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
00464     }
00465 
00471     public function canRate()
00472     {
00473         if ( $this->_blCanRate === null ) {
00474 
00475             $this->_blCanRate = false;
00476 
00477             if ( $this->ratingIsActive() && $oUser = $this->getUser() ) {
00478 
00479                 $oRating = oxNew( 'oxrating' );
00480                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00481             }
00482         }
00483 
00484         return $this->_blCanRate;
00485     }
00486 
00492     public function canChangeTags()
00493     {
00494         if ( $oUser = $this->getUser() ) {
00495 
00496             return true;
00497         }
00498         return false;
00499     }
00500 
00506     public function saveReview()
00507     {
00508         if ( $this->canAcceptFormData() &&
00509              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00510 
00511             $dRating = oxConfig::getParameter( 'artrating' );
00512             if ( $dRating !== null ) {
00513                 $dRating = (int) $dRating;
00514             }
00515 
00516             //save rating
00517             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00518                 $oRating = oxNew( 'oxrating' );
00519                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00520                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00521                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00522                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00523                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00524                     $oRating->save();
00525                     $oProduct->addToRatingAverage( $dRating );
00526                 }
00527             }
00528 
00529             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00530                 $oReview = oxNew( 'oxreview' );
00531                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00532                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00533                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00534                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00535                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00536                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00537                 $oReview->save();
00538             }
00539         }
00540     }
00541 
00547     public function addToRecomm()
00548     {
00549         if (!$this->getViewConfig()->getShowListmania()) {
00550             return;
00551         }
00552 
00553         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00554         $sRecommList = oxConfig::getParameter( 'recomm' );
00555         $sArtId      = $this->getProduct()->getId();
00556 
00557         if ( $sArtId ) {
00558             $oRecomm = oxNew( 'oxrecommlist' );
00559             $oRecomm->load( $sRecommList);
00560             $oRecomm->addArticle( $sArtId, $sRecommText );
00561         }
00562     }
00563 
00569     public function addTags()
00570     {
00571         $sTag  = $this->getConfig()->getParameter('newTags', true );
00572         $sHighTag  = $this->getConfig()->getParameter( 'highTags', true );
00573         if ( !$sTag && !$sHighTag) {
00574             return;
00575         }
00576         if ( $sHighTag ) {
00577             $sTag = getStr()->html_entity_decode( $sHighTag );
00578         }
00579 
00580         //can tag only once per product and tags
00581         $aTags = array();
00582         $oProduct = $this->getProduct();
00583         $aTaggedProducts = oxSession::getVar("aTaggedProducts");
00584         if ( $aTaggedProducts ) {
00585             $aTags = $aTaggedProducts[$oProduct->getId()];
00586         }
00587         $blAddedTag = false;
00588         //Checks if user already tagged it
00589         if ( $aTags[$sTag] != 1 ) {
00590             $oProduct->addTag( $sTag );
00591             $aTags[$sTag] = 1;
00592             $aTaggedProducts[$oProduct->getId()] = $aTags;
00593             oxSession::setVar( 'aTaggedProducts', $aTaggedProducts);
00594             $blAddedTag = true;
00595         }
00596         // for ajax call
00597         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00598             oxRegistry::getUtils()->showMessageAndExit( $blAddedTag );
00599         }
00600     }
00601 
00607     public function editTags()
00608     {
00609         if ( !$this->getUser() ) {
00610             return;
00611         }
00612         $oTagCloud = oxNew("oxTagCloud");
00613         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00614         $this->_blEditTags = true;
00615 
00616         // for ajax call
00617         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00618             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00619             $oActView = oxNew( 'oxubase' );
00620             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00621             $oSmarty->assign('oView', $this );
00622             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00623             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00624         }
00625     }
00626 
00632     public function cancelTags()
00633     {
00634         $oTagCloud = oxNew("oxTagCloud");
00635         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00636         $this->_blEditTags = false;
00637 
00638         // for ajax call
00639         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00640             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00641             $oActView = oxNew( 'oxubase' );
00642             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00643             $oSmarty->assign('oView', $this );
00644             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00645             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00646         }
00647     }
00648 
00654     protected function _getSeoObjectId()
00655     {
00656         if ( $oProduct = $this->getProduct() ) {
00657             return $oProduct->getId();
00658         }
00659     }
00660 
00666     public function getAttributes()
00667     {
00668         if ( $this->_aAttributes === null ) {
00669             // all attributes this article has
00670             $aArtAttributes = $this->getProduct()->getAttributes();
00671 
00672             //making a new array for backward compatibility
00673             $this->_aAttributes = false;
00674 
00675             if ( count( $aArtAttributes ) ) {
00676                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00677                     $this->_aAttributes[$sKey] = new stdClass();
00678                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00679                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00680                 }
00681             }
00682         }
00683         return $this->_aAttributes;
00684     }
00685 
00686 
00692     public function getEditTags()
00693     {
00694         return $this->_blEditTags;
00695     }
00696 
00702     public function getTags()
00703     {
00704         return $this->_aTags;
00705     }
00706 
00712     public function getTagCloudManager()
00713     {
00714         $oManager = oxNew( "oxTagCloud" );
00715         $oManager->setExtendedMode( true );
00716         $oManager->setProductId( $this->getProduct()->getId() );
00717         return $oManager;
00718     }
00719 
00726     public function isEditableTags()
00727     {
00728         if ( $this->_blCanEditTags === null ) {
00729             $this->_blCanEditTags = false;
00730             if ( $this->getProduct() && $this->getUser()) {
00731                 $this->_blCanEditTags = true;
00732             }
00733         }
00734         return $this->_blCanEditTags;
00735     }
00736 
00742     public function getProduct()
00743     {
00744         $myConfig = $this->getConfig();
00745         $myUtils = oxRegistry::getUtils();
00746 
00747         if ( $this->_oProduct === null ) {
00748 
00749             //this option is only for lists and we must reset value
00750             //as blLoadVariants = false affect "ab price" functionality
00751             $myConfig->setConfigParam( 'blLoadVariants', true );
00752 
00753             $sOxid = oxConfig::getParameter( 'anid' );
00754 
00755             // object is not yet loaded
00756             $this->_oProduct = oxNew( 'oxarticle' );
00757 
00758             if ( !$this->_oProduct->load( $sOxid ) ) {
00759                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00760                 $myUtils->showMessageAndExit( '' );
00761             }
00762 
00763             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00764             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00765                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00766             }
00767         }
00768 
00769         // additional checks
00770         if ( !$this->_blIsInitialized ) {
00771 
00772             $blContinue = true;
00773             if ( !$this->_oProduct->isVisible() ) {
00774                 $blContinue = false;
00775             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00776                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00777                 if ( !$oParent || !$oParent->isVisible() ) {
00778                     $blContinue = false;
00779                 }
00780             }
00781 
00782             if ( !$blContinue ) {
00783                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00784                 $myUtils->showMessageAndExit( '' );
00785             }
00786 
00787             $this->_processProduct( $this->_oProduct );
00788             $this->_blIsInitialized = true;
00789         }
00790 
00791         return $this->_oProduct;
00792     }
00793 
00799     public function getLinkType()
00800     {
00801         if ( $this->_iLinkType === null ) {
00802             $sListType = oxConfig::getParameter( 'listtype' );
00803             if ( 'vendor' == $sListType ) {
00804                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00805             } elseif ( 'manufacturer' == $sListType ) {
00806                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00807             } elseif ( 'tag' == $sListType ) {
00808                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00809             } elseif ( 'recommlist' == $sListType ) {
00810                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00811             } else {
00812                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00813 
00814                 // price category has own type..
00815                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00816                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00817                 }
00818             }
00819         }
00820 
00821         return $this->_iLinkType;
00822     }
00823 
00829     public function getVariantList()
00830     {
00831         return $this->loadVariantInformation();
00832     }
00833 
00840     public function getVariantListExceptCurrent()
00841     {
00842         $oList = $this->getVariantList();
00843         if (is_object($oList)) {
00844             $oList = clone $oList;
00845         }
00846 
00847         $sOxid = $this->getProduct()->getId();
00848         if (isset($oList[$sOxid])) {
00849             unset($oList[$sOxid]);
00850         }
00851         return $oList;
00852     }
00853 
00859     public function getCaptcha()
00860     {
00861         if ( $this->_oCaptcha === null ) {
00862             $this->_oCaptcha = oxNew('oxCaptcha');
00863         }
00864         return $this->_oCaptcha;
00865     }
00866 
00872     public function getMediaFiles()
00873     {
00874         if ( $this->_aMediaFiles === null ) {
00875             $aMediaFiles = $this->getProduct()->getMediaUrls();
00876             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00877         }
00878         return $this->_aMediaFiles;
00879     }
00880 
00888     public function getLastProducts( $iCnt = 4 )
00889     {
00890         if ( $this->_aLastProducts === null ) {
00891             //last seen products for #768CA
00892             $oProduct = $this->getProduct();
00893             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00894 
00895             $oHistoryArtList = oxNew( 'oxarticlelist' );
00896             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00897             $this->_aLastProducts = $oHistoryArtList;
00898         }
00899         return $this->_aLastProducts;
00900     }
00901 
00907     public function getVendor()
00908     {
00909         if ( $this->_oVendor === null ) {
00910             $this->_oVendor = $this->getProduct()->getVendor( false );
00911         }
00912         return $this->_oVendor;
00913     }
00914 
00920     public function getManufacturer()
00921     {
00922         if ( $this->_oManufacturer === null ) {
00923             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00924         }
00925         return $this->_oManufacturer;
00926     }
00927 
00933     public function getCategory()
00934     {
00935         if ( $this->_oCategory === null ) {
00936             $this->_oCategory = $this->getProduct()->getCategory();
00937         }
00938         return $this->_oCategory;
00939     }
00940 
00946     public function drawParentUrl()
00947     {
00948         return $this->getProduct()->isVariant();
00949     }
00950 
00956     public function getParentName()
00957     {
00958         if ( $this->_sParentName === null ) {
00959             $this->_sParentName = false;
00960             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00961                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00962             }
00963         }
00964         return $this->_sParentName;
00965     }
00966 
00972     public function getParentUrl()
00973     {
00974         if ( $this->_sParentUrl === null ) {
00975             $this->_sParentUrl = false;
00976             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00977                 $this->_sParentUrl = $oParent->getLink();
00978             }
00979         }
00980         return $this->_sParentUrl;
00981     }
00982 
00988     public function getPictureGallery()
00989     {
00990         if ( $this->_aPicGallery === null ) {
00991             //get picture gallery
00992             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00993         }
00994         return $this->_aPicGallery;
00995     }
00996 
01002     public function getActPictureId()
01003     {
01004         $aPicGallery = $this->getPictureGallery();
01005         return $aPicGallery['ActPicID'];
01006     }
01007 
01013     public function getActPicture()
01014     {
01015         $aPicGallery = $this->getPictureGallery();
01016         return $aPicGallery['ActPic'];
01017     }
01018 
01024     public function morePics()
01025     {
01026         $aPicGallery = $this->getPictureGallery();
01027         return $aPicGallery['MorePics'];
01028     }
01029 
01035     public function getPictures()
01036     {
01037         $aPicGallery = $this->getPictureGallery();
01038         return $aPicGallery['Pics'];
01039     }
01040 
01048     public function getArtPic( $sPicNr )
01049     {
01050         $aPicGallery = $this->getPictureGallery();
01051         return $aPicGallery['Pics'][$sPicNr];
01052     }
01053 
01059     public function getIcons()
01060     {
01061         $aPicGallery = $this->getPictureGallery();
01062         return $aPicGallery['Icons'];
01063     }
01064 
01070     public function showZoomPics()
01071     {
01072         $aPicGallery = $this->getPictureGallery();
01073         return $aPicGallery['ZoomPic'];
01074     }
01075 
01081     public function getZoomPics()
01082     {
01083         $aPicGallery = $this->getPictureGallery();
01084         return $aPicGallery['ZoomPics'];
01085     }
01086 
01092     public function getActZoomPic()
01093     {
01094         return 1;
01095     }
01096 
01102     public function getSelectLists()
01103     {
01104         if ( $this->_aSelectLists === null ) {
01105             $this->_aSelectLists = false;
01106             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01107                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01108             }
01109         }
01110         return $this->_aSelectLists;
01111     }
01112 
01118     public function getReviews()
01119     {
01120         if ( $this->_aReviews === null ) {
01121             $this->_aReviews = false;
01122             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01123                 $this->_aReviews = $this->getProduct()->getReviews();
01124             }
01125         }
01126         return $this->_aReviews;
01127     }
01128 
01134     public function getCrossSelling()
01135     {
01136         if ( $this->_oCrossSelling === null ) {
01137             $this->_oCrossSelling = false;
01138             if ( $oProduct = $this->getProduct() ) {
01139                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01140             }
01141         }
01142         return $this->_oCrossSelling;
01143     }
01144 
01150     public function getSimilarProducts()
01151     {
01152         if ( $this->_oSimilarProducts === null ) {
01153             $this->_oSimilarProducts = false;
01154             if ( $oProduct = $this->getProduct() ) {
01155                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01156             }
01157         }
01158         return $this->_oSimilarProducts;
01159     }
01160 
01166     public function getSimilarRecommListIds()
01167     {
01168         if ( $this->_aSimilarRecommListIds === null ) {
01169             $this->_aSimilarRecommListIds = false;
01170 
01171             if ( $oProduct = $this->getProduct() ) {
01172                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
01173             }
01174         }
01175         return $this->_aSimilarRecommListIds;
01176     }
01177 
01183     public function getAccessoires()
01184     {
01185         if ( $this->_oAccessoires === null ) {
01186             $this->_oAccessoires = false;
01187             if ( $oProduct = $this->getProduct() ) {
01188                 $this->_oAccessoires = $oProduct->getAccessoires();
01189             }
01190         }
01191         return $this->_oAccessoires;
01192     }
01193 
01199     public function getAlsoBoughtTheseProducts()
01200     {
01201         if ( $this->_aAlsoBoughtArts === null ) {
01202             $this->_aAlsoBoughtArts = false;
01203             if ( $oProduct = $this->getProduct() ) {
01204                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01205             }
01206         }
01207         return $this->_aAlsoBoughtArts;
01208     }
01209 
01215     public function isPriceAlarm()
01216     {
01217         // #419 disabling pricealarm if article has fixed price
01218         $oProduct = $this->getProduct();
01219         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01220             return 0;
01221         }
01222         return 1;
01223     }
01224 
01233     protected function _getSubject( $iLang )
01234     {
01235         return $this->getProduct();
01236     }
01237 
01243     public function getSearchTitle()
01244     {
01245         return $this->_sSearchTitle;
01246     }
01247 
01255     public function setSearchTitle( $sTitle )
01256     {
01257         $this->_sSearchTitle = $sTitle;
01258     }
01259 
01267     public function setCatTreePath( $sActCatPath )
01268     {
01269         $this->_sCatTreePath = $sActCatPath;
01270     }
01271 
01278     public function noIndex()
01279     {
01280         $sListType = oxConfig::getParameter( 'listtype' );
01281         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01282             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01283         }
01284         return parent::noIndex();
01285     }
01286 
01292     public function getTitle()
01293     {
01294         if ( $oProduct = $this->getProduct() ) {
01295             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01296         }
01297     }
01298 
01299 
01305     public function getTag()
01306     {
01307         return oxConfig::getParameter("searchtag", 1);
01308     }
01309 
01315     public function getCanonicalUrl()
01316     {
01317         if ( ( $oProduct = $this->getProduct() ) ) {
01318             if ( $oProduct->oxarticles__oxparentid->value ) {
01319                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01320             }
01321 
01322             $oUtils = oxRegistry::get("oxUtilsUrl");
01323             if ( oxRegistry::getUtils()->seoIsActive() ) {
01324                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01325             } else {
01326                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01327             }
01328             return $sUrl;
01329         }
01330     }
01331 
01337     public function isMdVariantView()
01338     {
01339         if ( $this->_blMdView === null ) {
01340             $this->_blMdView = false;
01341             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01342                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01343                 $this->_blMdView = ($iMaxMdDepth > 1);
01344             }
01345         }
01346 
01347         return $this->_blMdView;
01348     }
01349 
01355     public function isPersParam()
01356     {
01357         $oProduct = $this->getProduct();
01358         return $oProduct->oxarticles__oxisconfigurable->value;
01359     }
01360 
01366     public function getTagSeparator()
01367     {
01368         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01369         return $sSepartor;
01370     }
01371 
01377     public function getRatingValue()
01378     {
01379 
01380         if ( $this->_dRatingValue === null ) {
01381             $this->_dRatingValue = (double) 0;
01382             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01383                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01384             }
01385         }
01386 
01387         return (double) $this->_dRatingValue;
01388     }
01389 
01395     public function isReviewActive()
01396     {
01397         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01398     }
01399 
01405     public function getRatingCount()
01406     {
01407         if ( $this->_iRatingCnt === null ) {
01408             $this->_iRatingCnt = false;
01409             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01410                 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01411             }
01412         }
01413         return $this->_iRatingCnt;
01414     }
01415 
01421     public function getBreadCrumb()
01422     {
01423         $aPaths = array();
01424 
01425         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01426             $sSearchParam = $this->getSearchParamForHtml();
01427 
01428             $aCatPath = array();
01429             $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01430             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01431 
01432             $aPaths[] = $aCatPath;
01433 
01434         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01435 
01436             $aCatPath = array();
01437 
01438             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01439             $aCatPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01440             $aPaths[] = $aCatPath;
01441 
01442             $oStr = getStr();
01443             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01444             $aCatPath['link']  = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01445             $aPaths[] = $aCatPath;
01446 
01447         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01448 
01449             $aCatPath = array();
01450             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01451             $aPaths[] = $aCatPath;
01452         } else {
01453 
01454             $oCatTree = $this->getCatTreePath();
01455 
01456             if ( $oCatTree ) {
01457 
01458                 foreach ( $oCatTree as $oCat ) {
01459                     $aCatPath = array();
01460 
01461                     $aCatPath['link'] = $oCat->getLink();
01462                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01463 
01464                     $aPaths[] = $aCatPath;
01465                 }
01466             }
01467         }
01468 
01469         return $aPaths;
01470     }
01471 
01481     public function addme()
01482     {
01483         $myConfig = $this->getConfig();
01484         $myUtils  = oxRegistry::getUtils();
01485 
01486         //control captcha
01487         $sMac     = oxConfig::getParameter( 'c_mac' );
01488         $sMacHash = oxConfig::getParameter( 'c_mach' );
01489         $oCaptcha = $this->getCaptcha();
01490         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01491             $this->_iPriceAlarmStatus = 2;
01492             return;
01493         }
01494 
01495         $aParams = oxConfig::getParameter( 'pa' );
01496         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01497             $this->_iPriceAlarmStatus = 0;
01498             return;
01499         }
01500         $aParams['aid'] = $this->getProduct()->getId();
01501         $oCur = $myConfig->getActShopCurrencyObject();
01502         // convert currency to default
01503         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01504 
01505         $oAlarm = oxNew( "oxpricealarm" );
01506         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01507         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01508         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01509         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01510         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01511         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01512 
01513         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01514 
01515         $oAlarm->save();
01516 
01517         // Send Email
01518         $oEmail = oxNew( 'oxemail' );
01519         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01520     }
01521 
01527     public function getPriceAlarmStatus()
01528     {
01529         return $this->_iPriceAlarmStatus;
01530     }
01531 
01537     public function getBidPrice()
01538     {
01539         if ( $this->_sBidPrice === null ) {
01540             $this->_sBidPrice = false;
01541 
01542             $aParams = oxConfig::getParameter( 'pa' );
01543             $oCur = $this->getConfig()->getActShopCurrencyObject();
01544             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01545             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01546         }
01547         return $this->_sBidPrice;
01548     }
01549 
01555     public function getVariantSelections()
01556     {
01557         // finding parent
01558         $oProduct = $this->getProduct();
01559         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01560             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01561         }
01562 
01563         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01564     }
01565 
01571     public function getPicturesProduct()
01572     {
01573         $aVariantSelections = $this->getVariantSelections();
01574         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01575             return $aVariantSelections['oActiveVariant'];
01576         }
01577         return $this->getProduct();
01578     }
01579 
01585     public function getSearchParamForHtml()
01586     {
01587         if ( $this->_sSearchParamForHtml === null ) {
01588             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01589         }
01590         return $this->_sSearchParamForHtml;
01591     }
01592 
01598     public function showRdfa()
01599     {
01600         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01601     }
01602 
01608     public function getRDFaNormalizedRating()
01609     {
01610         $myConfig = $this->getConfig();
01611         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01612         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01613 
01614         $oProduct = $this->getProduct();
01615         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01616         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01617             $aNomalizedRating = array();
01618             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01619             $aNomalizedRating["count"] = $iCount;
01620             $aNomalizedRating["value"] = round($iValue, 2);
01621             return $aNomalizedRating;
01622         }
01623         return false;
01624     }
01625 
01633     public function getRDFaValidityPeriod($sShopConfVar)
01634     {
01635         if ( $sShopConfVar ) {
01636             $aValidity = array();
01637             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01638             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01639 
01640             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01641             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01642             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01643 
01644             return $aValidity;
01645         }
01646         return false;
01647     }
01648 
01654     public function getRDFaBusinessFnc()
01655     {
01656         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01657     }
01658 
01664     public function getRDFaCustomers()
01665     {
01666         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01667     }
01668 
01674     public function getRDFaVAT()
01675     {
01676         return $this->getConfig()->getConfigParam("iRDFaVAT");
01677     }
01678 
01684     public function getRDFaGenericCondition()
01685     {
01686         return $this->getConfig()->getConfigParam("iRDFaCondition");
01687     }
01688 
01694     public function getBundleArticle()
01695     {
01696         $oProduct = $this->getProduct();
01697         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01698             $oArticle = oxNew("oxarticle");
01699             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01700             return $oArticle;
01701         }
01702         return false;
01703     }
01704 
01710     public function getRDFaPaymentMethods()
01711     {
01712         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01713         $oPayments = oxNew("oxpaymentlist");
01714         $oPayments->loadRDFaPaymentList($iPrice);
01715         return $oPayments;
01716     }
01717 
01723     public function getRDFaDeliverySetMethods()
01724     {
01725         $oDelSets = oxNew("oxdeliverysetlist");
01726         $oDelSets->loadRDFaDeliverySetList();
01727         return $oDelSets;
01728     }
01729 
01735     public function getProductsDeliveryList()
01736     {
01737         $oProduct = $this->getProduct();
01738         $oDelList = oxNew( "oxDeliveryList" );
01739         $oDelList->loadDeliveryListForProduct( $oProduct );
01740         return $oDelList;
01741     }
01742 
01748     public function getRDFaDeliveryChargeSpecLoc()
01749     {
01750         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01751     }
01752 
01758     public function getRDFaPaymentChargeSpecLoc()
01759     {
01760         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01761     }
01762 
01768     public function getRDFaBusinessEntityLoc()
01769     {
01770         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01771     }
01772 
01778     public function showRDFaProductStock()
01779     {
01780         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01781     }
01782 
01783 }