Go to the documentation of this file.00001 <?php
00002
00010 class oxcmp_utils extends oxView
00011 {
00012
00018 protected $_blIsComponent = true;
00019
00030 public function getArticle()
00031 {
00032 $myConfig = $this->getConfig();
00033 $myUtils = oxRegistry::getUtils();
00034
00035 if (!$myConfig->getConfigParam("blAllowRemoteArticleInfo")) {
00036 return false;
00037 }
00038
00039
00040 $sOutput = 'OXID__Problem : no valid oxid !';
00041 $oProduct = null;
00042
00043 if (($sId = oxRegistry::getConfig()->getRequestParameter('oxid'))) {
00044 $oProduct = oxNew('oxArticle');
00045 $oProduct->load($sId);
00046 } elseif ($myConfig->getConfigParam('bl_perfLoadAktion')) {
00047 $oArtList = oxNew('oxarticlelist');
00048 $oArtList->loadActionArticles('OXAFFILIATE');
00049 $oProduct = $oArtList->current();
00050 }
00051
00052 if ($oProduct) {
00053
00054 $aExport = array();
00055
00056 $aClassVars = get_object_vars($oProduct);
00057 $oStr = getStr();
00058
00059
00060 while (list($sFieldName,) = each($aClassVars)) {
00061 if ($oStr->strstr($sFieldName, 'oxarticles')) {
00062 $sName = str_replace('oxarticles__', '', $sFieldName);
00063 $aExport[$sName] = $oProduct->$sFieldName->value;
00064 }
00065 }
00066
00067 $oPrice = $oProduct->getPrice();
00068
00069 $aExport['vatPercent'] = $oPrice->getVat();
00070 $aExport['netPrice'] = $myUtils->fRound($oPrice->getNettoPrice());
00071 $aExport['brutPrice'] = $myUtils->fRound($oPrice->getBruttoPrice());
00072 $aExport['vat'] = $oPrice->getVatValue();
00073 $aExport['fprice'] = $oProduct->getFPrice();
00074 $aExport['ftprice'] = $oProduct->getFTPrice();
00075
00076 $aExport['oxdetaillink'] = $oProduct->getLink();
00077 $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
00078 $aExport['tobasketlink'] = $oProduct->getToBasketLink();
00079 $sPictureUrl = $myConfig->getPictureUrl(null, false, $myConfig->isSsl());
00080 $aExport['thumbnaillink'] = $sPictureUrl . "/" . $aExport['oxthumb'];
00081 $sOutput = serialize($aExport);
00082 }
00083
00084
00085 $myUtils->showMessageAndExit($sOutput);
00086 }
00087
00099 public function toCompareList(
00100 $sProductId = null,
00101 $dAmount = null,
00102 $aSel = null,
00103 $blOverride = false,
00104 $blBundle = false
00105 ) {
00106
00107 if ($this->getViewConfig()->getShowCompareList() && !oxRegistry::getUtils()->isSearchEngine()) {
00108
00109
00110
00111 $blAddCompare = oxRegistry::getConfig()->getRequestParameter('addcompare');
00112 $blRemoveCompare = oxRegistry::getConfig()->getRequestParameter('removecompare');
00113 $sProductId = $sProductId ? $sProductId : oxRegistry::getConfig()->getRequestParameter('aid');
00114 if (($blAddCompare || $blRemoveCompare) && $sProductId) {
00115
00116
00117 $aItems = oxRegistry::getSession()->getVariable('aFiltcompproducts');
00118 if ($blAddCompare && !isset($aItems[$sProductId])) {
00119 $aItems[$sProductId] = true;
00120 }
00121
00122 if ($blRemoveCompare) {
00123 unset($aItems[$sProductId]);
00124 }
00125
00126 oxRegistry::getSession()->setVariable('aFiltcompproducts', $aItems);
00127 $oParentView = $this->getParent();
00128
00129
00130 if (($oProduct = $oParentView->getViewProduct())) {
00131 if (isset($aItems[$oProduct->getId()])) {
00132 $oProduct->setOnComparisonList(true);
00133 } else {
00134 $oProduct->setOnComparisonList(false);
00135 }
00136 }
00137
00138 $aViewProds = $oParentView->getViewProductList();
00139 if (is_array($aViewProds) && count($aViewProds)) {
00140 foreach ($aViewProds as $oProduct) {
00141 if (isset($aItems[$oProduct->getId()])) {
00142 $oProduct->setOnComparisonList(true);
00143 } else {
00144 $oProduct->setOnComparisonList(false);
00145 }
00146 }
00147 }
00148 }
00149 }
00150 }
00151
00162 public function toNoticeList($sProductId = null, $dAmount = null, $aSel = null)
00163 {
00164 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00165 return;
00166 }
00167
00168 $this->_toList('noticelist', $sProductId, $dAmount, $aSel);
00169 }
00170
00181 public function toWishList($sProductId = null, $dAmount = null, $aSel = null)
00182 {
00183 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00184 return;
00185 }
00186
00187
00188 if ($this->getViewConfig()->getShowWishlist()) {
00189 $this->_toList('wishlist', $sProductId, $dAmount, $aSel);
00190 }
00191 }
00192
00201 protected function _toList($sListType, $sProductId, $dAmount, $aSel)
00202 {
00203
00204 if ($oUser = $this->getUser()) {
00205
00206 $sProductId = ($sProductId) ? $sProductId : oxRegistry::getConfig()->getRequestParameter('itmid');
00207 $sProductId = ($sProductId) ? $sProductId : oxRegistry::getConfig()->getRequestParameter('aid');
00208 $dAmount = isset($dAmount) ? $dAmount : oxRegistry::getConfig()->getRequestParameter('am');
00209 $aSel = $aSel ? $aSel : oxRegistry::getConfig()->getRequestParameter('sel');
00210
00211
00212 $dAmount = str_replace(',', '.', $dAmount);
00213 if (!$this->getConfig()->getConfigParam('blAllowUnevenAmounts')) {
00214 $dAmount = round(( string ) $dAmount);
00215 }
00216
00217 $oBasket = $oUser->getBasket($sListType);
00218 $oBasket->addItemToBasket($sProductId, abs($dAmount), $aSel, ($dAmount == 0));
00219
00220
00221 $oBasket->getItemCount(true);
00222 }
00223 }
00224
00230 public function render()
00231 {
00232 parent::render();
00233
00234 $myConfig = $this->getConfig();
00235 $oParentView = $this->getParent();
00236
00237
00238 $oContentList = oxNew('oxcontentlist');
00239 $oContentList->loadMainMenulist();
00240 $oParentView->setMenueList($oContentList);
00241
00242 return;
00243 }
00244 }