oxerptype_articlestock.php

Go to the documentation of this file.
00001 <?php
00002 
00003 require_once 'oxerptype.php';
00004 
00008 class oxERPType_ArticleStock extends oxERPType
00009 {
00015     public function __construct()
00016     {
00017         parent::__construct();
00018 
00019         $this->_sTableName      = 'oxarticles';
00020         $this->_sShopObjectName = 'oxarticle';
00021         $this->_blRestrictedByShopId = true;
00022 
00023         $this->_aFieldList = array(
00024             'OXID'           => 'OXID',
00025             'OXSTOCK'        => 'OXSTOCK',
00026         );
00027     }
00028 
00036     public function checkWriteAccess($sOxid)
00037     {
00038         //extend the write access to NOT write into nonexisting articles
00039 
00040         $myConfig = oxConfig::getInstance();
00041 
00042         $oDB = oxDb::getDb();
00043 
00044         $sSql = "select oxid from ". $this->getTableName($myConfig->getShopId()) ." where oxid = ".$oDB->quote( $sOxid );
00045         $sRes = $oDB->getOne($sSql);
00046 
00047         if ( !$sRes ) {
00048             throw new Exception( oxERPBase::$ERROR_OBJECT_NOT_EXISTING);
00049         }
00050 
00051         parent::checkWriteAccess($sOxid);
00052     }
00053 
00054 
00065     protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00066     {
00067         $oCompat = oxNew('OXERPCompatability');
00068         if ( !$oCompat->isArticleNullLongDescComatable() ) {
00069 
00070             $aLongDescriptionFields = array('OXLONGDESC_1','OXLONGDESC_2','OXLONGDESC_3');
00071 
00072             foreach ( $aLongDescriptionFields as $iKey => $sField ) {
00073                 if ( in_array( $sField, $this->_aFieldList ) ) {
00074                     unset($aLongDescriptionFields[$iKey]);
00075                 }
00076             }
00077 
00078             if ( count($aLongDescriptionFields ) ) {
00079                 $oArtExt = oxNew('oxbase');
00080                 $oArtExt->init('oxartextends');
00081 
00082                 if ( $oArtExt->load($aData['OXID'] ) ) {
00083                     foreach ($aLongDescriptionFields as $sField) {
00084                         $sFieldName = $oArtExt->getCoreTableName()."__".strtolower( $sField );
00085                         $sLongDesc  = null;
00086 
00087                         if ($oArtExt->$sFieldName instanceof oxField) {
00088                             $sLongDesc = $oArtExt->$sFieldName->getRawValue();
00089                         } elseif (is_object($oArtExt->$sFieldName)) {
00090                             $sLongDesc = $oArtExt->$sFieldName->value;
00091                         }
00092 
00093                         if ( isset($sLongDesc) ) {
00094                             $aData[$sField] = $sLongDesc;
00095                         }
00096                     }
00097                 }
00098             }
00099         }
00100 
00101         return parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00102     }
00103 
00104 }