Ejemplo n.º 1
0
 /**
  * If passed article ID (by URL or posted form) - loads article,
  * otherwise - loads list of action articles oxarticlelist::loadAktionArticles().
  * In this case, the last list object will be used. Loaded article info
  * is serialized and outputted to client system.
  *
  * @return null
  */
 public function getArticle()
 {
     $myConfig = $this->getConfig();
     $myUtils = oxUtils::getInstance();
     if (!$myConfig->getConfigParam("blAllowRemoteArticleInfo")) {
         return false;
     }
     $sOutput = 'OXID__Problem : no valid oxid !';
     $oProduct = null;
     if ($sId = oxConfig::getParameter('oxid')) {
         $oProduct = oxNewArticle($sId);
     } elseif ($myConfig->getConfigParam('bl_perfLoadAktion')) {
         $oArtList = oxNew('oxarticlelist');
         $oArtList->loadAktionArticles('OXAFFILIATE');
         $oProduct = $oArtList->current();
     }
     if ($oProduct) {
         $aExport = array();
         $aClassVars = get_object_vars($oProduct);
         $oStr = getStr();
         // add all database fields
         while (list($sFieldName, ) = each($aClassVars)) {
             if ($oStr->strstr($sFieldName, 'oxarticles')) {
                 $sName = str_replace('oxarticles__', '', $sFieldName);
                 $aExport[$sName] = $oProduct->{$sFieldName}->value;
             }
         }
         $oPrice = $oProduct->getPrice();
         $aExport['vatPercent'] = $oPrice->getVat();
         $aExport['netPrice'] = $myUtils->fRound($oPrice->getNettoPrice());
         $aExport['brutPrice'] = $myUtils->fRound($oPrice->getBruttoPrice());
         $aExport['vat'] = $oPrice->getVatValue();
         $aExport['fprice'] = $oProduct->getFPrice();
         $aExport['ftprice'] = $oProduct->getFTPrice();
         $aExport['oxdetaillink'] = $oProduct->getLink();
         $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
         $aExport['tobasketlink'] = $oProduct->getToBasketLink();
         $aExport['thumbnaillink'] = $myConfig->getPictureUrl(null, false, $myConfig->isSsl()) . "/" . $aExport['oxthumb'];
         $sOutput = serialize($aExport);
     }
     // stop shop here
     $myUtils->showMessageAndExit($sOutput);
 }
Ejemplo n.º 2
0
 /**
  * Template variable getter. Returns active product
  *
  * @return oxarticle
  */
 public function getProduct()
 {
     if ($this->_oProduct === null) {
         $this->_oProduct = oxNewArticle(oxConfig::getParameter('anid'));
     }
     return $this->_oProduct;
 }
Ejemplo n.º 3
0
 /**
  * Returns current product parent article object if it is available
  *
  * @param string $sParentId parent product id
  *
  * @return oxarticle
  */
 protected function _getParentProduct($sParentId)
 {
     if ($sParentId && $this->_oParentProd === null) {
         $this->_oParentProd = false;
         if ($oParent = oxNewArticle($sParentId)) {
             $this->_processProduct($oParent);
             $this->_oParentProd = $oParent;
         }
     }
     return $this->_oParentProd;
 }
Ejemplo n.º 4
0
 /**
  * Recursive function. Updates quantity of sold articles.
  * Return true on success
  *
  * @param double $dAmount Number of articles sold
  *
  * @return bool
  */
 public function updateSoldAmount($dAmount = 0)
 {
     if (!$dAmount) {
         return;
     }
     $this->beforeUpdate();
     // article is not variant - should be updated current amount
     if (!$this->oxarticles__oxparentid->value) {
         //updating by SQL query, due to wrong behaviour if saving article using not admin mode
         $dAmount = (double) $dAmount;
         $oDb = oxDb::getDb();
         $rs = $oDb->execute("update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + {$dAmount} where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
     } elseif ($this->oxarticles__oxparentid->value) {
         // article is variant - should be updated this article parent amount
         $oUpdateArticle = oxNewArticle($this->oxarticles__oxparentid->value);
         $oUpdateArticle->updateSoldAmount($dAmount);
     }
     $this->onChange(ACTION_UPDATE);
     return $rs;
 }