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 
00241     protected function _getParentProduct( $sParentId )
00242     {
00243         if ( $sParentId && $this->_oParentProd === null ) {
00244             $this->_oParentProd = false;
00245             if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00246                 $this->_processProduct( $oParent );
00247                 $this->_oParentProd = $oParent;
00248             }
00249         }
00250         return $this->_oParentProd;
00251     }
00252 
00259     public function loadVariantInformation()
00260     {
00261         if ( $this->_aVariantList === null ) {
00262             $oProduct = $this->getProduct();
00263 
00264             //if we are child and do not have any variants then let's load all parent variants as ours
00265             if ( $oParent = $oProduct->getParentArticle() ) {
00266                 $myConfig = $this->getConfig();
00267 
00268                 $oParent->setNoVariantLoading(false);
00269                 $this->_aVariantList = $oParent->getFullVariants( false );
00270 
00271                 //lets additionally add parent article if it is sellable
00272                 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00273                     //#1104S if parent is buyable load selectlists too
00274                     $oParent->aSelectlist = $oParent->getSelectLists();
00275                     $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00276                 }
00277             } else {
00278                 //loading full list of variants
00279                 $this->_aVariantList = $oProduct->getFullVariants( false );
00280             }
00281 
00282             // setting link type for variants ..
00283             foreach ( $this->_aVariantList as $oVariant ) {
00284                 $this->_processProduct( $oVariant );
00285             }
00286 
00287         }
00288 
00289         return $this->_aVariantList;
00290     }
00291 
00297     protected function _getAddUrlParams()
00298     {
00299         if ( $this->getListType() == "search" ) {
00300             return $this->getDynUrlParams();
00301         }
00302     }
00303 
00311     protected function _processProduct( $oProduct )
00312     {
00313         $oProduct->setLinkType( $this->getLinkType() );
00314         if ( $sAddParams = $this->_getAddUrlParams() ) {
00315             $oProduct->appendLink( $sAddParams );
00316         }
00317     }
00318 
00324     public function getViewId()
00325     {
00326         if ( isset( $this->_sViewId )) {
00327             return $this->_sViewId;
00328         }
00329 
00330             $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00331 
00332 
00333         return $this->_sViewId = $sViewId;
00334     }
00335 
00336 
00348     public function render()
00349     {
00350         $myConfig = $this->getConfig();
00351 
00352         $oProduct = $this->getProduct();
00353 
00354         // assign template name
00355         if ( $oProduct->oxarticles__oxtemplate->value ) {
00356             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00357         }
00358 
00359         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00360             $this->_sThisTemplate = basename ( $sTplName );
00361         }
00362 
00363         //loading amount price list
00364         $oProduct->loadAmountPriceInfo();
00365 
00366         parent::render();
00367 
00368         $sPartial = oxConfig::getParameter('renderPartial');
00369         $this->addTplParam('sRenderPartial', $sPartial);
00370 
00371         switch ($sPartial) {
00372             case "productInfo":
00373                 return 'page/details/ajax/fullproductinfo.tpl';
00374                 break;
00375             case "detailsMain":
00376                 return 'page/details/ajax/productmain.tpl';
00377                 break;
00378             default:
00379                 // #785A loads and sets locator data
00380                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00381                 $oLocator->setLocatorData( $oProduct, $this );
00382 
00383                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommLists()) {
00384                     $oRss = oxNew('oxrssfeed');
00385                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00386                 }
00387 
00388                 return $this->_sThisTemplate;
00389         }
00390     }
00391 
00403     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00404     {
00405         if ( !$sMeta ) {
00406             $oProduct = $this->getProduct();
00407 
00408             $sMeta = $oProduct->getArticleLongDesc()->value;
00409             $sMeta = str_replace( array( '<br>', '<br />', '<br/>' ), "\n", $sMeta );
00410             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00411             $sMeta = strip_tags( $sMeta );
00412         }
00413         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00414     }
00415 
00426     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00427     {
00428         $myConfig = $this->getConfig();
00429 
00430         if ( !$sKeywords ) {
00431             $oProduct = $this->getProduct();
00432             $aKeywords[] = trim( $this->getTitle() );
00433 
00434             if ( $oCatTree = $this->getCategoryTree() ) {
00435                 foreach ( $oCatTree->getPath() as $oCat ) {
00436                     $aKeywords[] = trim( $oCat->oxcategories__oxtitle->value );
00437                 }
00438             }
00439 
00440             $sKeywords = implode( ", ", $aKeywords );
00441 
00442             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00443 
00444             //adding searchkeys info
00445             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00446                 $sKeywords .= ", " . parent::_prepareMetaKeyword( $sSearchKeys, false );
00447             }
00448         }
00449 
00450         return $sKeywords;
00451     }
00452 
00458     public function canRate()
00459     {
00460         if ( $this->_blCanRate === null ) {
00461 
00462             $this->_blCanRate = false;
00463             $myConfig = $this->getConfig();
00464 
00465             if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) &&
00466                  $oUser = $this->getUser() ) {
00467 
00468                 $oRating = oxNew( 'oxrating' );
00469                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00470             }
00471         }
00472         return $this->_blCanRate;
00473     }
00474 
00480     public function canChangeTags()
00481     {
00482         if ( $oUser = $this->getUser() ) {
00483 
00484             return true;
00485         }
00486         return false;
00487     }
00488 
00494     public function saveReview()
00495     {
00496         if ( $this->canAcceptFormData() &&
00497              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00498 
00499             $dRating = oxConfig::getParameter( 'artrating' );
00500             if ( $dRating !== null ) {
00501                 $dRating = (int) $dRating;
00502             }
00503 
00504             //save rating
00505             if ( $dRating !== null && $dRating >= 0 && $dRating <= 5 ) {
00506                 $oRating = oxNew( 'oxrating' );
00507                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00508                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00509                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00510                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00511                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00512                     $oRating->save();
00513                     $oProduct->addToRatingAverage( $dRating );
00514                 }
00515             }
00516 
00517             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00518                 $oReview = oxNew( 'oxreview' );
00519                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00520                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00521                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00522                 $oReview->oxreviews__oxlang     = new oxField( oxLang::getInstance()->getBaseLanguage() );
00523                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00524                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : null );
00525                 $oReview->save();
00526             }
00527         }
00528     }
00529 
00535     public function addToRecomm()
00536     {
00537         if (!$this->getViewConfig()->getShowListmania()) {
00538             return;
00539         }
00540 
00541         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00542         $sRecommList = oxConfig::getParameter( 'recomm' );
00543         $sArtId      = $this->getProduct()->getId();
00544 
00545         if ( $sArtId ) {
00546             $oRecomm = oxNew( 'oxrecommlist' );
00547             $oRecomm->load( $sRecommList);
00548             $oRecomm->addArticle( $sArtId, $sRecommText );
00549         }
00550     }
00551 
00557     public function addTags()
00558     {
00559         $sTag  = $this->getConfig()->getParameter('newTags', true );
00560         $sHighTag  = $this->getConfig()->getParameter( 'highTags', true );
00561         if ( !$sTag && !$sHighTag) {
00562             return;
00563         }
00564         if ( $sHighTag ) {
00565             $sTag = getStr()->html_entity_decode( $sHighTag );
00566         }
00567 
00568         //can tag only once per product and tags
00569         $aTags = array();
00570         $oProduct = $this->getProduct();
00571         $aTaggedProducts = oxSession::getVar("aTaggedProducts");
00572         if ( $aTaggedProducts ) {
00573             $aTags = $aTaggedProducts[$oProduct->getId()];
00574         }
00575         $blAddedTag = false;
00576         //Checks if user already tagged it
00577         if ( $aTags[$sTag] != 1 ) {
00578             $oProduct->addTag( $sTag );
00579             $aTags[$sTag] = 1;
00580             $aTaggedProducts[$oProduct->getId()] = $aTags;
00581             oxSession::setVar( 'aTaggedProducts', $aTaggedProducts);
00582             $blAddedTag = true;
00583         }
00584         // for ajax call
00585         if ($this->getConfig()->getParameter('blAjax', true )) {
00586             die($blAddedTag);
00587         }
00588     }
00589 
00595     public function editTags()
00596     {
00597         if ( !$this->getUser() ) {
00598             return;
00599         }
00600         $oTagCloud = oxNew("oxTagCloud");
00601         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00602         $this->_blEditTags = true;
00603 
00604         // for ajax call
00605         if ($this->getConfig()->getParameter('blAjax', true )) {
00606             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00607             $oActView = oxNew( 'oxubase' );
00608             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00609             $oSmarty->assign('oView', $this );
00610             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00611             die($oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ));
00612         }
00613     }
00614 
00620     public function cancelTags()
00621     {
00622         $oTagCloud = oxNew("oxTagCloud");
00623         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00624         $this->_blEditTags = false;
00625 
00626         // for ajax call
00627         if ($this->getConfig()->getParameter('blAjax', true )) {
00628             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00629             $oActView = oxNew( 'oxubase' );
00630             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00631             $oSmarty->assign('oView', $this );
00632             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00633             die($oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ));
00634         }
00635     }
00636 
00642     protected function _getSeoObjectId()
00643     {
00644         if ( $oProduct = $this->getProduct() ) {
00645             return $oProduct->getId();
00646         }
00647     }
00648 
00654     public function getAttributes()
00655     {
00656         if ( $this->_aAttributes === null ) {
00657             // all attributes this article has
00658             $aArtAttributes = $this->getProduct()->getAttributes();
00659 
00660             //making a new array for backward compatibility
00661             $this->_aAttributes = false;
00662 
00663             if ( count( $aArtAttributes ) ) {
00664                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00665                     $this->_aAttributes[$sKey] = new stdClass();
00666                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00667                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00668                 }
00669             }
00670         }
00671         return $this->_aAttributes;
00672     }
00673 
00674 
00680     public function getEditTags()
00681     {
00682         return $this->_blEditTags;
00683     }
00684 
00690     public function getTags()
00691     {
00692         return $this->_aTags;
00693     }
00694 
00700     public function getTagCloudManager()
00701     {
00702         $oManager = oxNew( "oxTagCloud" );
00703         $oManager->setExtendedMode( true );
00704         $oManager->setProductId( $this->getProduct()->getId() );
00705         return $oManager;
00706     }
00707 
00714     public function isEditableTags()
00715     {
00716         if ( $this->_blCanEditTags === null ) {
00717             $this->_blCanEditTags = false;
00718             if ( $this->getProduct() && $this->getUser()) {
00719                 $this->_blCanEditTags = true;
00720             }
00721         }
00722         return $this->_blCanEditTags;
00723     }
00724 
00730     public function getProduct()
00731     {
00732         $myConfig = $this->getConfig();
00733         $myUtils = oxUtils::getInstance();
00734 
00735         if ( $this->_oProduct === null ) {
00736 
00737             //this option is only for lists and we must reset value
00738             //as blLoadVariants = false affect "ab price" functionality
00739             $myConfig->setConfigParam( 'blLoadVariants', true );
00740 
00741             $sOxid = oxConfig::getParameter( 'anid' );
00742 
00743             // object is not yet loaded
00744             $this->_oProduct = oxNew( 'oxarticle' );
00745             //$this->_oProduct->setSkipAbPrice( true );
00746 
00747             if ( !$this->_oProduct->load( $sOxid ) ) {
00748                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00749                 $myUtils->showMessageAndExit( '' );
00750             }
00751 
00752             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00753             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00754                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00755             }
00756         }
00757 
00758         // additional checks
00759         if ( !$this->_blIsInitialized ) {
00760 
00761             $blContinue = true;
00762             if ( !$this->_oProduct->isVisible() ) {
00763                 $blContinue = false;
00764             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00765                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00766                 if ( !$oParent || !$oParent->isVisible() ) {
00767                     $blContinue = false;
00768                 }
00769             }
00770 
00771             if ( !$blContinue ) {
00772                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00773                 $myUtils->showMessageAndExit( '' );
00774             }
00775 
00776             $this->_processProduct( $this->_oProduct );
00777             $this->_blIsInitialized = true;
00778         }
00779 
00780         return $this->_oProduct;
00781     }
00782 
00788     public function getLinkType()
00789     {
00790         if ( $this->_iLinkType === null ) {
00791             $sListType = oxConfig::getParameter( 'listtype' );
00792             if ( 'vendor' == $sListType ) {
00793                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00794             } elseif ( 'manufacturer' == $sListType ) {
00795                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00796             } elseif ( 'tag' == $sListType ) {
00797                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00798             } elseif ( 'recommlist' == $sListType ) {
00799                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00800             } else {
00801                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00802 
00803                 // price category has own type..
00804                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00805                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00806                 }
00807             }
00808         }
00809 
00810         return $this->_iLinkType;
00811     }
00812 
00818     public function getVariantList()
00819     {
00820         return $this->loadVariantInformation();
00821     }
00822 
00829     public function getVariantListExceptCurrent()
00830     {
00831         $oList = $this->getVariantList();
00832         if (is_object($oList)) {
00833             $oList = clone $oList;
00834         }
00835 
00836         $sOxid = $this->getProduct()->getId();
00837         if (isset($oList[$sOxid])) {
00838             unset($oList[$sOxid]);
00839         }
00840         return $oList;
00841     }
00842 
00848     public function getCaptcha()
00849     {
00850         if ( $this->_oCaptcha === null ) {
00851             $this->_oCaptcha = oxNew('oxCaptcha');
00852         }
00853         return $this->_oCaptcha;
00854     }
00855 
00861     public function getMediaFiles()
00862     {
00863         if ( $this->_aMediaFiles === null ) {
00864             $aMediaFiles = $this->getProduct()->getMediaUrls();
00865             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00866         }
00867         return $this->_aMediaFiles;
00868     }
00869 
00877     public function getLastProducts( $iCnt = 4 )
00878     {
00879         if ( $this->_aLastProducts === null ) {
00880             //last seen products for #768CA
00881             $oProduct = $this->getProduct();
00882             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00883 
00884             $oHistoryArtList = oxNew( 'oxarticlelist' );
00885             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00886             $this->_aLastProducts = $oHistoryArtList;
00887         }
00888         return $this->_aLastProducts;
00889     }
00890 
00896     public function getVendor()
00897     {
00898         if ( $this->_oVendor === null ) {
00899             $this->_oVendor = $this->getProduct()->getVendor( false );
00900         }
00901         return $this->_oVendor;
00902     }
00903 
00909     public function getManufacturer()
00910     {
00911         if ( $this->_oManufacturer === null ) {
00912             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00913         }
00914         return $this->_oManufacturer;
00915     }
00916 
00922     public function getCategory()
00923     {
00924         if ( $this->_oCategory === null ) {
00925             $this->_oCategory = $this->getProduct()->getCategory();
00926         }
00927         return $this->_oCategory;
00928     }
00929 
00935     public function drawParentUrl()
00936     {
00937         return $this->getProduct()->isVariant();
00938     }
00939 
00945     public function getParentName()
00946     {
00947         if ( $this->_sParentName === null ) {
00948             $this->_sParentName = false;
00949             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00950                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00951             }
00952         }
00953         return $this->_sParentName;
00954     }
00955 
00961     public function getParentUrl()
00962     {
00963         if ( $this->_sParentUrl === null ) {
00964             $this->_sParentUrl = false;
00965             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00966                 $this->_sParentUrl = $oParent->getLink();
00967             }
00968         }
00969         return $this->_sParentUrl;
00970     }
00971 
00977     public function getPictureGallery()
00978     {
00979         if ( $this->_aPicGallery === null ) {
00980             //get picture gallery
00981             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00982         }
00983         return $this->_aPicGallery;
00984     }
00985 
00991     public function getActPictureId()
00992     {
00993         $aPicGallery = $this->getPictureGallery();
00994         return $aPicGallery['ActPicID'];
00995     }
00996 
01002     public function getActPicture()
01003     {
01004         $aPicGallery = $this->getPictureGallery();
01005         return $aPicGallery['ActPic'];
01006     }
01007 
01013     public function morePics()
01014     {
01015         $aPicGallery = $this->getPictureGallery();
01016         return $aPicGallery['MorePics'];
01017     }
01018 
01024     public function getPictures()
01025     {
01026         $aPicGallery = $this->getPictureGallery();
01027         return $aPicGallery['Pics'];
01028     }
01029 
01037     public function getArtPic( $sPicNr )
01038     {
01039         $aPicGallery = $this->getPictureGallery();
01040         return $aPicGallery['Pics'][$sPicNr];
01041     }
01042 
01048     public function getIcons()
01049     {
01050         $aPicGallery = $this->getPictureGallery();
01051         return $aPicGallery['Icons'];
01052     }
01053 
01059     public function showZoomPics()
01060     {
01061         $aPicGallery = $this->getPictureGallery();
01062         return $aPicGallery['ZoomPic'];
01063     }
01064 
01070     public function getZoomPics()
01071     {
01072         $aPicGallery = $this->getPictureGallery();
01073         return $aPicGallery['ZoomPics'];
01074     }
01075 
01081     public function getActZoomPic()
01082     {
01083         return 1;
01084     }
01085 
01091     public function getSelectLists()
01092     {
01093         if ( $this->_aSelectLists === null ) {
01094             $this->_aSelectLists = false;
01095             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01096                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01097             }
01098         }
01099         return $this->_aSelectLists;
01100     }
01101 
01107     public function getReviews()
01108     {
01109         if ( $this->_aReviews === null ) {
01110             $this->_aReviews = false;
01111             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01112                 $this->_aReviews = $this->getProduct()->getReviews();
01113             }
01114         }
01115         return $this->_aReviews;
01116     }
01117 
01123     public function getCrossSelling()
01124     {
01125         if ( $this->_oCrossSelling === null ) {
01126             $this->_oCrossSelling = false;
01127             if ( $oProduct = $this->getProduct() ) {
01128                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01129             }
01130         }
01131         return $this->_oCrossSelling;
01132     }
01133 
01139     public function getSimilarProducts()
01140     {
01141         if ( $this->_oSimilarProducts === null ) {
01142             $this->_oSimilarProducts = false;
01143             if ( $oProduct = $this->getProduct() ) {
01144                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01145             }
01146         }
01147         return $this->_oSimilarProducts;
01148     }
01149 
01155     public function getSimilarRecommLists()
01156     {
01157         if (!$this->getViewConfig()->getShowListmania()) {
01158             return false;
01159         }
01160 
01161         if ( $this->_oRecommList === null ) {
01162             $this->_oRecommList = false;
01163             if ( $oProduct = $this->getProduct() ) {
01164                 $oRecommList = oxNew('oxrecommlist');
01165                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
01166             }
01167         }
01168         return $this->_oRecommList;
01169     }
01170 
01176     public function getAccessoires()
01177     {
01178         if ( $this->_oAccessoires === null ) {
01179             $this->_oAccessoires = false;
01180             if ( $oProduct = $this->getProduct() ) {
01181                 $this->_oAccessoires = $oProduct->getAccessoires();
01182             }
01183         }
01184         return $this->_oAccessoires;
01185     }
01186 
01192     public function getAlsoBoughtTheseProducts()
01193     {
01194         if ( $this->_aAlsoBoughtArts === null ) {
01195             $this->_aAlsoBoughtArts = false;
01196             if ( $oProduct = $this->getProduct() ) {
01197                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01198             }
01199         }
01200         return $this->_aAlsoBoughtArts;
01201     }
01202 
01208     public function isPriceAlarm()
01209     {
01210         // #419 disabling pricealarm if article has fixed price
01211         $oProduct = $this->getProduct();
01212         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01213             return 0;
01214         }
01215         return 1;
01216     }
01217 
01226     protected function _getSubject( $iLang )
01227     {
01228         return $this->getProduct();
01229     }
01230 
01236     public function getSearchTitle()
01237     {
01238         return $this->_sSearchTitle;
01239     }
01240 
01248     public function setSearchTitle( $sTitle )
01249     {
01250         $this->_sSearchTitle = $sTitle;
01251     }
01252 
01260     public function setCatTreePath( $sActCatPath )
01261     {
01262         $this->_sCatTreePath = $sActCatPath;
01263     }
01264 
01271     public function noIndex()
01272     {
01273         $sListType = oxConfig::getParameter( 'listtype' );
01274         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01275             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01276         }
01277         return parent::noIndex();
01278     }
01279 
01285     public function getTitle()
01286     {
01287         if ( $oProduct = $this->getProduct() ) {
01288             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01289         }
01290     }
01291 
01292 
01298     public function getTag()
01299     {
01300         return oxConfig::getParameter("searchtag", 1);
01301     }
01302 
01308     public function getCanonicalUrl()
01309     {
01310         if ( ( $oProduct = $this->getProduct() ) ) {
01311             $oUtils = oxUtilsUrl::getInstance();
01312             if ( oxUtils::getInstance()->seoIsActive() ) {
01313                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01314             } else {
01315                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01316             }
01317             return $sUrl;
01318         }
01319     }
01320 
01326     public function isMdVariantView()
01327     {
01328         if ( $this->_blMdView === null ) {
01329             $this->_blMdView = false;
01330             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01331                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01332                 $this->_blMdView = ($iMaxMdDepth > 1);
01333             }
01334         }
01335 
01336         return $this->_blMdView;
01337     }
01338 
01344     public function isPersParam()
01345     {
01346         $oProduct = $this->getProduct();
01347         return $oProduct->oxarticles__oxisconfigurable->value;
01348     }
01349 
01355     public function getTagSeparator()
01356     {
01357         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01358         return $sSepartor;
01359     }
01360 
01366     public function getRatingValue()
01367     {
01368 
01369         if ( $this->_dRatingValue === null ) {
01370             $this->_dRatingValue = (double) 0;
01371             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01372                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage(), 1);
01373             }
01374         }
01375 
01376         return (double) $this->_dRatingValue;
01377     }
01378 
01384     public function isReviewActive()
01385     {
01386         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01387     }
01388 
01394     public function getRatingCount()
01395     {
01396         if ( $this->_iRatingCnt === null ) {
01397             $this->_iRatingCnt = false;
01398             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01399                 $this->_iRatingCnt = $oDetailsProduct->oxarticles__oxratingcnt->value;
01400             }
01401         }
01402         return $this->_iRatingCnt;
01403     }
01404 
01410     public function getBreadCrumb()
01411     {
01412         $aPaths = array();
01413 
01414         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01415 
01416             $aCatPath = array();
01417             $aCatPath['title'] = sprintf(oxLang::getInstance()->translateString( 'searchResult', oxLang::getInstance()->getBaseLanguage(), false ), oxConfig::getParameter( 'searchparam' ));
01418             $sLink = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken')
01419                    . "&amp;cl=search&amp;searchparam=" . oxConfig::getParameter( 'searchparam' );
01420 
01421             $aCatPath['link']  = $sLink;
01422 
01423             $aPaths[] = $aCatPath;
01424 
01425         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01426 
01427             $aCatPath = array();
01428 
01429             $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
01430             $aCatPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01431             $aPaths[] = $aCatPath;
01432 
01433             $oStr = getStr();
01434             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01435             $aCatPath['link']  = oxSeoEncoderTag::getInstance()->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01436             $aPaths[] = $aCatPath;
01437 
01438         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01439 
01440             $aCatPath = array();
01441             $aCatPath['title'] = oxLang::getInstance()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
01442             $aPaths[] = $aCatPath;
01443         } else {
01444 
01445             $oCatTree = $this->getCatTreePath();
01446 
01447             if ( $oCatTree ) {
01448 
01449                 foreach ( $oCatTree as $oCat ) {
01450                     $aCatPath = array();
01451 
01452                     $aCatPath['link'] = $oCat->getLink();
01453                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01454 
01455                     $aPaths[] = $aCatPath;
01456                 }
01457             }
01458         }
01459 
01460         return $aPaths;
01461     }
01462 
01472     public function addme()
01473     {
01474         $myConfig = $this->getConfig();
01475         $myUtils  = oxUtils::getInstance();
01476 
01477         //control captcha
01478         $sMac     = oxConfig::getParameter( 'c_mac' );
01479         $sMacHash = oxConfig::getParameter( 'c_mach' );
01480         $oCaptcha = $this->getCaptcha();
01481         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01482             $this->_iPriceAlarmStatus = 2;
01483             return;
01484         }
01485 
01486         $aParams = oxConfig::getParameter( 'pa' );
01487         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01488             $this->_iPriceAlarmStatus = 0;
01489             return;
01490         }
01491         $aParams['aid'] = $this->getProduct()->getId();
01492         $oCur = $myConfig->getActShopCurrencyObject();
01493         // convert currency to default
01494         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01495 
01496         $oAlarm = oxNew( "oxpricealarm" );
01497         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01498         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01499         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01500         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01501         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01502         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01503 
01504         $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
01505 
01506         $oAlarm->save();
01507 
01508         // Send Email
01509         $oEmail = oxNew( 'oxemail' );
01510         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01511     }
01512 
01518     public function getPriceAlarmStatus()
01519     {
01520         return $this->_iPriceAlarmStatus;
01521     }
01522 
01528     public function getBidPrice()
01529     {
01530         if ( $this->_sBidPrice === null ) {
01531             $this->_sBidPrice = false;
01532 
01533             $aParams = oxConfig::getParameter( 'pa' );
01534             $oCur = $this->getConfig()->getActShopCurrencyObject();
01535             $iPrice = oxUtils::getInstance()->currency2Float( $aParams['price'] );
01536             $this->_sBidPrice = oxLang::getInstance()->formatCurrency( $iPrice, $oCur );
01537         }
01538         return $this->_sBidPrice;
01539     }
01540 
01546     public function getVariantSelections()
01547     {
01548         // finding parent
01549         $oProduct = $this->getProduct();
01550         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01551             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01552         }
01553 
01554         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01555     }
01556 
01562     public function getPicturesProduct()
01563     {
01564         $aVariantSelections = $this->getVariantSelections();
01565         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01566             return $aVariantSelections['oActiveVariant'];
01567         }
01568         return $this->getProduct();
01569     }
01570 
01571 
01577     public function isMoreTagsVisible()
01578     {
01579         return true;
01580     }
01581 
01587     public function getSearchParamForHtml()
01588     {
01589         if ( $this->_sSearchParamForHtml === null ) {
01590             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01591         }
01592         return $this->_sSearchParamForHtml;
01593     }
01594 
01595 }