oxerptype_article.php

Go to the documentation of this file.
00001 <?php
00002 
00003 require_once 'oxerptype.php';
00004 
00008 class oxERPType_Article extends oxERPType
00009 {
00014     protected $_aFieldListVersions = array (
00015         '1' => array(
00016             'OXSHOPID'         => 'OXSHOPID',
00017             'OXSHOPINCL'       => 'OXSHOPINCL',
00018             'OXSHOPEXCL'       => 'OXSHOPEXCL',
00019             'OXPARENTID'       => 'OXPARENTID',
00020             'OXACTIV'          => 'OXACTIV',
00021             'OXACTIVFROM'      => 'OXACTIVFROM',
00022             'OXACTIVTO'        => 'OXACTIVTO',
00023             'OXARTNUM'         => 'OXARTNUM',
00024             'OXEAN'            => 'OXEAN',
00025             'OXDISTEAN'        => 'OXDISTEAN',
00026             'OXMPN'            => 'OXMPN',
00027             'OXTITLE'          => 'OXTITLE',
00028             'OXSHORTDESC'      => 'OXSHORTDESC',
00029             'OXLONGDESC'       => 'OXLONGDESC',
00030             'OXPRICE'          => 'OXPRICE',
00031             'OXBLFIXEDPRICE'   => 'OXBLFIXEDPRICE',
00032             'OXPRICEA'         => 'OXPRICEA',
00033             'OXPRICEB'         => 'OXPRICEB',
00034             'OXPRICEC'         => 'OXPRICEC',
00035             'OXBPRICE'         => 'OXBPRICE',
00036             'OXTPRICE'         => 'OXTPRICE',
00037             'OXUNITNAME'       => 'OXUNITNAME',
00038             'OXUNITQUANTITY'   => 'OXUNITQUANTITY',
00039             'OXEXTURL'         => 'OXEXTURL',
00040             'OXURLDESC'        => 'OXURLDESC',
00041             'OXURLIMG'         => 'OXURLIMG',
00042             'OXVAT'            => 'OXVAT',
00043             'OXTHUMB'          => 'OXTHUMB',
00044             'OXICON'         => 'OXICON',
00045             'OXPIC1'         => 'OXPIC1',
00046             'OXPIC2'         => 'OXPIC2',
00047             'OXPIC3'         => 'OXPIC3',
00048             'OXPIC4'         => 'OXPIC4',
00049             'OXPIC5'         => 'OXPIC5',
00050             'OXPIC6'         => 'OXPIC6',
00051             'OXPIC7'         => 'OXPIC7',
00052             'OXPIC8'         => 'OXPIC8',
00053             'OXPIC9'         => 'OXPIC9',
00054             'OXPIC10'         => 'OXPIC10',
00055             'OXPIC11'         => 'OXPIC11',
00056             'OXPIC12'         => 'OXPIC12',
00057             'OXZOOM1'         => 'OXZOOM1',
00058             'OXZOOM2'         => 'OXZOOM2',
00059             'OXZOOM3'         => 'OXZOOM3',
00060             'OXZOOM4'         => 'OXZOOM4',
00061             'OXWEIGHT'        => 'OXWEIGHT',
00062             'OXSTOCK'         => 'OXSTOCK',
00063             'OXSTOCKFLAG'     => 'OXSTOCKFLAG',
00064             'OXSTOCKTEXT'     => 'OXSTOCKTEXT',
00065             'OXNOSTOCKTEXT'   => 'OXNOSTOCKTEXT',
00066             'OXDELIVERY'     => 'OXDELIVERY',
00067             'OXINSERT'       => 'OXINSERT', //always now()
00068             'OXTIMESTAMP'    => 'OXTIMESTAMP',
00069             'OXLENGTH'       => 'OXLENGTH',
00070             'OXWIDTH'        => 'OXWIDTH',
00071             'OXHEIGHT'       => 'OXHEIGHT',
00072             'OXAKTION'       => 'OXAKTION',
00073             'OXFILE'         => 'OXFILE',
00074             'OXSEARCHKEYS'   => 'OXSEARCHKEYS',
00075             'OXTEMPLATE'     => 'OXTEMPLATE',
00076             'OXQUESTIONEMAIL'=> 'OXQUESTIONEMAIL',
00077             'OXISSEARCH'     => 'OXISSEARCH',
00078             'OXVARNAME'      => 'OXVARNAME',
00079             'OXVARSTOCK'     => 'OXVARSTOCK',
00080             'OXVARCOUNT'     => 'OXVARCOUNT',
00081             'OXVARSELECT'    => 'OXVARSELECT',
00082             'OXVARNAME_1'    => 'OXVARNAME_1',
00083             'OXVARSELECT_1'  => 'OXVARSELECT_1',
00084             'OXVARNAME_2'   =>'OXVARNAME_2',
00085             'OXVARSELECT_2' =>'OXVARSELECT_2',
00086             'OXVARNAME_3'   =>'OXVARNAME_3',
00087             'OXVARSELECT_3' =>'OXVARSELECT_3',
00088             'OXTITLE_1'     =>'OXTITLE_1',
00089             'OXSHORTDESC_1' =>'OXSHORTDESC_1',
00090             'OXLONGDESC_1'  =>'OXLONGDESC_1',
00091             'OXURLDESC_1'   =>'OXURLDESC_1',
00092             'OXSEARCHKEYS_1'=>'OXSEARCHKEYS_1',
00093             'OXTITLE_2'     =>'OXTITLE_2',
00094             'OXSHORTDESC_2' =>'OXSHORTDESC_2',
00095             'OXLONGDESC_2'  =>'OXLONGDESC_2',
00096             'OXURLDESC_2'   =>'OXURLDESC_2',
00097             'OXSEARCHKEYS_2'=>'OXSEARCHKEYS_2',
00098             'OXTITLE_3'     =>'OXTITLE_3',
00099             'OXSHORTDESC_3' =>'OXSHORTDESC_3',
00100             'OXLONGDESC_3'  =>'OXLONGDESC_3',
00101             'OXURLDESC_3'   =>'OXURLDESC_3',
00102             'OXSEARCHKEYS_3'=>'OXSEARCHKEYS_3',
00103             'OXFOLDER'      =>'OXFOLDER',
00104             'OXSUBCLASS'    =>'OXSUBCLASS',
00105             'OXSTOCKTEXT_1' =>'OXSTOCKTEXT_1',
00106             'OXSTOCKTEXT_2' =>'OXSTOCKTEXT_2',
00107             'OXSTOCKTEXT_3' =>'OXSTOCKTEXT_3',
00108             'OXNOSTOCKTEXT_1'=>'OXNOSTOCKTEXT_1',
00109             'OXNOSTOCKTEXT_2'=>'OXNOSTOCKTEXT_2',
00110             'OXNOSTOCKTEXT_3'=>'OXNOSTOCKTEXT_3',
00111             'OXSORT'         => 'OXSORT',
00112             'OXSOLDAMOUNT'   => 'OXSOLDAMOUNT',
00113             'OXNONMATERIAL'  => 'OXNONMATERIAL',
00114             'OXFREESHIPPING' => 'OXFREESHIPPING',
00115             'OXREMINDACTIV'  => 'OXREMINDACTIV',
00116             'OXREMINDAMOUNT' => 'OXREMINDAMOUNT',
00117             'OXAMITEMID'    =>'OXAMITEMID',
00118             'OXAMTASKID'    =>'OXAMTASKID',
00119             'OXVENDORID'    =>'OXVENDORID',
00120             'OXSKIPDISCOUNTS'=> 'OXSKIPDISCOUNTS',
00121             'OXORDERINFO'   =>'OXORDERINFO',
00122             'OXSEOID'       =>'OXSEOID',
00123             'OXSEOID_1'     =>'OXSEOID_1',
00124             'OXSEOID_2'     =>'OXSEOID_2',
00125             'OXSEOID_3'     =>'OXSEOID_3',
00126             'OXPIXIEXPORT'   => 'OXPIXIEXPORT',
00127             'OXPIXIEXPORTED' => 'OXPIXIEXPORTED',
00128             'OXVPE'          => 'OXVPE',
00129             'OXID'           => 'OXID',
00130         ),
00131         '2' => array(
00132             'OXID' => 'OXID',
00133             'OXSHOPID' => 'OXSHOPID',
00134             'OXSHOPINCL' => 'OXSHOPINCL',
00135             'OXSHOPEXCL' => 'OXSHOPEXCL',
00136             'OXPARENTID' => 'OXPARENTID',
00137             'OXACTIVE' => 'OXACTIVE',
00138             'OXACTIVEFROM' => 'OXACTIVEFROM',
00139             'OXACTIVETO' => 'OXACTIVETO',
00140             'OXARTNUM' => 'OXARTNUM',
00141             'OXEAN' => 'OXEAN',
00142             'OXDISTEAN' => 'OXDISTEAN',
00143             'OXMPN' => 'OXMPN',
00144             'OXTITLE' => 'OXTITLE',
00145             'OXSHORTDESC' => 'OXSHORTDESC',
00146             'OXPRICE' => 'OXPRICE',
00147             'OXBLFIXEDPRICE' => 'OXBLFIXEDPRICE',
00148             'OXPRICEA' => 'OXPRICEA',
00149             'OXPRICEB' => 'OXPRICEB',
00150             'OXPRICEC' => 'OXPRICEC',
00151             'OXBPRICE' => 'OXBPRICE',
00152             'OXTPRICE' => 'OXTPRICE',
00153             'OXUNITNAME' => 'OXUNITNAME',
00154             'OXUNITQUANTITY' => 'OXUNITQUANTITY',
00155             'OXEXTURL' => 'OXEXTURL',
00156             'OXURLDESC' => 'OXURLDESC',
00157             'OXURLIMG' => 'OXURLIMG',
00158             'OXVAT' => 'OXVAT',
00159             'OXTHUMB' => 'OXTHUMB',
00160             'OXICON' => 'OXICON',
00161             'OXPIC1' => 'OXPIC1',
00162             'OXPIC2' => 'OXPIC2',
00163             'OXPIC3' => 'OXPIC3',
00164             'OXPIC4' => 'OXPIC4',
00165             'OXPIC5' => 'OXPIC5',
00166             'OXPIC6' => 'OXPIC6',
00167             'OXPIC7' => 'OXPIC7',
00168             'OXPIC8' => 'OXPIC8',
00169             'OXPIC9' => 'OXPIC9',
00170             'OXPIC10' => 'OXPIC10',
00171             'OXPIC11' => 'OXPIC11',
00172             'OXPIC12' => 'OXPIC12',
00173             'OXZOOM1' => 'OXZOOM1',
00174             'OXZOOM2' => 'OXZOOM2',
00175             'OXZOOM3' => 'OXZOOM3',
00176             'OXZOOM4' => 'OXZOOM4',
00177             'OXWEIGHT' => 'OXWEIGHT',
00178             'OXSTOCK' => 'OXSTOCK',
00179             'OXSTOCKFLAG' => 'OXSTOCKFLAG',
00180             'OXSTOCKTEXT' => 'OXSTOCKTEXT',
00181             'OXNOSTOCKTEXT' => 'OXNOSTOCKTEXT',
00182             'OXDELIVERY' => 'OXDELIVERY',
00183             'OXINSERT' => 'OXINSERT',
00184             'OXTIMESTAMP' => 'OXTIMESTAMP',
00185             'OXLENGTH' => 'OXLENGTH',
00186             'OXWIDTH' => 'OXWIDTH',
00187             'OXHEIGHT' => 'OXHEIGHT',
00188             'OXFILE' => 'OXFILE',
00189             'OXSEARCHKEYS' => 'OXSEARCHKEYS',
00190             'OXTEMPLATE' => 'OXTEMPLATE',
00191             'OXQUESTIONEMAIL' => 'OXQUESTIONEMAIL',
00192             'OXISSEARCH' => 'OXISSEARCH',
00193             'OXVARNAME' => 'OXVARNAME',
00194             'OXVARSTOCK' => 'OXVARSTOCK',
00195             'OXVARCOUNT' => 'OXVARCOUNT',
00196             'OXVARSELECT' => 'OXVARSELECT',
00197             'OXVARMINPRICE' => 'OXVARMINPRICE',
00198             'OXVARNAME_1' => 'OXVARNAME_1',
00199             'OXVARSELECT_1' => 'OXVARSELECT_1',
00200             'OXVARNAME_2' => 'OXVARNAME_2',
00201             'OXVARSELECT_2' => 'OXVARSELECT_2',
00202             'OXVARNAME_3' => 'OXVARNAME_3',
00203             'OXVARSELECT_3' => 'OXVARSELECT_3',
00204             'OXTITLE_1' => 'OXTITLE_1',
00205             'OXSHORTDESC_1' => 'OXSHORTDESC_1',
00206             'OXURLDESC_1' => 'OXURLDESC_1',
00207             'OXSEARCHKEYS_1' => 'OXSEARCHKEYS_1',
00208             'OXTITLE_2' => 'OXTITLE_2',
00209             'OXSHORTDESC_2' => 'OXSHORTDESC_2',
00210             'OXURLDESC_2' => 'OXURLDESC_2',
00211             'OXSEARCHKEYS_2' => 'OXSEARCHKEYS_2',
00212             'OXTITLE_3' => 'OXTITLE_3',
00213             'OXSHORTDESC_3' => 'OXSHORTDESC_3',
00214             'OXURLDESC_3' => 'OXURLDESC_3',
00215             'OXSEARCHKEYS_3' => 'OXSEARCHKEYS_3',
00216             'OXFOLDER' => 'OXFOLDER',
00217             'OXSUBCLASS' => 'OXSUBCLASS',
00218             'OXSTOCKTEXT_1' => 'OXSTOCKTEXT_1',
00219             'OXSTOCKTEXT_2' => 'OXSTOCKTEXT_2',
00220             'OXSTOCKTEXT_3' => 'OXSTOCKTEXT_3',
00221             'OXNOSTOCKTEXT_1' => 'OXNOSTOCKTEXT_1',
00222             'OXNOSTOCKTEXT_2' => 'OXNOSTOCKTEXT_2',
00223             'OXNOSTOCKTEXT_3' => 'OXNOSTOCKTEXT_3',
00224             'OXSORT' => 'OXSORT',
00225             'OXSOLDAMOUNT' => 'OXSOLDAMOUNT',
00226             'OXNONMATERIAL' => 'OXNONMATERIAL',
00227             'OXFREESHIPPING' => 'OXFREESHIPPING',
00228             'OXREMINDACTIVE' => 'OXREMINDACTIVE',
00229             'OXREMINDAMOUNT' => 'OXREMINDAMOUNT',
00230             'OXAMITEMID' => 'OXAMITEMID',
00231             'OXAMTASKID' => 'OXAMTASKID',
00232             'OXVENDORID' => 'OXVENDORID',
00233             'OXSKIPDISCOUNTS' => 'OXSKIPDISCOUNTS',
00234             'OXORDERINFO' => 'OXORDERINFO',
00235             'OXPIXIEXPORT' => 'OXPIXIEXPORT',
00236             'OXPIXIEXPORTED' => 'OXPIXIEXPORTED',
00237             'OXVPE' => 'OXVPE',
00238             'OXRATING' => 'OXRATING',
00239             'OXRATINGCNT' => 'OXRATINGCNT',
00240             'OXLONGDESC'       => 'OXLONGDESC',
00241             'OXLONGDESC_1'     => 'OXLONGDESC_1',
00242             'OXLONGDESC_2'     => 'OXLONGDESC_2',
00243             'OXLONGDESC_3'     => 'OXLONGDESC_3',
00244             'OXBUNDLEID'       => 'OXBUNDLEID',
00245             'OXMANUFACTURERID' => 'OXMANUFACTURERID',
00246         ),
00247     );
00248 
00254     public function __construct()
00255     {
00256 
00257         parent::__construct();
00258 
00259         $this->_sTableName      = 'oxarticles';
00260         $this->_sShopObjectName = 'oxarticle';
00261 
00262     }
00263 
00273     protected function getSqlFieldName($sField, $iLanguage = 0, $iShopID = 1)
00274     {
00275         switch ($sField) {
00276             // oxlongdesc is valid in all versions
00277             case 'OXLONGDESC':
00278             case 'OXLONGDESC_1':
00279             case 'OXLONGDESC_2':
00280             case 'OXLONGDESC_3':
00281                 // take from oxartextends
00282                 return "(select $sField from oxartextends where ".$this->getTableName($iShopID).".oxid = oxartextends.oxid limit 1) as $sField";
00283                 break;
00284         }
00285 
00286         if ('1' == oxERPBase::getUsedDbFieldsVersion()) {
00287             switch ($sField) {
00288                 case 'OXAKTION':
00289                 case 'OXSEOID':
00290                 case 'OXSEOID_1':
00291                 case 'OXSEOID_2':
00292                 case 'OXSEOID_3':
00293                     return "'' as $sField";
00294                     break;
00295                 case 'OXACTIV':
00296                     return "OXACTIVE as OXACTIV";
00297                     break;
00298                 case 'OXACTIVFROM':
00299                     return "OXACTIVEFROM as OXACTIVFROM";
00300                     break;
00301                 case 'OXACTIVTO':
00302                     return "OXACTIVETO as OXACTIVTO";
00303                     break;
00304             }
00305         }
00306 
00307         return parent::getSqlFieldName($sField, $iLanguage, $iShopID);
00308     }
00309 
00319     protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00320     {
00321         $oCompat = oxNew('OXERPCompatability');
00322         if ( !$oCompat->isArticleNullLongDescComatable() ) {
00323 
00324             $aLongDescriptionFields = array('OXLONGDESC_1', 'OXLONGDESC_2', 'OXLONGDESC_3');
00325 
00326             foreach ( $aLongDescriptionFields as $iKey => $sField ) {
00327                 if ( in_array($sField, $this->_aFieldList ) ) {
00328                     unset($aLongDescriptionFields[$iKey]);
00329                 }
00330             }
00331 
00332             if ( count($aLongDescriptionFields ) ) {
00333                 $oArtExt = oxNew('oxbase');
00334                 $oArtExt->init('oxartextends');
00335 
00336                 if ( $oArtExt->load($aData['OXID']) ) {
00337                     foreach ($aLongDescriptionFields as $sField) {
00338                         $sFieldName = $oArtExt->getCoreTableName()."__".strtolower( $sField );
00339                         $sLongDesc  = null;
00340 
00341                         if ($oArtExt->$sFieldName instanceof oxField) {
00342                             $sLongDesc = $oArtExt->$sFieldName->getRawValue();
00343                         } elseif (is_object($oArtExt->$sFieldName)) {
00344                             $sLongDesc = $oArtExt->$sFieldName->value;
00345                         }
00346 
00347                         if ( isset($sLongDesc) ) {
00348                             $aData[$sField] = $sLongDesc;
00349                         }
00350                     }
00351                 }
00352             }
00353         }
00354 
00355         return parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00356     }
00357 }