/** * 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; }
/** * 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); } } } }
/** * 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; }
/** * Loads article default category * * @param oxarticle $oArticle Article object * * @return record set */ public function getDefaultCategoryString($oArticle) { $sLang = oxRegistry::getLang()->getBaseLanguage(); $oDB = oxDb::getDb(); $sCatView = getViewName('oxcategories', $sLang); $sO2CView = getViewName('oxobject2category', $sLang); //selecting category $sQ = "select {$sCatView}.oxtitle from {$sO2CView} as oxobject2category left join {$sCatView} on {$sCatView}.oxid = oxobject2category.oxcatnid "; $sQ .= "where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) . " and {$sCatView}.oxactive = 1 order by oxobject2category.oxtime "; return $oDB->getOne($sQ); }
/** * Converts a oxarticle object to an EMOS_Item * * @param oxarticle $oProduct article to convert * @param string $sCatPath category path * @param int $iQty buyable amount * * @return EMOS_Item */ protected function _convProd2EmosItem($oProduct, $sCatPath = "NULL", $iQty = 1) { $oItem = $this->_getNewEmosItem(); $sProductId = isset($oProduct->oxarticles__oxartnum->value) && $oProduct->oxarticles__oxartnum->value ? $oProduct->oxarticles__oxartnum->value : $oProduct->getId(); $oItem->productId = $this->_convertToUtf($sProductId); $oItem->productName = $this->_prepareProductTitle($oProduct); // #810A $oCur = $this->getConfig()->getActShopCurrencyObject(); $oItem->price = $oProduct->getPrice()->getBruttoPrice() * (1 / $oCur->rate); $oItem->productGroup = "{$sCatPath}/{$this->_convertToUtf($oProduct->oxarticles__oxtitle->value)}"; $oItem->quantity = $iQty; // #3452: Add brands to econda tracking $oItem->variant1 = $oProduct->getVendor() ? $this->_convertToUtf($oProduct->getVendor()->getTitle()) : "NULL"; $oItem->variant2 = $oProduct->getManufacturer() ? $this->_convertToUtf($oProduct->getManufacturer()->getTitle()) : "NULL"; $oItem->variant3 = $oProduct->getId(); return $oItem; }
/** * 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; }
/** * 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}"); }