/**
  * 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');
 }
示例#2
0
 /**
  * deletes article seo entries
  *
  * @param oxArticle $oArticle article to remove
  */
 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}");
 }
示例#3
0
 /**
  * loads 'Recommendation lists' rss data
  *
  * @param oxArticle $oArticle load lists for this article
  *
  * @return null
  */
 public function loadRecommLists(oxArticle $oArticle)
 {
     if ($this->_aChannel = $this->_loadFromCache(self::RSS_ARTRECOMMLISTS . $oArticle->getId())) {
         return;
     }
     $oConfig = $this->getConfig();
     $oConfig->setConfigParam('iNrofCrossellArticles', $oConfig->getConfigParam('iRssItemsCount'));
     $oList = oxNew('oxrecommlist')->getRecommListsByIds(array($oArticle->getId()));
     if ($oList == null) {
         $oList = oxNew('oxlist');
     }
     $oLang = oxRegistry::getLang();
     $this->_loadData(self::RSS_ARTRECOMMLISTS . $oArticle->getId(), $this->getRecommListsTitle($oArticle), sprintf($oLang->translateString('LISTMANIA_LIST_FOR', $oLang->getBaseLanguage()), $oArticle->oxarticles__oxtitle->value), $this->_getRecommListItems($oList), $this->getRecommListsUrl($oArticle), $oArticle->getLink());
 }
示例#4
0
 /**
  * return Vat value for oxcategory type assignment only
  *
  * @param oxArticle $oArticle given article
  *
  * @return float | false
  */
 protected function _getVatForArticleCategory(oxArticle $oArticle)
 {
     $oDb = oxDb::getDb();
     $sCatT = getViewName('oxcategories');
     if ($this->_blCatVatSet === null) {
         $sSelect = "SELECT oxid FROM {$sCatT} WHERE oxvat IS NOT NULL LIMIT 1";
         //no category specific vats in shop?
         //then for performance reasons we just return false
         $this->_blCatVatSet = (bool) $oDb->getOne($sSelect);
     }
     if (!$this->_blCatVatSet) {
         return false;
     }
     $sO2C = getViewName('oxobject2category');
     $sSql = "SELECT c.oxvat\n                 FROM {$sCatT} AS c, {$sO2C} AS o2c\n                 WHERE c.oxid=o2c.oxcatnid AND\n                       o2c.oxobjectid = " . $oDb->quote($oArticle->getId()) . " AND\n                       c.oxvat IS NOT NULL\n                 ORDER BY o2c.oxtime ";
     $fVat = $oDb->getOne($sSql);
     if ($fVat !== false && $fVat !== null) {
         return $fVat;
     }
     return false;
 }
示例#5
0
 /**
  * Returns product tags array for given language
  *
  * @param oxArticle $oArticle Article object
  * @param int       $iLang    language id
  *
  * @return array
  */
 protected function _getTagList($oArticle, $iLang)
 {
     $oArticleTagList = oxNew("oxarticletaglist");
     $oArticleTagList->setLanguage($iLang);
     $oArticleTagList->load($oArticle->getId());
     $aTagsList = array();
     if (count($aTags = $oArticleTagList->getArray())) {
         $sShopId = $this->getConfig()->getShopId();
         $iProdId = $oArticle->getId();
         foreach ($aTags as $sTitle => $oTagObject) {
             // A. we do not have oxTag object yet, so reusing manufacturers for general interface
             $oTag = oxNew("oxManufacturer");
             $oTag->setLanguage($iLang);
             $oTag->setId(md5(strtolower($sShopId . $this->_getStdUrl($iProdId, "oxtag", "tag", $iLang, $sTitle))));
             $oTag->oxmanufacturers__oxtitle = new oxField($sTitle);
             $aTagsList[] = $oTag;
         }
     }
     return $aTagsList;
 }
 /**
  * Returns products main category id
  *
  * @param oxArticle $oArticle product
  *
  * @return string
  */
 protected function _getMainCategory($oArticle)
 {
     $oMainCat = null;
     // if variant parent id must be used
     $sArtId = $oArticle->getId();
     if (isset($oArticle->oxarticles__oxparentid->value) && $oArticle->oxarticles__oxparentid->value) {
         $sArtId = $oArticle->oxarticles__oxparentid->value;
     }
     $oDb = oxDb::getDb();
     // add manin category chaching;
     $sQ = "select oxcatnid from " . getViewName("oxobject2category") . " where oxobjectid = " . $oDb->quote($sArtId) . " order by oxtime";
     $sIdent = md5($sQ);
     if (($sMainCatId = $this->_loadFromCache($sIdent, "oxarticle")) === false) {
         $sMainCatId = $oDb->getOne($sQ);
         // storing in cache
         $this->_saveInCache($sIdent, $sMainCatId, "oxarticle");
     }
     if ($sMainCatId) {
         $oMainCat = oxNew("oxcategory");
         if (!$oMainCat->load($sMainCatId)) {
             $oMainCat = null;
         }
     }
     return $oMainCat;
 }