/**
  * Returns SEO uri for passed article.
  *
  * @param oxarticle $oArticle Article object.
  * @param string    $sActCatId
  */
 public function pingArticleCategoryUrl($oArticle, $sActCatId)
 {
     $oActCat = $this->getCategoryById($sActCatId);
     $iLang = $oArticle->getLanguage();
     if (!($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $sActCatId, true))) {
         if ($oActCat) {
             $blInCat = false;
             if ($oActCat->isPriceCategory()) {
                 $blInCat = $oArticle->inPriceCategory($sActCatId);
             } else {
                 $blInCat = $oArticle->inCategory($sActCatId);
             }
             if ($blInCat) {
                 $this->_createArticleCategoryUri($oArticle, $oActCat, $iLang);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Returns variant parent object
  *
  * @param string $sParentId parent product id
  *
  * @return oxarticle
  */
 protected function _getProductParent($sParentId)
 {
     if ($this->_oProductParent === null || $this->_oProductParent !== false && $this->_oProductParent->getId() != $sParentId) {
         $this->_oProductParent = false;
         $oProduct = oxNew("oxArticle");
         if ($oProduct->load($sParentId)) {
             $this->_oProductParent = $oProduct;
         }
     }
     return $this->_oProductParent;
 }
Esempio n. 3
0
 /**
  * Returns part of query for discount check. If product is variant - query contains both id check e.g.
  * "and (oxobjectid = '...' or oxobjectid = '...')
  *
  * @param oxarticle $oProduct product used for discount check
  *
  * @return string
  */
 protected function _getProductCheckQuery($oProduct)
 {
     $oDb = oxDb::getDb();
     // check if this article is assigned
     if ($sParentId = $oProduct->getParentId()) {
         $sArticleId = " and ( oxobjectid = " . $oDb->quote($oProduct->getProductId()) . " or oxobjectid = " . $oDb->quote($sParentId) . " )";
     } else {
         $sArticleId = " and oxobjectid = " . $oDb->quote($oProduct->getProductId());
     }
     return $sArticleId;
 }
Esempio n. 4
0
 /**
  * Searches for current article in article list and sets previous/next product ids
  *
  * @param oxarticle $oArticle       current Article
  * @param object    $oIdList        articles list containing only fake article objects !!!
  * @param oxubase   $oLocatorTarget oxubase object
  *
  * @return integer
  */
 protected function _getProductPos($oArticle, $oIdList, $oLocatorTarget)
 {
     $iCnt = 1;
     $iPos = 0;
     // variant handling
     $sOxid = $oArticle->oxarticles__oxparentid->value ? $oArticle->oxarticles__oxparentid->value : $oArticle->getId();
     if ($oIdList->count() && isset($oIdList[$sOxid])) {
         $aIds = $oIdList->arrayKeys();
         $iPos = oxRegistry::getUtils()->arrayStringSearch($sOxid, $aIds);
         if (array_key_exists($iPos - 1, $aIds)) {
             $oBackProduct = oxNew('oxArticle');
             $oBackProduct->modifyCacheKey('_locator');
             $oBackProduct->setNoVariantLoading(true);
             if ($oBackProduct->load($aIds[$iPos - 1])) {
                 $oBackProduct->setLinkType($oLocatorTarget->getLinkType());
                 $this->_oBackProduct = $oBackProduct;
             }
         }
         if (array_key_exists($iPos + 1, $aIds)) {
             $oNextProduct = oxNew('oxArticle');
             $oNextProduct->modifyCacheKey('_locator');
             $oNextProduct->setNoVariantLoading(true);
             if ($oNextProduct->load($aIds[$iPos + 1])) {
                 $oNextProduct->setLinkType($oLocatorTarget->getLinkType());
                 $this->_oNextProduct = $oNextProduct;
             }
         }
         return $iPos + 1;
     }
     return 0;
 }
 /**
  * Returns array containing default list type and category (or manufacturer ir vendor) id
  *
  * @param oxarticle $oProduct current product object
  *
  * @return array
  */
 protected function _getDefaultParams($oProduct)
 {
     $sListType = null;
     $aArticleCats = $oProduct->getCategoryIds(true);
     if (is_array($aArticleCats) && count($aArticleCats)) {
         $sActCat = reset($aArticleCats);
     } elseif ($sActCat = $oProduct->getManufacturerId()) {
         // not assigned to any category ? maybe it is assigned to Manufacturer ?
         $sListType = 'manufacturer';
     } elseif ($sActCat = $oProduct->getVendorId()) {
         // not assigned to any category ? maybe it is assigned to vendor ?
         $sListType = 'vendor';
     } else {
         $sActCat = null;
     }
     return array($sListType, $sActCat);
 }
Esempio n. 6
0
 /**
  * sets detail link for campaigns
  *
  * @param oxarticle $oArticle article object
  *
  * @return oxarticle
  */
 protected function _setCampaignDetailLink($oArticle)
 {
     // #827
     if ($sCampaign = oxRegistry::getConfig()->getRequestParameter("sExportCampaign")) {
         // modify detaillink
         //#1166R - pangora - campaign
         $oArticle->appendLink("campaign={$sCampaign}");
         if (oxRegistry::getConfig()->getRequestParameter("blAppendCatToCampaign") && ($sCat = $this->getCategoryString($oArticle))) {
             $oArticle->appendLink("/{$sCat}");
         }
     }
     return $oArticle;
 }
Esempio n. 7
0
 /**
  * Builds basket product category path
  *
  * @param oxarticle $oArticle article to build category id
  *
  * @return string
  */
 protected function _getBasketProductCatPath($oArticle)
 {
     $sCatPath = '';
     if ($oCategory = $oArticle->getCategory()) {
         $sTable = $oCategory->getViewName();
         $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
         $sQ = "select {$sTable}.oxtitle as oxtitle from {$sTable}\n                       where {$sTable}.oxleft <= " . $oDb->quote($oCategory->oxcategories__oxleft->value) . " and\n                             {$sTable}.oxright >= " . $oDb->quote($oCategory->oxcategories__oxright->value) . " and\n                             {$sTable}.oxrootid = " . $oDb->quote($oCategory->oxcategories__oxrootid->value) . "\n                       order by {$sTable}.oxleft";
         $oRs = $oDb->execute($sQ);
         if ($oRs != false && $oRs->recordCount() > 0) {
             while (!$oRs->EOF) {
                 if ($sCatPath) {
                     $sCatPath .= '/';
                 }
                 $sCatPath .= strip_tags($oRs->fields['oxtitle']);
                 $oRs->moveNext();
             }
         }
     }
     $sCatPath = $this->_convertToUtf($sCatPath);
     return $sCatPath;
 }
Esempio n. 8
0
 /**
  * Returns array of product categories
  *
  * @param oxarticle $oArticle Article object
  *
  * @return array
  */
 protected function _getCategoryList($oArticle)
 {
     $sMainCatId = false;
     if ($oMainCat = $oArticle->getCategory()) {
         $sMainCatId = $oMainCat->getId();
     }
     $aCatList = array();
     $iLang = $this->getEditLang();
     // adding categories
     $sView = getViewName('oxobject2category');
     $oDb = oxDb::getDb(oxDB::FETCH_MODE_ASSOC);
     $sSqlForPriceCategories = $oArticle->getSqlForPriceCategories('oxid');
     $sQuotesArticleId = $oDb->quote($oArticle->getId());
     $sQ = "select oxobject2category.oxcatnid as oxid from {$sView} as oxobject2category " . "where oxobject2category.oxobjectid=" . $sQuotesArticleId . " union " . $sSqlForPriceCategories;
     $oRs = $oDb->execute($sQ);
     if ($oRs != false && $oRs->recordCount() > 0) {
         while (!$oRs->EOF) {
             $oCat = oxNew('oxCategory');
             if ($oCat->loadInLang($iLang, current($oRs->fields))) {
                 if ($sMainCatId == $oCat->getId()) {
                     $sSuffix = oxRegistry::getLang()->translateString('(main category)', $this->getEditLang());
                     $sTitleField = 'oxcategories__oxtitle';
                     $sTitle = $oCat->{$sTitleField}->getRawValue() . " " . $sSuffix;
                     $oCat->{$sTitleField} = new oxField($sTitle, oxField::T_RAW);
                 }
                 $aCatList[] = $oCat;
             }
             $oRs->moveNext();
         }
     }
     return $aCatList;
 }
Esempio n. 9
0
 /**
  * Forms query to load variants.
  *
  * @param bool                      $blRemoveNotOrderables
  * @param bool                      $forceCoreTableUsage
  * @param oxSimpleVariant|oxarticle $baseObject
  * @param string                    $sArticleTable
  *
  * @return string
  */
 protected function getLoadVariantsQuery($blRemoveNotOrderables, $forceCoreTableUsage, $baseObject, $sArticleTable)
 {
     return "select " . $baseObject->getSelectFields($forceCoreTableUsage) . " from {$sArticleTable} where " . $this->getActiveCheckQuery($forceCoreTableUsage) . $this->getVariantsQuery($blRemoveNotOrderables, $forceCoreTableUsage) . " order by {$sArticleTable}.oxsort";
 }
 /**
  * deletes article seo entries
  *
  * @param oxarticle $oArticle article to remove
  *
  * @return null
  */
 public function onDeleteArticle($oArticle)
 {
     $oDb = oxDb::getDb();
     $sIdQuoted = $oDb->quote($oArticle->getId());
     $oDb->execute("delete from oxseo where oxobjectid = {$sIdQuoted} and oxtype = 'oxarticle'");
     $oDb->execute("delete from oxobject2seodata where oxobjectid = {$sIdQuoted}");
 }