Пример #1
0
 /**
  * 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');
 }
 /**
  * Creates articles from array
  *
  * @param array $aArticles
  *
  * @return array $aResult of id's and basket amounts of created articles
  */
 public function createArticles($aArticles)
 {
     $aResult = array();
     if (empty($aArticles)) {
         return $aResult;
     }
     foreach ($aArticles as $aArticle) {
         $oArticle = new oxArticle();
         $oArticle->setId($aArticle['oxid']);
         foreach ($aArticle as $sKey => $sValue) {
             if (strstr($sKey, "ox")) {
                 $sField = "oxarticles__{$sKey}";
                 $oArticle->{$sField} = new oxField($aArticle[$sKey]);
             }
         }
         $oArticle->save();
         if ($aArticle['scaleprices']) {
             $this->_createScalePrices(array($aArticle['scaleprices']));
         }
         if ($aArticle['field2shop']) {
             $this->_createField2Shop($oArticle, $aArticle['field2shop']);
         }
         $aResult[$aArticle['oxid']] = array('id' => $aArticle['oxid'], 'amount' => $aArticle['amount']);
     }
     return $aResult;
 }