public function render()
 {
     parent::render();
     $this->_aViewData['edit'] = $oCategory = oxNew('oxcategory');
     // resetting
     oxSession::setVar('neworder_sess', null);
     $soxId = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oCategory->load($soxId);
         $oArticleList = oxnew('oxarticlelist');
         $oArticleList->loadCategoryArticles($soxId, array());
         $this->_aViewData['oArticleList'] = $oArticleList;
         //Disable editing for derived items
         if ($oCategory->isDerived()) {
             $this->_aViewData['readonly'] = true;
         }
     }
     if (oxConfig::getParameter("aoc")) {
         return "marm_category_order_popup.tpl";
     }
     return "marm_category_order.tpl";
 }
 protected function _zw_getFromVariant()
 {
     if ($this->_oFromVariant === null && $this->isRangePrice()) {
         $this->_oFromVariant = false;
         $sPriceSuffix = $this->_getUserPriceSufix();
         $dVarMinPrice = $this->_getVarMinPrice();
         $dPrice = $this->_getPrice();
         if ($dVarMinPrice !== null && $dPrice > $dVarMinPrice) {
             $sSql = 'SELECT oxid ';
             $sSql .= ' FROM ' . $this->getViewName(true) . '
             WHERE ' . $this->getSqlActiveSnippet(true) . '
                 AND ( `oxparentid` = ' . oxDb::getDb()->quote($this->getId()) . ' )
                 AND (`oxprice' . $sPriceSuffix . '` = ' . oxDb::getDb()->quote($dVarMinPrice) . ' )
                 Limit 1';
             $sOxid = oxdb::getDb()->getOne($sSql);
             $oVariant = oxnew('oxarticle');
             if ($sOxid && $oVariant->load($sOxid)) {
                 $this->_oFromVariant = $oVariant;
             }
         }
     }
     return $this->_oFromVariant;
 }
 public function testSendNoEditval()
 {
     $this->setRequestParameter('editval', null);
     /** @var Suggest $oSuggest */
     $oSuggest = oxnew('Suggest');
     $this->assertSame(null, $oSuggest->send());
 }
 /**
  * Testing basketItemKey setter and getter
  */
 public function testSetGetBasketItemKey()
 {
     $basketItem = oxnew('oxBasketItem');
     $basketItem->setBasketItemKey('some_key');
     $this->assertSame('some_key', $basketItem->getBasketItemKey());
 }
 /**
  * Returns true if active root category was changed
  *
  * @return bool
  */
 public function isRootCatChanged()
 {
     // in Basket
     $oBasket = $this->getSession()->getBasket();
     if ($oBasket->showCatChangeWarning()) {
         $oBasket->setCatChangeWarningState(false);
         return true;
     }
     // in Category, only then category is empty ant not equal to default category
     $sDefCat = oxRegistry::getConfig()->getActiveShop()->oxshops__oxdefcat->value;
     $sActCat = oxRegistry::getConfig()->getRequestParameter('cnid');
     $oActCat = oxnew('oxcategory');
     if ($sActCat && $sActCat != $sDefCat && $oActCat->load($sActCat)) {
         $sActRoot = $oActCat->oxcategories__oxrootid->value;
         if ($oBasket->getBasketRootCatId() && $sActRoot != $oBasket->getBasketRootCatId()) {
             return true;
         }
     }
     return false;
 }
 /**
  * Test article load.
  *
  * @return null
  */
 public function testLoad()
 {
     $this->_createArticle('_testArt');
     oxTestModules::addFunction('oxarticle', '_skipSaveFields', '{$this->_aSkipSaveFields=array();}');
     $oArticle = oxnew('oxarticle');
     $oArticle->load('_testArt');
     $oArticle->oxarticles__oxinsert = new oxField('2008/04/04');
     $oArticle->save();
     $oArticle = oxNew('oxArticle');
     $oArticle->load('_testArt');
     $sInsert = '2008-04-04';
     if ($oArticle->getLanguage() == 1) {
         $sInsert = '2008-04-04';
     }
     $this->assertEquals($sInsert, $oArticle->oxarticles__oxinsert->value);
 }
 /**
  * Test helper, fill basket for given user.
  *
  * @param oxUser $user
  * @param string $articleId
  *
  * @return oxBasket
  */
 private function _getFilledBasketForUser($user, $articleId)
 {
     $basket = oxnew('oxBasket');
     $basket->setBasketUser($user);
     $basket->addToBasket($articleId, 1);
     $basket->calculateBasket(true);
     //only saved on calculate, oxuserbaskets.oxtitle = 'savedbasket'
     $basket->onUpdate();
     $articles = $basket->getBasketSummary()->aArticles;
     $this->assertSame(1, (int) $articles[$articleId]);
     return $basket;
 }
Exemple #8
0
 /**
  * Assert that we get the expected multilanguage data for some language id >= 8.
  * Testing the case that we add the article when base language has some language id >= 8.
  */
 public function testMultilanguageViewsAddArticleInDifferentDefaultLanguage()
 {
     //add more languages and activate latest added language in frontend
     $languageId = $this->prepare();
     oxRegistry::getLang()->setBaseLanguage($languageId);
     //insert article after switching base language
     $this->insertArticle();
     //load article to have a look at e.g. it's title in the current language
     $article = oxnew('oxArticle');
     $article->disableLazyLoading();
     $article->load($this->testArticleId);
     //We stored article in switched default language
     $this->assertSame('TEST_MULTI_LANGUAGE', $article->oxarticles__oxtitle->value);
     //As article was stored in switched base language, related original base language field is empty.
     oxRegistry::getLang()->setBaseLanguage($this->originalBaseLanguageId);
     $article = oxnew('oxArticle');
     $article->disableLazyLoading();
     $article->load($this->testArticleId);
     $this->assertSame('', $article->oxarticles__oxtitle->value);
 }
 /**
  * #5720
  */
 public function testGetAltImageUrlNoDoubleSlashes()
 {
     $oPicHandler = oxnew('oxPictureHandler');
     $this->setConfigParam('sAltImageUrl', 'https://example.com');
     $this->assertEquals('https://example.com/path/nopic.jpg', $oPicHandler->getAltImageUrl('path/', 'nopic.jpg'));
     $this->setConfigParam('sAltImageUrl', 'https://example.com/');
     $this->assertEquals('https://example.com/path/nopic.jpg', $oPicHandler->getAltImageUrl('path/', 'nopic.jpg'));
 }