4 define( 
'OXARTICLE_LINKTYPE_CATEGORY', 0 );
 
    5 define( 
'OXARTICLE_LINKTYPE_VENDOR', 1 );
 
    6 define( 
'OXARTICLE_LINKTYPE_MANUFACTURER', 2 );
 
    7 define( 
'OXARTICLE_LINKTYPE_PRICECATEGORY', 3 );
 
    8 define( 
'OXARTICLE_LINKTYPE_TAG', 4 );
 
    9 define( 
'OXARTICLE_LINKTYPE_RECOMM', 5 );
 
  367                                              'oxarticles__oxtimestamp',
 
  370                                              'oxarticles__oxparentid');
 
  378                                          'oxarticles__oxfreeshipping',
 
  379                                          'oxarticles__oxisdownloadable',
 
  380                                          'oxarticles__oxshowcustomagreement');
 
  445         if ( $aParams && is_array($aParams)) {
 
  446             foreach ( $aParams as $sParam => $mValue) {
 
  447                 $this->$sParam = $mValue;
 
  451         $this->
init( 
'oxarticles' );
 
  465         if ( $this->$sName ) {
 
  470         return $this->$sName;
 
  481     public function __set( $sName, $sValue )
 
  504     public function setId( $sId = null )
 
  509         $this->oxarticles__oxnid = $this->oxarticles__oxid;
 
  528         $sQ = 
" $sTable.oxactive = 1 ";
 
  531         if ( $this->
getConfig()->getConfigParam( 
'blUseTimeCheck' ) ) {
 
  532             $sDate = date( 
'Y-m-d H:i:s', 
oxRegistry::get(
"oxUtilsDate")->getTime() );
 
  533             $sQ = 
"( $sQ or ( $sTable.oxactivefrom < '$sDate' and $sTable.oxactiveto > '$sDate' ) ) ";
 
  560         if ( 
$myConfig->getConfigParam( 
'blUseStock' ) ) {
 
  561             $sQ = 
" and ( $sTable.oxstockflag != 2 or ( $sTable.oxstock + $sTable.oxvarstock ) > 0  ) ";
 
  563             if ( !
$myConfig->getConfigParam( 
'blVariantParentBuyable' ) ) {
 
  565                 if ( 
$myConfig->getConfigParam( 
'blUseTimeCheck' ) ) {
 
  566                      $sDate = date( 
'Y-m-d H:i:s', 
oxRegistry::get(
"oxUtilsDate")->getTime() );
 
  567                      $sTimeCheckQ = 
" or ( art.oxactivefrom < '$sDate' and art.oxactiveto > '$sDate' )";
 
  569                 $sQ = 
" $sQ and IF( $sTable.oxvarcount = 0, 1, ( select 1 from $sTable as art where art.oxparentid=$sTable.oxid and ( art.oxactive = 1 $sTimeCheckQ ) and ( art.oxstockflag != 2 or art.oxstock > 0 ) limit 1 ) ) ";
 
  590         $sQ = 
" and $sTable.oxparentid = '".$this->getId().
"' ";
 
  593         if ( $this->
getConfig()->getConfigParam( 
'blUseStock' ) ) {
 
  594             $sQ .= 
" and ( $sTable.oxstock > 0 or ( $sTable.oxstock <= 0 and $sTable.oxstockflag != 2 ";
 
  595             if ( $blRemoveNotOrderables ) {
 
  596                 $sQ .= 
" and $sTable.oxstockflag != 3 ";
 
  634         $this->_blSkipAssign = $blSkipAssign;
 
  644         $this->_blLoadPrice = 
false;
 
  654         $this->_blLoadPrice = 
true;
 
  676         $this->_sItemKey = $sItemKey;
 
  688         $this->_blLoadVariants = !$blLoadVariants;
 
  698         if ($this->_blNotBuyableParent) {
 
  734         $this->_blIsOnComparisonList = $blOnList;
 
  746         $this->_blLoadParentData = $blLoadParentData;
 
  770         $this->_blSkipAbPrice = $blSkipAbPrice;
 
  783         switch ($sFieldName) {
 
  802             return $blCanPreview;
 
  806         $sNow = date(
'Y-m-d H:i:s');
 
  807         if ( !$this->oxarticles__oxactive->value &&
 
  808              (  $this->oxarticles__oxactivefrom->value > $sNow ||
 
  809                 $this->oxarticles__oxactiveto->value < $sNow
 
  815         if ( $this->
getConfig()->getConfigParam( 
'blUseStock' ) && $this->oxarticles__oxstockflag->value == 2) {
 
  816             $iOnStock = $this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value;
 
  817             if ($this->
getConfig()->getConfigParam( 
'blPsBasketReservationEnabled' )) {
 
  818                 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
 
  820             if ( $iOnStock <= 0 ) {
 
  839         startProfile(
'articleAssign');
 
  844         $this->oxarticles__oxnid = $this->oxarticles__oxid;
 
  847         if ($this->_blSkipAssign) {
 
  861         stopProfile(
'articleAssign');
 
  899         $this->_blNotBuyableParent = 
false;
 
  910             $this->_isLoaded = 
true;
 
  927         $dOldRating = $this->oxarticles__oxrating->value;
 
  928         $dOldCnt    = $this->oxarticles__oxratingcnt->value;
 
  929         $this->oxarticles__oxrating->setValue(( $dOldRating * $dOldCnt + $iRating ) / ($dOldCnt + 1));
 
  930         $this->oxarticles__oxratingcnt->setValue($dOldCnt + 1);
 
  931         $dRating = ( $dOldRating * $dOldCnt + $iRating ) / ($dOldCnt + 1);
 
  932         $dRatingCnt = (int) ($dOldCnt + 1);
 
  935         $oDb->execute( 
'update oxarticles set oxarticles.oxrating = '.$dRating.
',oxarticles.oxratingcnt = '.$dRatingCnt.
', oxarticles.oxtimestamp = oxarticles.oxtimestamp where oxarticles.oxid = '.$oDb->quote( $this->getId() ) );
 
  948          $this->oxarticles__oxrating = 
new oxField( $iRating );
 
  960          $this->oxarticles__oxratingcnt = 
new oxField( $iRatingCnt );
 
  972         if ( !$blIncludeVariants ) {
 
  973             return round( $this->oxarticles__oxrating->value, 1);
 
  975             $oRating = 
oxNew( 
'oxRating' );
 
  989         if ( !$blIncludeVariants ) {
 
  990             return $this->oxarticles__oxratingcnt->value;
 
  992             $oRating = 
oxNew( 
'oxRating' );
 
 1005         $aIds = array($this->
getId());
 
 1007         if ( $this->oxarticles__oxparentid->value ) {
 
 1008             $aIds[] = $this->oxarticles__oxparentid->value;
 
 1012         if ( $this->
getConfig()->getConfigParam( 
'blShowVariantReviews' ) ) {
 
 1014             if (is_array($aAdd)) {
 
 1015                 $aIds = array_merge($aIds, $aAdd);
 
 1019         $oReview = 
oxNew(
'oxreview');
 
 1020         $oRevs = $oReview->loadList(
'oxarticle', $aIds);
 
 1023         if ( $oRevs->count() < 1 ) {
 
 1037         $oCrosslist = 
oxNew( 
"oxarticlelist");
 
 1038         $oCrosslist->loadArticleCrossSell($this->oxarticles__oxid->value);
 
 1039         if ( $oCrosslist->count() ) {
 
 1056         if ( !
$myConfig->getConfigParam( 
'bl_perfLoadAccessoires' ) ) {
 
 1060         $oAcclist = 
oxNew( 
"oxarticlelist");
 
 1061         $oAcclist->setSqlLimit( 0, 
$myConfig->getConfigParam( 
'iNrofCrossellArticles' ));
 
 1062         $oAcclist->loadArticleAccessoires($this->oxarticles__oxid->value);
 
 1064         if ( $oAcclist->count()) {
 
 1080         if ( !
$myConfig->getConfigParam( 
'bl_perfLoadSimilar' ) ) {
 
 1096         if ( count( $aList ) ) {
 
 1097             uasort( $aList, 
'cmpart');
 
 1101             $oSimilarlist = 
oxNew( 
'oxarticlelist' );
 
 1102             $oSimilarlist->setSqlLimit( 0, 
$myConfig->getConfigParam( 
'iNrofSimilarArticles' ));
 
 1103             $oSimilarlist->selectString( $sSearch);
 
 1105             return $oSimilarlist;
 
 1120         if ( !
$myConfig->getConfigParam( 
'bl_perfLoadCustomerWhoBoughtThis' ) ) {
 
 1127         $oArticles = 
oxNew( 
'oxarticlelist' );
 
 1128         $oArticles->setSqlLimit( 0, 
$myConfig->getConfigParam( 
'iNrofCustomerWhoArticles' ));
 
 1129         $oArticles->selectString( $sQ );
 
 1130         if ( $oArticles->count() ) {
 
 1146         if ( !
$myConfig->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice || !$this->_blCalcPrice || !$this->
hasAmountPrice() ) {
 
 1150         if ( $this->_oAmountPriceInfo === null ) {
 
 1151             $this->_oAmountPriceInfo = array();
 
 1170         $sKey = $this->
getId();
 
 1171         if ( isset( $sKeyPrefix ) ) {
 
 1172             $sKey = $sKeyPrefix.
'__'.$sKey;
 
 1175         if ( !isset( self::$_aSelList[$sKey] ) ) {
 
 1179             $sQ = 
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid 
 1180                    where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
 
 1183             $oLists = 
oxNew( 
'oxlist' );
 
 1184             $oLists->init( 
'oxselectlist' );
 
 1185             $oLists->selectString( sprintf( $sQ, $oDb->quote( $this->getId() ) ) );
 
 1188             if ( $oLists->count() == 0 && $this->oxarticles__oxparentid->value ) {
 
 1189                 $oLists->selectString( sprintf( $sQ, $oDb->quote( $this->oxarticles__oxparentid->value ) ) );
 
 1199             self::$_aSelList[$sKey] = array();
 
 1200             foreach ( $oLists as $oSelectlist ) {
 
 1201                 self::$_aSelList[$sKey][$iCnt] = $oSelectlist->getFieldList( $dVat );
 
 1202                 self::$_aSelList[$sKey][$iCnt][
'name'] = $oSelectlist->oxselectlist__oxtitle->value;
 
 1206         return self::$_aSelList[$sKey];
 
 1219         if ( ( $sId = $this->
getId() ) ) {
 
 1220             if ( $this->oxarticles__oxshopid->value == $this->getConfig()->getShopId() ) {
 
 1221                 $blHas = (bool) $this->oxarticles__oxvarcount->value;
 
 1223                 $sArticleTable = $this->
getViewName( $blForceCoreTable );
 
 1224                 $blHas = (bool) 
oxDb::getDb()->getOne( 
"select 1 from $sArticleTable where oxparentid='{$sId}'" );
 
 1237         return $this->oxarticles__oxvarcount->value;
 
 1257         return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxnonmaterial->value && !$this->
hasDownloadableAgreement();
 
 1267         return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxisdownloadable->value;
 
 1281         $iLimit = (int) $iLimit;
 
 1282         if ( !isset( $this->_aVariantSelections[$iLimit] ) ) {
 
 1283             $aVariantSelections = 
false;
 
 1284             if ( $this->oxarticles__oxvarcount->value ) {
 
 1286                 $aVariantSelections = 
oxNew( 
"oxVariantHandler" )->buildVariantSelections( $this->oxarticles__oxvarname->getRawValue(), $oVariants, $aFilterIds, $sActVariantId, $iLimit );
 
 1288                 if ( !empty($oVariants) && empty( $aVariantSelections[
'rawselections'] ) ) {
 
 1289                     $aVariantSelections = 
false;
 
 1292             $this->_aVariantSelections[$iLimit] = $aVariantSelections;
 
 1295         return $this->_aVariantSelections[$iLimit];
 
 1308         $sId = $this->
getId() . ( (int) $iLimit );
 
 1309         if ( !array_key_exists( $sId, self::$_aSelections ) ) {
 
 1314             $sQ = 
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid 
 1315                    where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
 
 1317             if ( ( $iLimit = (
int) $iLimit ) ) {
 
 1318                 $sQ .= 
" limit $iLimit ";
 
 1323             if ( ( $oPrice = $this->
getPrice() ) != null ) {
 
 1324                 $dVat = $oPrice->getVat();
 
 1328             $oList = 
oxNew( 
'oxlist' );
 
 1329             $oList->init( 
'oxselectlist' );
 
 1330             $oList->getBaseObject()->setVat( $dVat );
 
 1331             $oList->selectString( sprintf( $sQ, $oDb->quote( $this->getId() ) ) );
 
 1334             if ( $oList->count() == 0 && $this->oxarticles__oxparentid->value ) {
 
 1335                 $oList->selectString( sprintf( $sQ, $oDb->quote( $this->oxarticles__oxparentid->value ) ) );
 
 1338             self::$_aSelections[$sId] = $oList->count() ? $oList : 
false;
 
 1341         if ( self::$_aSelections[$sId] ) {
 
 1346                 foreach ( self::$_aSelections[$sId] as $oSelection ) {
 
 1347                     if ( isset( $aFilter[$iSelIdx] ) ) {
 
 1348                         $oSelection->setActiveSelectionByIndex( $aFilter[$iSelIdx] );
 
 1355         return self::$_aSelections[$sId];
 
 1367     protected function _loadVariantList( $blSimple, $blRemoveNotOrderables = 
true, $blForceCoreTable = null )
 
 1369         $oVariants = array();
 
 1370         $sId = $this->
getId();
 
 1377         self::$_aLoadedParents[$sId . 
"_" . $this->
getLanguage()] = $this;
 
 1381         if ( !$this->_blLoadVariants ||
 
 1383             ( !$this->
isAdmin() && !$this->oxarticles__oxvarcount->value ) ) {
 
 1388         $sCacheKey = $blSimple ? 
"simple" : 
"full";
 
 1389         if ( $blRemoveNotOrderables ) {
 
 1390             if ( isset( $this->_aVariants[$sCacheKey] ) ) {
 
 1391                return $this->_aVariants[$sCacheKey];
 
 1393                 $this->_aVariants[$sCacheKey] = & $oVariants;
 
 1395         } elseif ( !$blRemoveNotOrderables ) {
 
 1396             if ( isset( $this->_aVariantsWithNotOrderables[$sCacheKey] ) ) {
 
 1397                 return $this->_aVariantsWithNotOrderables[$sCacheKey];
 
 1399                 $this->_aVariantsWithNotOrderables[$sCacheKey] = & $oVariants;
 
 1403         if ( ( $this->_blHasVariants = $this->
_hasAnyVariant( $blForceCoreTable ) ) ) {
 
 1407             $oVariants = $this->
_selectVariants( $blRemoveNotOrderables, $blForceCoreTable, $oVariants );
 
 1412             $this->_blNotBuyableParent = 
true;
 
 1417             $this->_blNotBuyable = 
true;
 
 1431     public function getFullVariants( $blRemoveNotOrderables = 
true, $blForceCoreTable = null )
 
 1433         return $this->
_loadVariantList( 
false, $blRemoveNotOrderables, $blForceCoreTable );
 
 1444     public function getVariants( $blRemoveNotOrderables = 
true, $blForceCoreTable = null  )
 
 1456         if ( $this->oxarticles__oxvarcount->value) {
 
 1473         $oVariants = 
oxNew( 
'oxarticlelist');
 
 1474         if ( ( $sId = $this->
getId() ) ) {
 
 1476             $oBaseObj = $oVariants->getBaseObject();
 
 1478             if ( is_null( $sLanguage ) ) {
 
 1481                 $oBaseObj->setLanguage( $sLanguage );
 
 1484             $sSql = 
"select * from ".$oBaseObj->getViewName().
" where oxparentid = '{$sId}' order by oxsort ";
 
 1485             $oVariants->selectString( $sSql );
 
 1488             if ( !$this->
getConfig()->getConfigParam( 
'blVariantParentBuyable' ) && ( $oVariants->count() > 0 ) ) {
 
 1490                 $this->_blNotBuyableParent = 
true;
 
 1506         $oCategory = 
oxNew( 
'oxcategory' );
 
 1510         $sOXID = $this->
getId();
 
 1511         if ( isset( $this->oxarticles__oxparentid->value ) && $this->oxarticles__oxparentid->value ) {
 
 1512             $sOXID = $this->oxarticles__oxparentid->value;
 
 1517             if ( !isset( $this->_aCategoryCache[ $sOXID ] ) ) {
 
 1518                 startPRofile( 
'getCategory' );
 
 1520                 $sWhere   = $oCategory->getSqlActiveSnippet();
 
 1522                 $sSelect .= ( $oStr->strstr( $sSelect, 
'where' )?
' and ':
' where ') . $sWhere . 
" order by oxobject2category.oxtime limit 1";
 
 1525                 if ( !$oCategory->assignRecord( $sSelect ) ) {
 
 1528                     $sSelect .= ( $oStr->strstr( $sSelect, 
'where' )?
' and ':
' where ') . $sWhere . 
" limit 1";
 
 1531                     if ( !$oCategory->assignRecord( $sSelect ) ) {
 
 1536                 $this->_aCategoryCache[ $sOXID ] = $oCategory;
 
 1537                 stopPRofile( 
'getCategory' );
 
 1540                $oCategory = $this->_aCategoryCache[ $sOXID ];
 
 1557         if ( isset( self::$_aArticleCats[$this->
getId()] ) && !$blSkipCache ) {
 
 1558             return self::$_aArticleCats[$this->
getId()];
 
 1562         $sOXID = $this->
getId();
 
 1566         if (isset( $this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
 
 1567             $aRet = array_merge( $aRet, $this->
_getArticleCategories( $this->oxarticles__oxparentid->value, $blActCats ) );
 
 1574         $rs = $oDb->select( $sSql );
 
 1577         if ($rs != 
false && $rs->recordCount() > 0) {
 
 1580                 if ( is_array( $rs->fields ) ) {
 
 1581                    $rs->fields = array_change_key_case( $rs->fields, CASE_LOWER );
 
 1585                 if ( !$aRet[$rs->fields[
'oxid']] ) {
 
 1586                     $aRet[] = $rs->fields[
'oxid'];
 
 1592         return self::$_aArticleCats[$this->
getId()] = array_unique($aRet);
 
 1608         $rs = $oDb->select( $sSql );
 
 1613         if ($rs != 
false && $rs->recordCount() > 0) {
 
 1615                 $aRet[] = $rs->fields[
'oxcatnid'];
 
 1635         $sSelect =  
"select oxobject2category.oxcatnid as oxcatnid from $sO2CView as oxobject2category left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
 
 1636         $sSelect .= 
'where oxobject2category.oxobjectid='.oxDb::getDb()->quote($sOXID).
' and oxcategories.oxid is not null and oxcategories.oxactive = 1 ';
 
 1638             $sSelect .= 
"and oxcategories.oxhidden = 0 and (select count(cats.oxid) from $sCatView as cats where cats.oxrootid = oxcategories.oxrootid and cats.oxleft < oxcategories.oxleft and cats.oxright > oxcategories.oxright and ( cats.oxhidden = 1 or cats.oxactive = 0 ) ) = 0 ";
 
 1640         $sSelect .= 
'order by oxobject2category.oxtime ';
 
 1656             $oVendor = 
oxNew( 
'oxvendor' );
 
 1657         } elseif ( !$blShopCheck && $this->oxarticles__oxvendorid->value ) {
 
 1658                 $oVendor = 
oxNew( 
'oxi18n' );
 
 1659                 $oVendor->init(
'oxvendor');
 
 1660                 $oVendor->setReadOnly( 
true );
 
 1661             $sVendorId = $this->oxarticles__oxvendorid->value;
 
 1663         if ( $sVendorId && $oVendor->load( $sVendorId ) && $oVendor->oxvendor__oxactive->value ) {
 
 1680         if ( $this->oxarticles__oxvendorid->value ) {
 
 1681                 $sVendorId = $this->oxarticles__oxvendorid->value;
 
 1696         $sManufacturerId = 
false;
 
 1697         if ( $this->oxarticles__oxmanufacturerid->value ) {
 
 1699                 $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
 
 1702         return $sManufacturerId;
 
 1716             $oManufacturer = 
oxNew( 
'oxmanufacturer' );;
 
 1718              !$blShopCheck && $this->oxarticles__oxmanufacturerid->value ) {
 
 1719             $oManufacturer->setReadOnly( 
true );
 
 1720             $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
 
 1723         if ( $sManufacturerId && $oManufacturer->load( $sManufacturerId ) ) {
 
 1724             if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadManufacturerTree' ) ) {
 
 1725                 $oManufacturer->setReadOnly( 
true );
 
 1727             $oManufacturer = $oManufacturer->oxmanufacturers__oxactive->value ? $oManufacturer : null;
 
 1729             $oManufacturer = null;
 
 1732         return $oManufacturer;
 
 1758         $sOXID = $this->
getId();
 
 1759         if ( isset( $this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
 
 1760             $sOXID = $this->oxarticles__oxparentid->value;
 
 1765         $sOXID = $oDb->getOne( $sSelect );
 
 1767         if ( isset( $sOXID) && $sOXID) {
 
 1772         if ( $this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) && $this->_blLoadPrice ) {
 
 1773             $dPriceFromTo = $this->
getPrice()->getBruttoPrice();
 
 1774             if ( $dPriceFromTo > 0) {
 
 1776                 $sOXID = $oDb->getOne( $sSelect );
 
 1778                 if ( isset( $sOXID) && $sOXID) {
 
 1793         if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
 
 1798         if ( $this->_oTPrice !== null ) {
 
 1804         $dBasePrice = $this->oxarticles__oxtprice->value;
 
 1807         $oPrice->setPrice( $dBasePrice );
 
 1820         if ( $oPrice->getPrice() <= $oPrice2->getPrice() ) {
 
 1825         $this->_oTPrice = $oPrice;
 
 1838         if ( $this->_blSkipDiscounts !== null ) {
 
 1842         if ( $this->oxarticles__oxskipdiscounts->value ) {
 
 1847         $this->_blSkipDiscounts = 
false;
 
 1848         if ( 
oxRegistry::get(
"oxDiscountList")->hasSkipDiscountCategories() ) {
 
 1853             $sSelect =  
"select 1 from $sO2CView as $sO2CView left join {$sViewName} on {$sViewName}.oxid = $sO2CView.oxcatnid 
 1854                          where $sO2CView.oxobjectid=".$oDb->quote( $this->
getId() ).
" and {$sViewName}.oxactive = 1 and {$sViewName}.oxskipdiscounts = '1' ";
 
 1855             $this->_blSkipDiscounts = ( $oDb->getOne( $sSelect ) == 1 );
 
 1870         $this->_oPrice = $oPrice;
 
 1914         if ( $dAmount != 1 || $this->_oPrice === null ) {
 
 1922             $oPrice->setPrice( $dBasePrice );
 
 1925             if ( !$this->_blCalcPrice && $dAmount == 1 ) {
 
 1926                 return $this->_oPrice = $oPrice;
 
 1930             if ( $dAmount != 1 ) {
 
 1934             $this->_oPrice = $oPrice;
 
 1950         if ( isset( $dVat ) || !$this->
getConfig()->getConfigParam( 
'bl_perfCalcVatOnlyForBasketOrder' ) ) {
 
 1959             $aDiscounts = $oDiscountList->getArticleDiscounts( $this, $this->
getArticleUser() );
 
 1961             reset( $aDiscounts );
 
 1962             foreach ( $aDiscounts as $oDiscount ) {
 
 1963                 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
 
 1965             $oPrice->calculateDiscount();
 
 1980         $this->_oUser = $oUser;
 
 1990         if ($this->_oUser) {
 
 2007         $oUser = $oBasket->getBasketUser();
 
 2010         $oBasketPrice = $this->
_getPriceObject( $oBasket->isCalculationModeNetto() );
 
 2021         $oBasketPrice->setPrice( $dBasePrice );
 
 2023         $dVat = 
oxRegistry::get(
"oxVatSelector")->getBasketItemVat( $this, $oBasket );
 
 2027         return $oBasketPrice;
 
 2038     public function delete( $sOXID = null )
 
 2041             $sOXID = $this->
getId();
 
 2051         $this->
load( $sOXID );
 
 2053         $this->
_onChangeResetCounts( $sOXID, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value );
 
 2062         $this->
onChange( ACTION_DELETE, $sOXID, $this->oxarticles__oxparentid->value );
 
 2079         $iStockCount = $this->oxarticles__oxstock->value - $dAmount;
 
 2080         if (!$blAllowNegativeStock && ($iStockCount < 0)) {
 
 2081             $dAmount += $iStockCount;
 
 2084         $this->oxarticles__oxstock = 
new oxField($iStockCount);
 
 2087         $oDb->execute( 
'update oxarticles set oxarticles.oxstock = '.$oDb->quote( $iStockCount ).
' where oxarticles.oxid = '.$oDb->quote( $this->
getId() ) );
 
 2088         $this->
onChange( ACTION_UPDATE_STOCK );
 
 2107         if ( !$this->oxarticles__oxparentid->value ) {
 
 2109             $dAmount = (double) $dAmount;
 
 2111             $rs = $oDb->execute( 
"update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + $dAmount where oxarticles.oxid = ".$oDb->quote($this->oxarticles__oxid->value));
 
 2112         } elseif ( $this->oxarticles__oxparentid->value) {
 
 2115             $oUpdateArticle->updateSoldAmount( $dAmount );
 
 2129         return $oDb->execute( 
"update oxarticles set oxarticles.oxremindactive = 2 where oxarticles.oxid = ".$oDb->quote($this->oxarticles__oxid->value));
 
 2141         if ( ( $blRet = parent::save() ) ) {
 
 2156         $sParentId = $this->oxarticles__oxparentid->value;
 
 2158         $this->_blAllowEmptyParentId = 
true;
 
 2160         $this->_blAllowEmptyParentId = 
false;
 
 2162         if ( $sParentId !== 
'' ) {
 
 2163             $this->
onChange( ACTION_UPDATE, null, $sParentId );
 
 2180         $aArtPics  = array();
 
 2181         $aArtIcons = array();
 
 2191         $iPicCount = 
$myConfig->getConfigParam( 
'iPicCount' );
 
 2192         $blCheckActivePicId = 
true;
 
 2194         for ( $i = 1; $i <= $iPicCount; $i++) {
 
 2197             if ( !$oStr->strstr($sIcoVal, 
'nopic_ico.jpg') && !$oStr->strstr($sIcoVal, 
'nopic.jpg') &&
 
 2198                  !$oStr->strstr($sPicVal, 
'nopic_ico.jpg') && !$oStr->strstr($sPicVal, 
'nopic.jpg') ) {
 
 2202                 $aArtIcons[$i]= $sIcoVal;
 
 2203                 $aArtPics[$i]= $sPicVal;
 
 2206                 if ($iActPicId == $i) {
 
 2207                     $sActPic = $sPicVal;
 
 2208                     $blCheckActivePicId = 
false;
 
 2211             } 
else if ( $blCheckActivePicId && $iActPicId <= $i) {
 
 2219         $aZoomPics = array();
 
 2220         $iZoomPicCount = 
$myConfig->getConfigParam( 
'iPicCount' );
 
 2222         for ( $j = 1,$c = 1; $j <= $iZoomPicCount; $j++) {
 
 2225             if ( $sVal && !$oStr->strstr($sVal, 
'nopic.jpg')) {
 
 2227                 $aZoomPics[$c][
'id'] = $c;
 
 2228                 $aZoomPics[$c][
'file'] = $sVal;
 
 2231                     $aZoomPics[$c][
'file'] = 
"nopic.jpg";
 
 2237         $aPicGallery = array(
'ActPicID' => $iActPicId,
 
 2238                              'ActPic' => $sActPic,
 
 2239                              'MorePics' => $blMorePic,
 
 2240                              'Pics' => $aArtPics,
 
 2241                              'Icons' => $aArtIcons,
 
 2242                              'ZoomPic' => $blZoomPic,
 
 2243                              'ZoomPics' => $aZoomPics);
 
 2245         return $aPicGallery;
 
 2261     public function onChange($sAction = null, $sOXID = null, $sParentID = null)
 
 2265         if (!isset($sOXID)) {
 
 2266             if ( $this->
getId()) {
 
 2267                 $sOXID = $this->
getId();
 
 2269             if (!isset ($sOXID)) {
 
 2270                 $sOXID = $this->oxarticles__oxid->value;
 
 2272             if ($this->oxarticles__oxparentid->value) {
 
 2273                 $sParentID = $this->oxarticles__oxparentid->value;
 
 2276         if (!isset($sOXID)) {
 
 2281         if ( 
$myConfig->getConfigParam( 
'blUseStock' ) ) {
 
 2284             if (!isset($sParentID)) {
 
 2286                 $sQ = 
'select oxparentid from oxarticles where oxid = '.$oDb->quote($sOXID);
 
 2287                 $sParentID = $oDb->getOne( $sQ );
 
 2300         $sId = ( $sParentID ) ? $sParentID : $sOXID;
 
 2307         if ( $sAction === ACTION_UPDATE_STOCK ) {
 
 2322         if ( isset($this->oxarticles__oxvat->value) ) {
 
 2323             return $this->oxarticles__oxvat->value;
 
 2340         if ( !
$myConfig->getConfigParam( 
'blUseStock' ) ) {
 
 2346         $sQ = 
'select oxstock, oxstockflag from oxarticles where oxid = '.$oDb->quote( $this->
getId() );
 
 2347         $rs = $oDb->select( $sQ );
 
 2351         if ( $rs !== 
false && $rs->recordCount() > 0 ) {
 
 2352             $iOnStock   = $rs->fields[
'oxstock'] - $dArtStockAmount;
 
 2353             $iStockFlag = $rs->fields[
'oxstockflag'];
 
 2356             if ( $iStockFlag == 1 || $iStockFlag == 4) {
 
 2359             if ( !
$myConfig->getConfigParam( 
'blAllowUnevenAmounts' ) ) {
 
 2360                 $iOnStock = floor( $iOnStock );
 
 2363         if ($this->
getConfig()->getConfigParam( 
'blPsBasketReservationEnabled' )) {
 
 2364             $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
 
 2366         if ( $iOnStock >= $dAmount ) {
 
 2369             if ( $iOnStock > 0 ) {
 
 2372                 $oEx = 
oxNew( 
'oxArticleInputException' );
 
 2373                 $oEx->setMessage( 
'ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE' );
 
 2388         if ( $this->_oLongDesc === null ) {
 
 2390             $this->_oLongDesc = 
new oxField();
 
 2394             $sOxid = $this->
getId();
 
 2398             $sDbValue = $oDb->getOne( 
"select oxlongdesc from {$sViewName} where oxid = " . $oDb->quote( $sOxid ) );
 
 2400             if ( $sDbValue != 
false ) {
 
 2402             } elseif ( $this->oxarticles__oxparentid->value ) {
 
 2403                 if ( !$this->
isAdmin() || $this->_blLoadParentData ) {
 
 2446         if ( $this->_oAttributeList === null ) {
 
 2447             $this->_oAttributeList = 
oxNew( 
'oxattributelist' );
 
 2448             $this->_oAttributeList->loadAttributes( $this->
getId(), $this->
getParentId() );
 
 2461         if ( $this->_oAttributeList === null ) {
 
 2462             $this->_oAttributeList = 
oxNew( 
'oxattributelist' );
 
 2463             $this->_oAttributeList->loadAttributesDisplayableInBasket( $this->
getId(), $this->
getParentId() );
 
 2480         if ( $sAddParams ) {
 
 2481             if ( $iLang === null ) {
 
 2485             $this->_aSeoAddParams[$iLang]  = isset( $this->_aSeoAddParams[$iLang] ) ? $this->_aSeoAddParams[$iLang] . 
"&" : 
"";
 
 2486             $this->_aSeoAddParams[$iLang] .= $sAddParams;
 
 2502             return $oEncoder->getArticleUrl( $this, $iLang, $this->
getLinkType() );
 
 2504         return $oEncoder->getArticleMainUrl( $this, $iLang );
 
 2515     public function getLink( $iLang = null, $blMain = 
false  )
 
 2521         if ( $iLang === null ) {
 
 2526         if ( !isset( $this->_aSeoUrls[$iLang][$iLinkType] ) ) {
 
 2527             $this->_aSeoUrls[$iLang][$iLinkType] = $this->
getBaseSeoLink( $iLang, $blMain );
 
 2530         $sUrl = $this->_aSeoUrls[$iLang][$iLinkType];
 
 2531         if ( isset($this->_aSeoAddParams[$iLang])) {
 
 2532             $sUrl .= ( ( strpos( $sUrl.$this->_aSeoAddParams[$iLang], 
'?' ) === false ) ? 
'?' : 
'&' ).$this->_aSeoAddParams[$iLang];
 
 2548         return $this->
getLink( $iLang, 
true );
 
 2561         $this->_sDetailLink = null;
 
 2564         $this->_iLinkType = (int) $iType;
 
 2587         if ( $sAddParams ) {
 
 2588             if ( $iLang === null ) {
 
 2592             $this->_aStdAddParams[$iLang]  = isset( $this->_aStdAddParams[$iLang] ) ? $this->_aStdAddParams[$iLang] . 
"&" : 
"";
 
 2593             $this->_aStdAddParams[$iLang] .= $sAddParams;
 
 2611             $sUrl = $this->
getConfig()->getShopUrl( $iLang, 
false );
 
 2614         $sUrl .= 
'index.php?cl=details' . ( $blAddId ? 
'&anid=' . urlencode($this->
getId()) : 
'' );
 
 2615         return $sUrl . ( isset( $this->_aStdAddParams[$iLang] ) ? 
'&' . $this->_aStdAddParams[$iLang] : 
'' );
 
 2628         if ( $iLang === null ) {
 
 2632         if ( !isset( $this->_aStdUrls[$iLang] ) ) {
 
 2636         return oxRegistry::get(
"oxUtilsUrl")->processUrl( $this->_aStdUrls[$iLang], 
true, $aParams, $iLang );
 
 2650         $oArticleTags = 
oxNew(
'oxarticletaglist');
 
 2651         $oArticleTags->setArticleId( $this->
getId() );
 
 2652         return $oArticleTags->getStdTagLink($sTag);
 
 2664         $oArticleTags = 
oxNew(
'oxarticletaglist');
 
 2665         $oArticleTags->load( $this->
getId() );
 
 2666         return $oArticleTags->get()->__toString();
 
 2684         $oArticleTags = 
oxNew(
'oxarticletaglist');
 
 2685         $oArticleTags->setArticleId( $this->
getId() );
 
 2686         $oArticleTags->set( $sTags );
 
 2687         $oArticleTags->save();
 
 2701         $oArticleTags = 
oxNew(
'oxarticletaglist');
 
 2702         $oArticleTags->load( $this->
getId() );
 
 2703         $oArticleTags->addTag( $sTag );
 
 2704         if ( $oArticleTags->save() ) {
 
 2717         if ( $this->_aMediaUrls === null ) {
 
 2718             $this->_aMediaUrls = 
oxNew(
"oxlist");
 
 2719             $this->_aMediaUrls->init(
"oxmediaurl");
 
 2720             $this->_aMediaUrls->getBaseObject()->setLanguage( $this->
getLanguage() );
 
 2723             $sQ = 
"select * from {$sViewName} where oxobjectid = '".$this->getId().
"'";
 
 2724             $this->_aMediaUrls->selectString($sQ);
 
 2746         if ($this->_aDispSelList === null) {
 
 2747             if ( $this->
getConfig()->getConfigParam( 
'bl_perfLoadSelectLists' ) && $this->
getConfig()->getConfigParam( 
'bl_perfLoadSelectListsInAList' ) ) {
 
 2761         if ( $this->_sMoreDetailLink == null ) {
 
 2764             $this->_sMoreDetailLink = $this->
getConfig()->getShopHomeURL() . 
'cl=moredetails';
 
 2768                 $this->_sMoreDetailLink .= 
'&cnid='.$sActCat;
 
 2770             $this->_sMoreDetailLink .= 
'&anid='.$this->getId();
 
 2784         if ( $this->_sToBasketLink == null ) {
 
 2788                 $this->_sToBasketLink = $this->
getLink();
 
 2791                 $this->_sToBasketLink = 
$myConfig->getShopHomeURL();
 
 2795                 if ( $sActClass == 
'thankyou') {
 
 2796                     $sActClass = 
'basket';
 
 2798                 $this->_sToBasketLink .= 
'cl='.$sActClass;
 
 2802                     $this->_sToBasketLink .= 
'&cnid='.$sActCat;
 
 2805                 $this->_sToBasketLink .= 
'&fnc=tobasket&aid='.$this->getId().
'&anid='.$this->
getId();
 
 2808                     $this->_sToBasketLink .= 
'&tpl='.$sTpl;
 
 2843         return $this->
_isStockStatusChanged() && ($this->_iStockStatus == -1 || $this->_iStockStatusOnLoad == -1);
 
 2853         if ( $this->oxarticles__oxdelivery->value != 
'0000-00-00') {
 
 2854             return oxRegistry::get(
"oxUtilsDate")->formatDBDate( $this->oxarticles__oxdelivery->value);
 
 2885         if ( $oPrice = $this->
getPrice() ) {
 
 2899         if ( $this->oxarticles__oxremindactive->value == 2 &&
 
 2900             $this->oxarticles__oxremindamount->value <= $this->oxarticles__oxstock->value ) {
 
 2901             $this->oxarticles__oxremindactive->value = 1;
 
 2916         if ( $oPrice = $this->
getPrice() ) {
 
 2962         $this->_blNotBuyable = !$blBuyable;
 
 2974         $this->_aDispSelList = $aSelList;
 
 2988             if ( !$this->
_isFieldEmpty( 
"oxarticles__oxpic".$iIndex ) ) {
 
 2989                 $sImgName = basename( $this->{
"oxarticles__oxpic$iIndex"}->value );
 
 2992             $sSize = $this->
getConfig()->getConfigParam( 
'aDetailImageSizes' );
 
 2993             return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl( 
"product/{$iIndex}/", $sImgName, $sSize, 
'oxpic'.$iIndex );
 
 3008         $sDirname = 
"product/1/";
 
 3009         if ( $iIndex && !$this->
_isFieldEmpty( 
"oxarticles__oxpic{$iIndex}" ) ) {
 
 3010             $sImgName = basename( $this->{
"oxarticles__oxpic$iIndex"}->value );
 
 3011             $sDirname = 
"product/{$iIndex}/";
 
 3012         } elseif ( !$this->
_isFieldEmpty( 
"oxarticles__oxicon" ) ) {
 
 3013             $sImgName = basename( $this->oxarticles__oxicon->value );
 
 3014             $sDirname = 
"product/icon/";
 
 3015         } elseif ( !$this->
_isFieldEmpty( 
"oxarticles__oxpic1" ) ) {
 
 3016             $sImgName = basename( $this->oxarticles__oxpic1->value );
 
 3019         $sSize = $this->
getConfig()->getConfigParam( 
'sIconsize' );
 
 3020         return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl( $sDirname, $sImgName, $sSize, $iIndex );
 
 3033         $sDirname = 
"product/1/";
 
 3035             $sImgName = basename( $this->oxarticles__oxthumb->value );
 
 3036             $sDirname = 
"product/thumb/";
 
 3037         } elseif ( !$this->
_isFieldEmpty( 
"oxarticles__oxpic1" ) ) {
 
 3038             $sImgName = basename( $this->oxarticles__oxpic1->value );
 
 3041         $sSize = $this->
getConfig()->getConfigParam( 
'sThumbnailsize' );
 
 3042         return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl( $sDirname, $sImgName, $sSize, 0, $bSsl );
 
 3054         $iIndex = (int) $iIndex;
 
 3055         if ( $iIndex > 0 && !$this->
_isFieldEmpty( 
"oxarticles__oxpic".$iIndex ) ) {
 
 3056             $sImgName = basename( $this->{
"oxarticles__oxpic".$iIndex}->value );
 
 3057             $sSize = $this->
getConfig()->getConfigParam( 
"sZoomImageSize" );
 
 3058             return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl( 
"product/{$iIndex}/", $sImgName, $sSize, 
'oxpic'.$iIndex );
 
 3071         return $this->
getConfig()->getPictureUrl( 
'media/' );
 
 3084         if ( $this->_blIsRangePrice) {
 
 3088         return $sPricePrefix;
 
 3100         if (in_array(
"oxlongdesc", $this->_aSkipSaveFields)) {
 
 3104         if ($this->_blEmployMultilanguage) {
 
 3106             if ( $sValue !== null ) {
 
 3107                 $oArtExt = 
oxNew(
'oxI18n');
 
 3108                 $oArtExt->init(
'oxartextends');
 
 3109                 $oArtExt->setLanguage((
int) $this->
getLanguage());
 
 3110                 if (!$oArtExt->load($this->getId())) {
 
 3111                     $oArtExt->setId($this->
getId());
 
 3117             $oArtExt = 
oxNew(
'oxI18n');
 
 3118             $oArtExt->setEnableMultilang(
false);
 
 3119             $oArtExt->init(
'oxartextends');
 
 3120             $aObjFields = $oArtExt->_getAllFields(
true);
 
 3121             if (!$oArtExt->load($this->getId())) {
 
 3122                 $oArtExt->setId($this->
getId());
 
 3125             foreach ($aObjFields as $sKey => $sValue ) {
 
 3126                 if ( preg_match(
'/^oxlongdesc(_(\d{1,2}))?$/', $sKey) ) {
 
 3129                     if (isset($this->$sField)) {
 
 3131                         if ($this->$sField instanceof 
oxField) {
 
 3132                             $sLongDesc = $this->$sField->getRawValue();
 
 3133                         } elseif (is_object($this->$sField)) {
 
 3134                             $sLongDesc = $this->$sField->value;
 
 3136                         if (isset($sLongDesc)) {
 
 3137                             $sAEField = $oArtExt->_getFieldLongName($sKey);
 
 3156         $this->_aSkipSaveFields = array();
 
 3158         $this->_aSkipSaveFields[] = 
'oxtimestamp';
 
 3160         $this->_aSkipSaveFields[] = 
'oxinsert';
 
 3162         if ( !$this->_blAllowEmptyParentId && (!isset( $this->oxarticles__oxparentid->value) || $this->oxarticles__oxparentid->value == 
'') ) {
 
 3163             $this->_aSkipSaveFields[] = 
'oxparentid';
 
 3179         foreach ( $aItemDiscounts as $sKey => $oDiscount ) {
 
 3181             if ( array_key_exists ($sKey, $aDiscounts) ) {
 
 3182                 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
 
 3184                 $aDiscounts[$sKey] = $oDiscount;
 
 3198         $sVarName = 
"oxarticles__oxprice{$sPriceSufix}";
 
 3199         $dPrice = $this->$sVarName->value;
 
 3202         if ( $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) && (
double) $dPrice == 0 ) {
 
 3203             $dPrice = $this->oxarticles__oxprice->value;
 
 3219         startProfile( 
"_getAmountPrice" );
 
 3223         foreach ($oAmtPrices as $oAmPrice) {
 
 3224             if ($oAmPrice->oxprice2article__oxamount->value <= $dAmount
 
 3225                     && $dAmount <= $oAmPrice->oxprice2article__oxamountto->value
 
 3226                     && $dPrice > $oAmPrice->oxprice2article__oxaddabs->value ) {
 
 3227                 $dPrice = $oAmPrice->oxprice2article__oxaddabs->value;
 
 3231         stopProfile( 
"_getAmountPrice" );
 
 3247         if ( 
$myConfig->getConfigParam( 
'bl_perfLoadSelectLists' ) && 
$myConfig->getConfigParam( 
'bl_perfUseSelectlistPrice' ) ) {
 
 3251             foreach ( $aSelLists as $key => $aSel) {
 
 3252                 if ( isset( $aChosenList[$key]) && isset($aSel[$aChosenList[$key]] ) ) {
 
 3253                     $oSel = $aSel[$aChosenList[$key]];
 
 3254                     if ( $oSel->priceUnit ==
'abs' ) {
 
 3255                         $dPrice += $oSel->price;
 
 3256                     } elseif ( $oSel->priceUnit ==
'%' ) {
 
 3278         foreach ($aAmPriceList as $sId => $oItem) {
 
 3281             if ( $oItem->oxprice2article__oxaddabs->value ) {
 
 3283                 $dBasePrice = $oItem->oxprice2article__oxaddabs->value;
 
 3286                 $oItemPrice->setPrice( $dBasePrice );
 
 3292                 $oItemPrice->setPrice( $dBasePrice );
 
 3293                 $oItemPrice->subtractPercent( $oItem->oxprice2article__oxaddperc->value );
 
 3297             $aAmPriceList[$sId]->fbrutprice = $oLang->formatCurrency( $this->
_getPriceForView( $oItemPrice ) );
 
 3300         return $aAmPriceList;
 
 3312         if ( ( $sId = $this->
getId() ) ) {
 
 3314             $sQ = 
"select oxid from " . $this->
getViewName( 
true ) . 
" where oxparentid = ".$oDb->quote( $sId ).
" and " .
 
 3316             $oRs = $oDb->select( $sQ );
 
 3317             if ( $oRs != 
false && $oRs->recordCount() > 0 ) {
 
 3318                 while (!$oRs->EOF) {
 
 3319                     $aSelect[] = reset( $oRs->fields );
 
 3334         if (!isset($this->_dArticleVat)) {
 
 3335             $this->_dArticleVat = 
oxRegistry::get(
"oxVatSelector")->getArticleVat( $this );
 
 3350         startProfile(__FUNCTION__);
 
 3351         $oPrice->setVAT( $dVat );
 
 3354         if ( ($dVat = $oVatSelector->getArticleUserVat($this)) !== 
false ) {
 
 3357         stopProfile(__FUNCTION__);
 
 3384             $aDiscounts = $oDiscountList->getArticleDiscounts( $this, $this->
getArticleUser() );
 
 3386             reset( $aDiscounts );
 
 3387             foreach ( $aDiscounts as $oDiscount ) {
 
 3388                 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
 
 3390             $oPrice->calculateDiscount();
 
 3405             $oCur = $this->
getConfig()->getActShopCurrencyObject();
 
 3424         $sSelect =  
'select oxattrid from oxobject2attribute where oxobject2attribute.oxobjectid='.$oDb->quote( $this->
getId() );
 
 3427         $rs = $oDb->select( $sSelect);
 
 3429         if ($rs != 
false && $rs->recordCount() > 0) {
 
 3432                     $sAttribs .= 
' or ';
 
 3434                 $sAttribs .= 
't1.oxattrid = '.$oDb->quote($rs->fields[
'oxattrid']).
' ';
 
 3456         $iAttrPercent = 
$myConfig->getConfigParam( 
'iAttributesPercent' )/100;
 
 3458         if ( !$iAttrPercent || $iAttrPercent < 0 || $iAttrPercent > 1) {
 
 3459             $iAttrPercent = 0.70;
 
 3462         $iHitMin = ceil( $iCnt * $iAttrPercent );
 
 3466         $sSelect =  
"select oxobjectid, count(*) as cnt from oxobject2attribute as t1 where 
 3468                     and t1.oxobjectid != ".$oDb->quote( $this->oxarticles__oxid->value ).
" 
 3469                     group by t1.oxobjectid having count(*) >= $iHitMin ";
 
 3471         $rs = $oDb->selectLimit( $sSelect, 20, 0 );
 
 3472         if ($rs != 
false && $rs->recordCount() > 0) {
 
 3474                 $oTemp = 
new stdClass();    
 
 3475                 $oTemp->cnt = $rs->fields[
'cnt'];
 
 3476                 $oTemp->id  = $rs->fields[
'oxobjectid'];
 
 3496         $sSearch = 
"select $sFieldList from $sArticleTable where ".$this->getSqlActiveSnippet().
"  and $sArticleTable.oxissearch = 1 and $sArticleTable.oxid in ( ";
 
 3500         foreach ( $aList as $oTemp) {
 
 3504             $sSearch .= $oDb->quote($oTemp->id);
 
 3506             if ( $iCnt >= 
$myConfig->getConfigParam( 
'iNrofSimilarArticles' ) ) {
 
 3517         $sSearch .= 
' order by rand() ';
 
 3537         if ( !$blSearchPriceCat ) {
 
 3538             $sSelect  = 
"select {$sCatView}.* from {$sO2CView} as oxobject2category left join {$sCatView} on 
 3539                          {$sCatView}.oxid = oxobject2category.oxcatnid 
 3540                          where oxobject2category.oxobjectid=".oxDb::getDb()->quote($sOXID).
" and {$sCatView}.oxid is not null ";
 
 3542             $sSelect  = 
"select {$sCatView}.* from {$sCatView} where 
 3543                          '{$this->oxarticles__oxprice->value}' >= {$sCatView}.oxpricefrom and 
 3544                          '{$this->oxarticles__oxprice->value}' <= {$sCatView}.oxpriceto ";
 
 3557         $sOrderArtTable = 
getViewName( 
'oxorderarticles' );
 
 3560         $sIn = 
" '{$this->oxarticles__oxid->value}' ";
 
 3561         if ( $this->oxarticles__oxparentid->value ) {
 
 3564             $sIn .= 
", '{$this->oxarticles__oxparentid->value}' ";
 
 3565             $sParentIdForVariants = $this->oxarticles__oxparentid->value;
 
 3568             $sParentIdForVariants = $this->
getId();
 
 3573         $oRs = $oDb->select( 
"select oxid from {$sArtTable} where oxparentid = ".$oDb->quote($sParentIdForVariants).
" and oxid != ".$oDb->quote($this->oxarticles__oxid->value) );
 
 3574         if ( $oRs != 
false && $oRs->recordCount() > 0) {
 
 3575             while ( !$oRs->EOF ) {
 
 3576                 $sIn .= 
", ".$oDb->quote(current( $oRs->fields )).
" ";
 
 3581         $iLimit = (int) $this->
getConfig()->getConfigParam( 
'iNrofCustomerWhoArticles' );
 
 3582         $iLimit = $iLimit?( $iLimit * 10 ): 50;
 
 3585         $sQ = 
"select distinct {$sArtTable}.* from ( 
 3586                    select d.oxorderid as suborderid from {$sOrderArtTable} as d use index ( oxartid ) where d.oxartid in ( {$sIn} ) limit {$iLimit} 
 3588                left join {$sOrderArtTable} force index ( oxorderid ) on suborder.suborderid = {$sOrderArtTable}.oxorderid 
 3589                left join {$sArtTable} on {$sArtTable}.oxid = {$sOrderArtTable}.oxartid 
 3590                where {$sArtTable}.oxid not in ( {$sIn} ) 
 3591                and ( {$sArtTable}.oxissearch = 1 or {$sArtTable}.oxparentid <> '' ) and ".$this->getSqlActiveSnippet();
 
 3620         $sOXID  = $oDb->quote($sOXID);
 
 3621         $sCatId = $oDb->quote($sCatId);
 
 3623         if (!$dPriceFromTo) {
 
 3624             $sSelect  = 
"select oxobject2category.oxcatnid from $sO2CView as oxobject2category ";
 
 3625             $sSelect .= 
"left join $sCategoryView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
 
 3626             $sSelect .= 
"where oxobject2category.oxcatnid=$sCatId and oxobject2category.oxobjectid=$sOXID ";
 
 3627             $sSelect .= 
"and oxcategories.oxactive = 1 order by oxobject2category.oxtime ";
 
 3629             $dPriceFromTo = $oDb->quote($dPriceFromTo);
 
 3630             $sSelect  = 
"select oxcategories.oxid from $sCategoryView as oxcategories where ";
 
 3631             $sSelect .= 
"oxcategories.oxid=$sCatId and $dPriceFromTo >= oxcategories.oxpricefrom and ";
 
 3632             $sSelect .= 
"$dPriceFromTo <= oxcategories.oxpriceto ";
 
 3644         if ( $this->_oAmountPriceList === null ) {
 
 3645             $oAmPriceList = 
oxNew( 
'oxAmountPricelist' );
 
 3649                 $oAmPriceList->load( $this );
 
 3653                 foreach ( $oAmPriceList as $oAmPrice ) {
 
 3654                     if ( $oAmPrice->oxprice2article__oxaddperc->value ) {
 
 3661             $this->_oAmountPriceList = $oAmPriceList;
 
 3676         $mValue = $this->$sFieldName->value;
 
 3678         if ( is_null( $mValue ) ) {
 
 3682         if ( $mValue === 
'' ) {
 
 3687         $aZeroValueFields = array(
'oxarticles__oxprice', 
'oxarticles__oxvat', 
'oxarticles__oxunitquantity');
 
 3689         if (!$mValue && in_array( $sFieldName, $aZeroValueFields ) ) {
 
 3694         if (!strcmp($mValue, 
'0000-00-00 00:00:00') || !strcmp($mValue, 
'0000-00-00')) {
 
 3698         $sFieldName = strtolower($sFieldName);
 
 3700         if ( $sFieldName == 
'oxarticles__oxicon' && ( strpos($mValue, 
"nopic_ico.jpg") !== 
false || strpos($mValue, 
"nopic.jpg") !== 
false ) ) {
 
 3704         if ( strpos($mValue, 
"nopic.jpg") !== 
false && ($sFieldName == 
'oxarticles__oxthumb' || substr($sFieldName, 0, 17) == 
'oxarticles__oxpic' || substr($sFieldName, 0, 18) == 
'oxarticles__oxzoom') ) {
 
 3720         $blIsImageField = ( stristr($sFieldName, 
'_oxthumb') || stristr($sFieldName, 
'_oxicon') || stristr($sFieldName, 
'_oxzoom') || stristr($sFieldName, 
'_oxpic') );
 
 3721         return $blIsImageField;
 
 3740         if ( $oParentArticle->$sCopyFieldName != null ) {
 
 3743             if ( substr( $sCopyFieldName, 0, 12) != 
'oxarticles__') {
 
 3748             if (in_array($sCopyFieldName, $this->_aNonCopyParentFields)) {
 
 3759                 $this->$sCopyFieldName = clone $oParentArticle->$sCopyFieldName;
 
 3771         if ( ( $sParentId = $this->oxarticles__oxparentid->value ) ) {
 
 3772             $sIndex = $sParentId . 
"_" . $this->
getLanguage();
 
 3773             if ( !isset( self::$_aLoadedParents[$sIndex] ) ) {
 
 3774                 self::$_aLoadedParents[$sIndex] = 
oxNew( 
'oxarticle' );
 
 3775                 self::$_aLoadedParents[$sIndex]->_blLoadPrice    = 
false;
 
 3776                 self::$_aLoadedParents[$sIndex]->_blLoadVariants = 
false;
 
 3777                 self::$_aLoadedParents[$sIndex]->loadInLang( $this->
getLanguage(), $sParentId );
 
 3779             return self::$_aLoadedParents[$sIndex];
 
 3790         startProfile(
'articleAssignParentInternal');
 
 3791         if ( $this->oxarticles__oxparentid->value ) {
 
 3793             if ( !$this->
isAdmin() || ( $this->_blLoadParentData && $this->
isAdmin() ) ) {
 
 3794                 foreach ( $this->_aFieldNames as $sFieldName => $sVal ) {
 
 3799         stopProfile(
'articleAssignParentInternal');
 
 3809         if ( !$this->
getConfig()->getConfigParam( 
'blVariantParentBuyable' ) &&
 
 3810              ($this->_blHasVariants || $this->oxarticles__oxvarstock->value || $this->oxarticles__oxvarcount->value )) {
 
 3811             $this->_blNotBuyableParent = 
true;
 
 3829         if (!
$myConfig->getConfigParam( 
'blAllowUnevenAmounts' ) && !$this->
isAdmin() ) {
 
 3830             $this->oxarticles__oxstock = 
new oxField((
int) floor($this->oxarticles__oxstock->value));
 
 3833         $this->_iStockStatus = 0;
 
 3836         if ( 
$myConfig->getConfigParam( 
'blUseStock' ) &&  $this->oxarticles__oxstockflag->value != 4) {
 
 3838             $iStock = $this->oxarticles__oxstock->value;
 
 3840             if ($this->_blNotBuyableParent) {
 
 3841                 $iStock = $this->oxarticles__oxvarstock->value;
 
 3845             if ( $iStock <= $myConfig->getConfigParam( 
'sStockWarningLimit' ) && $iStock > 0) {
 
 3846                 $this->_iStockStatus = 1;
 
 3851                 $this->_iStockStatus = -1;
 
 3857         if ( 
$myConfig->getConfigParam( 
'blUseStock' ) && ($this->oxarticles__oxstockflag->value == 3 || $this->oxarticles__oxstockflag->value == 2)) {
 
 3858             $iOnStock = $this->oxarticles__oxstock->value;
 
 3859             if ($this->
getConfig()->getConfigParam( 
'blPsBasketReservationEnabled' )) {
 
 3860                 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
 
 3862             if ($iOnStock <= 0) {
 
 3868         if ($this->_blNotBuyable && $this->oxarticles__oxvarstock->value ) {
 
 3871             $this->_blNotBuyableParent = 
true;
 
 3877         if ( !
$myConfig->getConfigParam( 
'blVariantParentBuyable' ) && !
$myConfig->getConfigParam( 
'blLoadVariants' ) && $this->oxarticles__oxvarstock->value) {
 
 3882         if (!$this->_blNotBuyable && $this->_blNotBuyableParent && $this->oxarticles__oxvarcount->value == 0) {
 
 3918         if ( isset( $aPersParam) && isset( $aPersParam[$this->
getId()])) {
 
 3919             $this->_aPersistParam = $aPersParam[$this->
getId()];
 
 3932         $sThisShop = $this->oxarticles__oxshopid->value;
 
 3934         $this->_sDynImageDir   = 
$myConfig->getPictureUrl( null, 
false );
 
 3935         $this->dabsimagedir    = 
$myConfig->getPictureDir( 
false ); 
 
 3936         $this->nossl_dimagedir = 
$myConfig->getPictureUrl( null, 
false, 
false, null, $sThisShop ); 
 
 3937         $this->ssl_dimagedir   = 
$myConfig->getPictureUrl( null, 
false, 
true, null, $sThisShop ); 
 
 3950         if ( isset( $aItems[$this->
getId()])) {
 
 3951             $this->_blIsOnComparisonList = 
true;
 
 3966         $sNow = date(
'Y-m-d H:i:s', 
oxRegistry::get(
"oxUtilsDate")->getTime());
 
 3967         $this->oxarticles__oxinsert    = 
new oxField( $sNow );
 
 3968         if ( !is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value == 
'') {
 
 3969             $this->oxarticles__oxsubclass = 
new oxField(
'oxarticle');
 
 4007             $sOxId = $oDb->quote($this->
getId());
 
 4008             $sOxShopId = $oDb->quote($this->
getShopId());
 
 4009             $iRemindActive = $oDb->quote($this->oxarticles__oxremindactive->value);
 
 4012                     set oxremindactive = $iRemindActive 
 4013                     where oxparentid = $sOxId and 
 4014                           oxshopid = $sOxShopId 
 4016             $oDb->execute( $sUpdate );
 
 4031         $sOXID = $oDb->quote($sOXID);
 
 4034         $sDelete = 
'delete from oxobject2article where oxarticlenid = '.$sOXID.
' or oxobjectid = '.$sOXID.
' ';
 
 4035         $oDb->execute( $sDelete);
 
 4037         $sDelete = 
'delete from oxobject2attribute where oxobjectid = '.$sOXID.
' ';
 
 4038         $oDb->execute( $sDelete);
 
 4040         $sDelete = 
'delete from oxobject2category where oxobjectid = '.$sOXID.
' ';
 
 4041         $oDb->execute( $sDelete);
 
 4043         $sDelete = 
'delete from oxobject2selectlist where oxobjectid = '.$sOXID.
' ';
 
 4044         $oDb->execute( $sDelete);
 
 4046         $sDelete = 
'delete from oxprice2article where oxartid = '.$sOXID.
' ';
 
 4047         $oDb->execute( $sDelete);
 
 4049         $sDelete = 
'delete from oxreviews where oxtype="oxarticle" and oxobjectid = '.$sOXID.
' ';
 
 4050         $oDb->execute( $sDelete);
 
 4052         $sDelete = 
'delete from oxratings where oxobjectid = '.$sOXID.
' ';
 
 4053         $rs = $oDb->execute( $sDelete );
 
 4055         $sDelete = 
'delete from oxaccessoire2article where oxobjectid = '.$sOXID.
' or oxarticlenid = '.$sOXID.
' ';
 
 4056         $oDb->execute( $sDelete);
 
 4059         $sDelete = 
'delete from oxobject2delivery where oxobjectid = '.$sOXID.
' and oxtype=\'oxarticles\' ';
 
 4060         $oDb->execute( $sDelete);
 
 4062         $sDelete = 
'delete from oxartextends where oxid = '.$sOXID.
' ';
 
 4063         $oDb->execute( $sDelete);
 
 4067             $oDb->execute( 
"delete from $sSetTbl where oxid = {$sOXID}" );
 
 4070         $sDelete = 
'delete from oxactions2article where oxartid = '.$sOXID.
' ';
 
 4071         $rs = $oDb->execute( $sDelete );
 
 4073         $sDelete = 
'delete from oxobject2list where oxobjectid = '.$sOXID.
' ';
 
 4074         $rs = $oDb->execute( $sDelete );
 
 4092             $sQ = 
'select oxid from '.$this->getViewName().
' where oxparentid = '.$oDb->quote( $sOXID );
 
 4093             $rs = $oDb->select( $sQ, 
false, 
false );
 
 4094             $oArticle = 
oxNew(
"oxArticle");
 
 4095             if ($rs != 
false && $rs->recordCount() > 0) {
 
 4097                     $oArticle->setId($rs->fields[0]);
 
 4098                     $oArticle->delete();
 
 4117         $oPictureHandler->deleteMainIcon( $this );
 
 4120         $oPictureHandler->deleteThumbnail( $this );
 
 4122         $sAbsDynImageDir = 
$myConfig->getPictureDir(
false);
 
 4125         $iPicCount = 
$myConfig->getConfigParam( 
'iPicCount' );
 
 4126         for ( $i = 1; $i <= $iPicCount; $i++ ) {
 
 4127             $oPictureHandler->deleteArticleMasterPicture( $this, $i );
 
 4146             $myUtilsCount->resetVendorArticleCount( $sVendorId );
 
 4149         if ( $sManufacturerId ) {
 
 4150             $myUtilsCount->resetManufacturerArticleCount( $sManufacturerId );
 
 4155         $sQ = 
"select oxcatnid from oxobject2category where oxobjectid = ".$oDb->quote($sOxid);
 
 4156         $oRs = $oDb->select( $sQ, 
false, 
false );
 
 4157         if ( $oRs !== 
false && $oRs->recordCount() > 0) {
 
 4158             while ( !$oRs->EOF ) {
 
 4159                 $myUtilsCount->resetCatArticleCount( $oRs->fields[0] );
 
 4176             $sParentIdQuoted = $oDb->quote($sParentID);
 
 4177             $sQ = 
'select oxstock, oxvendorid, oxmanufacturerid from oxarticles where oxid = '.$sParentIdQuoted;
 
 4178             $rs = $oDb->select( $sQ, 
false, 
false );
 
 4179             $iOldStock = $rs->fields[0];
 
 4180             $iVendorID = $rs->fields[1];
 
 4181             $iManufacturerID = $rs->fields[2];
 
 4183             $sQ = 
'select sum(oxstock) from '.$this->getViewName(
true).
' where oxparentid = '.$sParentIdQuoted.
' and '. $this->
getSqlActiveSnippet( 
true ).
' and oxstock > 0 ';
 
 4184             $iStock = (float) $oDb->getOne( $sQ, 
false, 
false );
 
 4186             $sQ = 
'update oxarticles set oxvarstock = '.$iStock.
' where oxid = '.$sParentIdQuoted;
 
 4187             $oDb->execute( $sQ );
 
 4191             if ( $iStock < 0 ) {
 
 4194             if ( $iOldStock < 0 ) {
 
 4197             if ( $this->oxarticles__oxstockflag->value == 2 && $iOldStock xor $iStock ) {
 
 4216         if ( 
$myConfig->getConfigParam( 
'blUseStock' ) && $this->oxarticles__oxstockflag->value == 2 &&
 
 4217            ( $this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value ) <= 0 ) {
 
 4219                $this->
_onChangeResetCounts( $sOxid, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value );
 
 4234             $sParentIdQuoted = $oDb->quote( $sParentID );
 
 4235             $sQ = 
"select count(*) as varcount from oxarticles where oxparentid = {$sParentIdQuoted}";
 
 4236             $iVarCount = (int) $oDb->getOne( $sQ, 
false, 
false );
 
 4238             $sQ = 
"update oxarticles set oxvarcount = {$iVarCount} where oxid = {$sParentIdQuoted}";
 
 4239             $oDb->execute( $sQ );
 
 4256                     MIN( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varminprice`, 
 4257                     MAX( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varmaxprice` 
 4258                 FROM '. $this->
getViewName(
true) . 
' AS `oxarticles` 
 4259                     LEFT JOIN '. $this->
getViewName(
true) . 
' AS `p` ON ( `p`.`oxid` = `oxarticles`.`oxparentid` AND `p`.`oxprice` > 0 ) 
 4261                     AND ( `oxarticles`.`oxparentid` = '. $oDb->quote( $sParentId ) .
' )';
 
 4263             $aPrices = $oDb->getRow( $sQ, 
false, 
false );
 
 4264             if ( !is_null( $aPrices[
'varminprice'] ) || !is_null( $aPrices[
'varmaxprice'] ) ) {
 
 4268                         `oxvarminprice` = '. $oDb->quote( $aPrices[
'varminprice'] ) .
', 
 4269                         `oxvarmaxprice` = '. $oDb->quote( $aPrices[
'varmaxprice'] ) .
' 
 4271                         `oxid` = ' . $oDb->quote( $sParentId );
 
 4276                         `oxvarminprice` = `oxprice`, 
 4277                         `oxvarmaxprice` = `oxprice` 
 4279                         `oxid` = ' . $oDb->quote( $sParentId );
 
 4281             $oDb->execute( $sQ );
 
 4299             $sParentIdQuoted = $oDb->quote($sParentID);
 
 4301             $sQ = 
'select min(oxprice) as varminprice from '.$this->getViewName(
true).
' where '.$this->
getSqlActiveSnippet(
true).
' and (oxparentid = '.$sParentIdQuoted.
')';
 
 4302             $dVarMinPrice = $oDb->getOne( $sQ, 
false, 
false );
 
 4304             $dParentPrice = $oDb->getOne( 
"select oxprice from oxarticles where oxid = $sParentIdQuoted ", 
false, 
false );
 
 4306             $blParentBuyable =  $this->
getConfig()->getConfigParam( 
'blVariantParentBuyable' );
 
 4308             if ($dVarMinPrice) {
 
 4309                 if ($blParentBuyable) {
 
 4310                     $dVarMinPrice = min($dVarMinPrice, $dParentPrice);
 
 4313                 $dVarMinPrice = $dParentPrice;
 
 4316             if ( $dVarMinPrice ) {
 
 4317                 $sQ = 
'update oxarticles set oxvarminprice = '.$dVarMinPrice.
' where oxid = '.$sParentIdQuoted;
 
 4334         if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
 
 4338         $this->_blIsRangePrice = 
false;
 
 4341         if ($this->_blSkipFromPrice || !$this->_blNotBuyableParent) {
 
 4347             $dPrice = $this->
_preparePrice( $this->oxarticles__oxvarminprice->value, $this->getArticleVat() );
 
 4348             $this->
getPrice()->setPrice($dPrice);
 
 4349             $this->_blIsRangePrice = 
true;
 
 4357         if (!$this->_blNotBuyableParent) {
 
 4358             $aPrices[] = $this->
getPrice()->getPrice();
 
 4363         if (count($aVariants)) {
 
 4364             foreach ($aVariants as $sKey => $oVariant) {
 
 4365                 $aPrices[] = $oVariant->getPrice()->getPrice();
 
 4369         if ( count( $aPrices ) ) {
 
 4370             $dMinPrice = min( $aPrices );
 
 4371             $dMaxPrice = max( $aPrices );
 
 4374         if ($this->_blNotBuyableParent && isset($dMinPrice) && $dMinPrice == $dMaxPrice) {
 
 4375             $this->
getPrice()->setPrice($dMinPrice);
 
 4378         if (isset($dMinPrice) && $dMinPrice != $dMaxPrice) {
 
 4379             $this->
getPrice()->setPrice($dMinPrice);
 
 4380             $this->_blIsRangePrice = 
true;
 
 4392         return $this->
getId();
 
 4414         return $this->oxarticles__oxparentid->value;
 
 4434         return (
bool) ( isset( $this->oxarticles__oxparentid ) ? $this->oxarticles__oxparentid->value : false );
 
 4444         $oMdVariant = 
oxNew( 
"oxVariantHandler" );
 
 4446         return $oMdVariant->isMdVariant($this);
 
 4461         $sSelectWhere = 
"select $sFields from ".$this->_getObjectViewName(
'oxcategories').
" where";
 
 4462         $sQuotedPrice = 
oxDb::getDb()->quote( $this->oxarticles__oxprice->value );
 
 4463         return  "$sSelectWhere oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice" 
 4464                .
" union $sSelectWhere oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice" 
 4465                .
" union $sSelectWhere oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice";
 
 4479         $sQuotedPrice = $oDb->quote( $this->oxarticles__oxprice->value );
 
 4480         $sQuotedCnid = $oDb->quote( $sCatNid );
 
 4481         return (
bool) $oDb->getOne(
 
 4482             "select 1 from ".$this->
_getObjectViewName(
'oxcategories').
" where oxid=$sQuotedCnid and" 
 4483            .
"(   (oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice)" 
 4484            .
" or (oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice)" 
 4485            .
" or (oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice)" 
 4497         if ( $this->_oMdVariants ) {
 
 4502         if ( $oParentArticle ) {
 
 4503             $oVariants = $oParentArticle->getVariants();
 
 4508         $oVariantHandler = 
oxNew( 
"oxVariantHandler" );
 
 4509         $this->_oMdVariants = $oVariantHandler->buildMdVariants( $oVariants, $this->
getId() );
 
 4533         $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
 
 4535         if ( $sPicName == 
"nopic.jpg" || $sPicName == 
"" ) {
 
 4538         if ( $this->
isVariant() && $this->
getParentArticle()->{
"oxarticles__oxpic".$iIndex}->value == $this->{
"oxarticles__oxpic".$iIndex}->value ) {
 
 4542         $sMasterPic = 
'product/'.$iIndex . 
"/" . $sPicName;
 
 4544         if ( $this->
getConfig()->getMasterPicturePath( $sMasterPic ) ) {
 
 4561         if ( $sFieldName ) {
 
 4562             $sFieldName = 
"oxarticles__" . $sFieldName . $iIndex;
 
 4563             return $this->$sFieldName->value;
 
 4577         $sPicName = basename( $this->{
"oxarticles__oxpic" . $iIndex}->value );
 
 4579         if ( $sPicName && $sPicName != 
"nopic.jpg" ) {
 
 4580             $sPicUrl = $this->
getConfig()->getPictureUrl( 
"master/product/" . $iIndex . 
"/" . $sPicName );
 
 4581             if ( !$sPicUrl || basename( $sPicUrl ) == 
"nopic.jpg" ) {
 
 4596         if ( $this->oxarticles__oxunitname->value ) {
 
 4610         if ( $this->_aArticleFiles === null) {
 
 4612             $this->_aArticleFiles = 
false;
 
 4614             $sQ = 
"SELECT * FROM `oxfiles` WHERE `oxartid` = '".$this->getId().
"'";
 
 4616             if ( !$this->
getConfig()->getConfigParam( 
'blVariantParentBuyable' ) && $blAddFromParent ) {
 
 4617                 $sQ .= 
" OR `oxartId` = '". $this->oxarticles__oxparentid->value . 
"'";
 
 4620             $oArticleFiles = 
oxNew(
"oxlist");
 
 4621             $oArticleFiles->init(
"oxfile");
 
 4622             $oArticleFiles->selectString( $sQ );
 
 4623             $this->_aArticleFiles  = $oArticleFiles;
 
 4637         return $this->oxarticles__oxisdownloadable->value;
 
 4647         if ( self::$_blHasAmountPrice === null ) {
 
 4649             self::$_blHasAmountPrice = 
false;
 
 4652             $sQ = 
"SELECT 1 FROM `oxprice2article` LIMIT 1";
 
 4654             if ( $oDb->getOne( $sQ ) ) {
 
 4655                 self::$_blHasAmountPrice = 
true;
 
 4670         $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
 
 4673             $blResult = $oUser->isPriceViewModeNetto();
 
 4689         $oPrice = 
oxNew( 
'oxPrice' );
 
 4691         if ( $blCalculationModeNetto === null ) {
 
 4695         if ( $blCalculationModeNetto ) {
 
 4696             $oPrice->setNettoPriceMode();
 
 4698             $oPrice->setBruttoPriceMode();
 
 4715             $dPrice = $oPrice->getNettoPrice();
 
 4717             $dPrice = $oPrice->getBruttoPrice();
 
 4733     protected function _preparePrice( $dPrice, $dVat, $blCalculationModeNetto = null )
 
 4735         if ( $blCalculationModeNetto === null ) {
 
 4739         $oCurrency = $this->
getConfig()->getActShopCurrencyObject();
 
 4741         $blEnterNetPrice = $this->
getConfig()->getConfigParam(
'blEnterNetPrice');
 
 4742         if ( $blCalculationModeNetto && !$blEnterNetPrice ) {
 
 4744         } elseif ( !$blCalculationModeNetto && $blEnterNetPrice ) {
 
 4760         if ($this->_fPricePerUnit == null) {
 
 4780         if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
 
 4785         if ( (
double) $this->
getUnitQuantity() && $this->oxarticles__oxunitname->value ) {
 
 4837         if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
 
 4848         $oPrice->setPrice( $dPrice );
 
 4863         if ( !$this->
getConfig()->getConfigParam( 
'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
 
 4877         $oPrice->setPrice( $dPrice );
 
 4891         if ( $this->_blIsRangePrice === null ) {
 
 4900                 if ( $dMinPrice != $dMaxPrice ) {
 
 4921         return $this->_blIsRangePrice = $blIsRangePrice;
 
 4935             if ( $oUser->inGroup( 
'oxidpricea' ) ) {
 
 4937             } elseif ( $oUser->inGroup( 
'oxidpriceb' ) ) {
 
 4939             } elseif ( $oUser->inGroup( 
'oxidpricec' ) ) {
 
 4944         return $sPriceSufix;
 
 4956             if ( $sPriceSufix === 
'') {
 
 4957                 $dPrice = $this->oxarticles__oxprice->value;
 
 4959                 if ( $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) ) {
 
 4960                     $dPrice = ($this->{oxarticles__oxprice.$sPriceSufix}->value !=0 )? $this->{oxarticles__oxprice.$sPriceSufix}->value : $this->oxarticles__oxprice->value;
 
 4962                     $dPrice = $this->{oxarticles__oxprice.$sPriceSufix}->value;
 
 4976         if ( $this->_dVarMinPrice === null) {
 
 4979             if ( $dPrice === null ) {
 
 4980                 if ( $sPriceSufix === 
'' ) {
 
 4981                     $dPrice = $this->oxarticles__oxvarminprice->value;
 
 4984                     if ( $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) ) {
 
 4985                         $sSql .=  
'MIN( IF(`oxprice'.$sPriceSufix.
'` = 0, `oxprice`, `oxprice'.$sPriceSufix.
'`) ) AS `varminprice` ';
 
 4987                         $sSql .=  
'MIN(`oxprice'.$sPriceSufix.
'`) AS `varminprice` ';
 
 4991                         WHERE ' .$this->getSqlActiveSnippet(
true) . 
' 
 4997             $this->_dVarMinPrice = $dPrice;
 
 5012         if ($this->
getConfig()->getConfigParam( 
'blMallCustomPrice' ) && $sShopId != $this->oxarticles__oxshopid->value ) {
 
 5015             if ( $sPriceSufix != 
'' && $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) ) {
 
 5016                 $sSql .=  
'MIN(IF(`oxfield2shop`.`oxprice'.$sPriceSufix.
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice'.$sPriceSufix.
'`)) AS `varminprice` ';
 
 5018                 $sSql .=  
'MIN(`oxfield2shop`.`oxprice'.$sPriceSufix.
'`) AS `varminprice` ';
 
 5020             $sSql .=  
' FROM ' . 
getViewName(
'oxfield2shop') . 
' AS oxfield2shop 
 5021                         INNER JOIN ' . $this->
getViewName(
true) . 
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid` 
 5022                         WHERE ' .$this->getSqlActiveSnippet(
true) . 
' 
 5023                             AND ( `oxarticles`.`oxparentid` = ' . 
oxDb::getDb()->quote( $this->
getId() ) . 
' ) 
 5024                             AND ( `oxfield2shop`.`oxshopid` = ' . 
oxDb::getDb()->quote( $sShopId ) . 
' )';
 
 5037         if ( $this->_dVarMaxPrice === null ) {
 
 5040             if ( $dPrice === null ) {
 
 5041                 if ( $sPriceSufix === 
'') {
 
 5042                     $dPrice = $this->oxarticles__oxvarmaxprice->value;
 
 5045                     if ( $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) ) {
 
 5046                         $sSql .=  
'MAX( IF(`oxprice'.$sPriceSufix.
'` = 0, `oxprice`, `oxprice'.$sPriceSufix.
'`) ) AS `varmaxprice` ';
 
 5048                         $sSql .=  
'MAX(`oxprice'.$sPriceSufix.
'`) AS `varmaxprice` ';
 
 5052                         WHERE ' .$this->getSqlActiveSnippet(
true) . 
' 
 5058             $this->_dVarMaxPrice = $dPrice;
 
 5073         if ($this->
getConfig()->getConfigParam( 
'blMallCustomPrice' ) && $sShopId != $this->oxarticles__oxshopid->value ) {
 
 5076             if ( $sPriceSufix != 
'' && $this->
getConfig()->getConfigParam( 
'blOverrideZeroABCPrices' ) ) {
 
 5077                 $sSql .=  
'MAX(IF(`oxfield2shop`.`oxprice'.$sPriceSufix.
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice'.$sPriceSufix.
'`)) AS `varmaxprice` ';
 
 5079                 $sSql .=  
'MAX(`oxfield2shop`.`oxprice'.$sPriceSufix.
'`) AS `varmaxprice` ';
 
 5081             $sSql .=  
' FROM ' . 
getViewName(
'oxfield2shop') . 
' AS oxfield2shop 
 5082                         INNER JOIN ' . $this->
getViewName(
true) . 
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid` 
 5083                         WHERE ' .$this->getSqlActiveSnippet(
true) . 
' 
 5084                             AND ( `oxarticles`.`oxparentid` = ' . 
oxDb::getDb()->quote( $this->
getId() ) . 
' ) 
 5085                             AND ( `oxfield2shop`.`oxshopid` = ' . 
oxDb::getDb()->quote( $sShopId ) . 
' )';
 
 5098         return $this->oxarticles__oxunitquantity->value;
 
 5108         $dSize = $this->oxarticles__oxlength->value *
 
 5109             $this->oxarticles__oxwidth->value *
 
 5110             $this->oxarticles__oxheight->value;
 
 5122         return $this->oxarticles__oxweight->value;
 
 5135             $sValue = isset( $this->$sField->value ) ? $this->$sField->value : 0;
 
 5136             $sSqlSets[] = 
'`' . str_replace( 
'oxarticles__', 
'', $sField )  . 
'` = ' . $oDb->quote( $sValue );
 
 5139         $sSql = 
"UPDATE `oxarticles` SET ";
 
 5140         $sSql .= implode(
', ', $sSqlSets) . 
'';
 
 5141         $sSql .= 
" WHERE `oxparentid` = " . $oDb->quote( $this->
getId() );
 
 5143         return $oDb->execute( $sSql );
 
 5167                 $this->$sField = 
new oxField ( $sParent->$sField->value );
 
 5182             $oVariants = 
oxNew( 
'oxsimplevariantlist' );
 
 5183             $oVariants->setParent( $this );
 
 5185             $oVariants = 
oxNew( 
'oxarticlelist' );
 
 5186             $oVariants->getBaseObject()->modifyCacheKey( 
'_variants' );
 
 5201     protected function _selectVariants( $blRemoveNotOrderables, $blForceCoreTable, $oVariants )
 
 5205         startProfile( 
"selectVariants" );
 
 5207         $blUseCoreTable = (bool) $blForceCoreTable;
 
 5208         $oBaseObject    = $oVariants->getBaseObject();
 
 5209         $oBaseObject->setLanguage( $this->
getLanguage() );
 
 5212         $sArticleTable = $this->
getViewName( $blUseCoreTable );
 
 5214         $sSelect = 
"select " . $oBaseObject->getSelectFields( $blUseCoreTable ) . 
" from $sArticleTable where " .
 
 5217                    " order by $sArticleTable.oxsort";
 
 5220         $oVariants->selectString( $sSelect );
 
 5223         if ( 
$myConfig->getConfigParam( 
'blUseMultidimensionVariants' ) ) {
 
 5224             $oMdVariants            = 
oxNew( 
"oxVariantHandler" );
 
 5225             $this->_blHasMdVariants = $oMdVariants->isMdVariant( $oVariants->current() );
 
 5228         stopProfile( 
"selectVariants" );