/** * Initialize the fixture. */ protected function setUp() { parent::setUp(); // demo article $sId = $this->getTestConfig()->getShopEdition() == 'EE' ? '2275' : '2077'; $sNewId = oxUtilsObject::getInstance()->generateUId(); $this->oArticle = oxNew('oxArticle'); $this->oArticle->disableLazyLoading(); $this->oArticle->Load($sId); // making copy $this->oArticle->setId($sNewId); $this->oArticle->oxarticles__oxweight = new oxField(10, oxField::T_RAW); $this->oArticle->oxarticles__oxstock = new oxField(100, oxField::T_RAW); $this->oArticle->oxarticles__oxprice = new oxField(19, oxField::T_RAW); $this->oArticle->oxarticles__oxstockflag = new oxField(2, oxField::T_RAW); $this->oArticle->save(); // demo category $sId = $this->getTestConfig()->getShopEdition() == 'EE' ? '30e44ab82c03c3848.49471214' : '8a142c3e4143562a5.46426637'; $sNewId = oxUtilsObject::getInstance()->generateUId(); $this->oCategory = oxNew('oxBase'); $this->oCategory->Init('oxcategories'); $this->oCategory->Load($sId); // making copy $this->oCategory->setId($sNewId); $this->oCategory->save(); // assigning article to category $oO2Group = oxNew('oxobject2category'); $oO2Group->oxobject2category__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW); $oO2Group->oxobject2category__oxobjectid = new oxField($this->oArticle->getId(), oxField::T_RAW); $oO2Group->oxobject2category__oxcatnid = new oxField($this->oCategory->getId(), oxField::T_RAW); $oO2Group->save(); $this->dDefaultVAT = $this->getConfig()->getConfigParam('dDefaultVAT'); $this->getConfig()->setConfigParam('dDefaultVAT', '99'); }
/** * Returns new seo url including the model no. * * * @param oxArticle $oArticle article object * @param oxCategory $oCategory category object * @param int $iLang language to generate uri for * * @return string */ protected function _createArticleCategoryUri($oArticle, $oCategory, $iLang) { startProfile(__FUNCTION__); $oArticle = $this->_getProductForLang($oArticle, $iLang); // create title part for uri $sTitle = $this->_prepareArticleTitle($oArticle); $sTitle = str_replace($this->_getUrlExtension(), " " . $oArticle->oxarticles__oxartnum->value, $sTitle) . "." . $this->_getUrlExtension(); // writing category path $sSeoUri = $this->_processSeoUrl($sTitle, $oArticle->getId(), $iLang); $sCatId = $oCategory->getId(); $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), array('cnid' => $sCatId)), $sSeoUri, $iLang, null, 0, $sCatId); stopProfile(__FUNCTION__); return $sSeoUri; }
/** * loadCategoryArticles loads 'Category Articles' rss data * * @param oxCategory $oCat category object * * @access public * * @return void */ public function loadCategoryArticles(oxCategory $oCat) { $sId = $oCat->getId(); if ($this->_aChannel = $this->_loadFromCache(self::RSS_CATARTS . $sId)) { return; } $oArtList = oxNew('oxarticlelist'); $oArtList->setCustomSorting('oc.oxtime desc'); $oArtList->loadCategoryArticles($oCat->getId(), null, $this->getConfig()->getConfigParam('iRssItemsCount')); $oLang = oxRegistry::getLang(); $this->_loadData(self::RSS_CATARTS . $sId, $this->getCategoryArticlesTitle($oCat), sprintf($oLang->translateString('S_CATEGORY_PRODUCTS', $oLang->getBaseLanguage()), $oCat->oxcategories__oxtitle->value), $this->_getArticleItems($oArtList), $this->getCategoryArticlesUrl($oCat), $oCat->getLink()); }
/** * deletes Category seo entries * * @param oxCategory $oCategory Category object */ public function onDeleteCategory($oCategory) { $oDb = oxDb::getDb(); $sIdQuoted = $oDb->quote($oCategory->getId()); $oDb->execute("update oxseo, (select oxseourl from oxseo where oxobjectid = {$sIdQuoted} and oxtype = 'oxcategory') as test set oxseo.oxexpired=1 where oxseo.oxseourl like concat(test.oxseourl, '%') and (oxtype = 'oxcategory' or oxtype = 'oxarticle')"); $oDb->execute("delete from oxseo where oxseo.oxtype = 'oxarticle' and oxseo.oxparams = {$sIdQuoted}"); $oDb->execute("delete from oxseo where oxobjectid = {$sIdQuoted} and oxtype = 'oxcategory'"); $oDb->execute("delete from oxobject2seodata where oxobjectid = {$sIdQuoted}"); }