OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
oxcmp_utils.php
Go to the documentation of this file.
1 <?php
2 
10 class oxcmp_utils extends oxView
11 {
12 
18  protected $_blIsComponent = true;
19 
30  public function getArticle()
31  {
32  $myConfig = $this->getConfig();
33  $myUtils = oxRegistry::getUtils();
34 
35  if (!$myConfig->getConfigParam("blAllowRemoteArticleInfo")) {
36  return false;
37  }
38 
39 
40  $sOutput = 'OXID__Problem : no valid oxid !';
41  $oProduct = null;
42 
43  if (($sId = oxRegistry::getConfig()->getRequestParameter('oxid'))) {
44  $oProduct = oxNew('oxArticle');
45  $oProduct->load($sId);
46  } elseif ($myConfig->getConfigParam('bl_perfLoadAktion')) {
47  $oArtList = oxNew('oxarticlelist');
48  $oArtList->loadActionArticles('OXAFFILIATE');
49  $oProduct = $oArtList->current();
50  }
51 
52  if ($oProduct) {
53 
54  $aExport = array();
55 
56  $aClassVars = get_object_vars($oProduct);
57  $oStr = getStr();
58 
59  // add all database fields
60  while (list($sFieldName,) = each($aClassVars)) {
61  if ($oStr->strstr($sFieldName, 'oxarticles')) {
62  $sName = str_replace('oxarticles__', '', $sFieldName);
63  $aExport[$sName] = $oProduct->$sFieldName->value;
64  }
65  }
66 
67  $oPrice = $oProduct->getPrice();
68 
69  $aExport['vatPercent'] = $oPrice->getVat();
70  $aExport['netPrice'] = $myUtils->fRound($oPrice->getNettoPrice());
71  $aExport['brutPrice'] = $myUtils->fRound($oPrice->getBruttoPrice());
72  $aExport['vat'] = $oPrice->getVatValue();
73  $aExport['fprice'] = $oProduct->getFPrice();
74  $aExport['ftprice'] = $oProduct->getFTPrice();
75 
76  $aExport['oxdetaillink'] = $oProduct->getLink();
77  $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
78  $aExport['tobasketlink'] = $oProduct->getToBasketLink();
79  $sPictureUrl = $myConfig->getPictureUrl(null, false, $myConfig->isSsl());
80  $aExport['thumbnaillink'] = $sPictureUrl . "/" . $aExport['oxthumb'];
81  $sOutput = serialize($aExport);
82  }
83 
84  // stop shop here
85  $myUtils->showMessageAndExit($sOutput);
86  }
87 
99  public function toCompareList(
100  $sProductId = null,
101  $dAmount = null,
102  $aSel = null,
103  $blOverride = false,
104  $blBundle = false
105  ) {
106  // only if enabled and not search engine..
107  if ($this->getViewConfig()->getShowCompareList() && !oxRegistry::getUtils()->isSearchEngine()) {
108 
109 
110  // #657 special treatment if we want to put on comparelist
111  $blAddCompare = oxRegistry::getConfig()->getRequestParameter('addcompare');
112  $blRemoveCompare = oxRegistry::getConfig()->getRequestParameter('removecompare');
113  $sProductId = $sProductId ? $sProductId : oxRegistry::getConfig()->getRequestParameter('aid');
114  if (($blAddCompare || $blRemoveCompare) && $sProductId) {
115 
116  // toggle state in session array
117  $aItems = oxRegistry::getSession()->getVariable('aFiltcompproducts');
118  if ($blAddCompare && !isset($aItems[$sProductId])) {
119  $aItems[$sProductId] = true;
120  }
121 
122  if ($blRemoveCompare) {
123  unset($aItems[$sProductId]);
124  }
125 
126  oxRegistry::getSession()->setVariable('aFiltcompproducts', $aItems);
127  $oParentView = $this->getParent();
128 
129  // #843C there was problem then field "blIsOnComparisonList" was not set to article object
130  if (($oProduct = $oParentView->getViewProduct())) {
131  if (isset($aItems[$oProduct->getId()])) {
132  $oProduct->setOnComparisonList(true);
133  } else {
134  $oProduct->setOnComparisonList(false);
135  }
136  }
137 
138  $aViewProds = $oParentView->getViewProductList();
139  if (is_array($aViewProds) && count($aViewProds)) {
140  foreach ($aViewProds as $oProduct) {
141  if (isset($aItems[$oProduct->getId()])) {
142  $oProduct->setOnComparisonList(true);
143  } else {
144  $oProduct->setOnComparisonList(false);
145  }
146  }
147  }
148  }
149  }
150  }
151 
162  public function toNoticeList($sProductId = null, $dAmount = null, $aSel = null)
163  {
164  if (!oxRegistry::getSession()->checkSessionChallenge()) {
165  return;
166  }
167 
168  $this->_toList('noticelist', $sProductId, $dAmount, $aSel);
169  }
170 
181  public function toWishList($sProductId = null, $dAmount = null, $aSel = null)
182  {
183  if (!oxRegistry::getSession()->checkSessionChallenge()) {
184  return;
185  }
186 
187  // only if enabled
188  if ($this->getViewConfig()->getShowWishlist()) {
189  $this->_toList('wishlist', $sProductId, $dAmount, $aSel);
190  }
191  }
192 
201  protected function _toList($sListType, $sProductId, $dAmount, $aSel)
202  {
203  // only if user is logged in
204  if ($oUser = $this->getUser()) {
205 
206  $sProductId = ($sProductId) ? $sProductId : oxRegistry::getConfig()->getRequestParameter('itmid');
207  $sProductId = ($sProductId) ? $sProductId : oxRegistry::getConfig()->getRequestParameter('aid');
208  $dAmount = isset($dAmount) ? $dAmount : oxRegistry::getConfig()->getRequestParameter('am');
209  $aSel = $aSel ? $aSel : oxRegistry::getConfig()->getRequestParameter('sel');
210 
211  // processing amounts
212  $dAmount = str_replace(',', '.', $dAmount);
213  if (!$this->getConfig()->getConfigParam('blAllowUnevenAmounts')) {
214  $dAmount = round(( string ) $dAmount);
215  }
216 
217  $oBasket = $oUser->getBasket($sListType);
218  $oBasket->addItemToBasket($sProductId, abs($dAmount), $aSel, ($dAmount == 0));
219 
220  // recalculate basket count
221  $oBasket->getItemCount(true);
222  }
223  }
224 
230  public function render()
231  {
232  parent::render();
233 
234  $myConfig = $this->getConfig();
235  $oParentView = $this->getParent();
236 
237  // add content for main menu
238  $oContentList = oxNew('oxcontentlist');
239  $oContentList->loadMainMenulist();
240  $oParentView->setMenueList($oContentList);
241 
242  return;
243  }
244 }