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);
10 define(
'OXARTICLE_LINKTYPE_RECOMM', 5);
374 'oxarticles__oxtimestamp',
377 'oxarticles__oxparentid');
385 'oxarticles__oxfreeshipping',
386 'oxarticles__oxisdownloadable',
387 'oxarticles__oxshowcustomagreement');
457 if ($aParams && is_array($aParams)) {
458 foreach ($aParams as $sParam => $mValue) {
459 $this->$sParam = $mValue;
463 $this->
init(
'oxarticles');
482 return $this->$sName;
491 public function __set($sName, $sValue)
519 $this->oxarticles__oxnid = $this->oxarticles__oxid;
538 $sQ =
" $sTable.oxactive = 1 ";
541 if ($this->
getConfig()->getConfigParam(
'blUseTimeCheck')) {
542 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
543 $sQ =
"( $sQ or ( $sTable.oxactivefrom < '$sDate' and $sTable.oxactiveto > '$sDate' ) ) ";
570 if (
$myConfig->getConfigParam(
'blUseStock')) {
571 $sQ =
" and ( $sTable.oxstockflag != 2 or ( $sTable.oxstock + $sTable.oxvarstock ) > 0 ) ";
573 if (!
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
575 if (
$myConfig->getConfigParam(
'blUseTimeCheck')) {
576 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
577 $sTimeCheckQ =
" or ( art.oxactivefrom < '$sDate' and art.oxactiveto > '$sDate' )";
579 $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 ) ) ";
600 $sQ =
" and $sTable.oxparentid = '" . $this->
getId() .
"' ";
603 if ($this->
getConfig()->getConfigParam(
'blUseStock')) {
604 $sQ .=
" and ( $sTable.oxstock > 0 or ( $sTable.oxstock <= 0 and $sTable.oxstockflag != 2 ";
605 if ($blRemoveNotOrderables) {
606 $sQ .=
" and $sTable.oxstockflag != 3 ";
621 return $this->oxarticles__oxunitquantity->value;
631 $dSize = $this->oxarticles__oxlength->value *
632 $this->oxarticles__oxwidth->value *
633 $this->oxarticles__oxheight->value;
645 return $this->oxarticles__oxweight->value;
674 $this->_blSkipAssign = $blSkipAssign;
682 $this->_blLoadPrice =
false;
690 $this->_blLoadPrice =
true;
710 $this->_sItemKey = $sItemKey;
720 $this->_blLoadVariants = !$blLoadVariants;
730 if ($this->_blNotBuyableParent) {
764 $this->_blIsOnComparisonList = $blOnList;
774 $this->_blLoadParentData = $blLoadParentData;
797 switch ($sFieldName) {
816 if ($this->_fPricePerUnit == null) {
835 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
840 if ((
double) $this->
getUnitQuantity() && $this->oxarticles__oxunitname->value) {
891 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
902 $oPrice->setPrice($dPrice);
916 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
930 $oPrice->setPrice($dPrice);
943 if ($this->_blIsRangePrice === null) {
952 if ($dMinPrice != $dMaxPrice) {
973 return $this->_blIsRangePrice = $blIsRangePrice;
986 return $blCanPreview;
990 $sNow = date(
'Y-m-d H:i:s');
991 if (!$this->oxarticles__oxactive->value &&
992 ($this->oxarticles__oxactivefrom->value > $sNow ||
993 $this->oxarticles__oxactiveto->value < $sNow
1000 if ($this->
getConfig()->getConfigParam(
'blUseStock') && $this->oxarticles__oxstockflag->value == 2) {
1001 $iOnStock = $this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value;
1002 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1003 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
1005 if ($iOnStock <= 0) {
1023 startProfile(
'articleAssign');
1028 $this->oxarticles__oxnid = $this->oxarticles__oxid;
1031 if ($this->_blSkipAssign) {
1045 stopProfile(
'articleAssign');
1062 $this->_blNotBuyableParent =
false;
1074 $this->_isLoaded =
true;
1090 $aSortingFields = !empty($aSortingFields) ? (array) $aSortingFields : array();
1092 foreach ($aSortingFields as $sField) {
1093 $sParameterName =
'oxarticles__' . $sField;
1094 if ($this->$sParameterName->value !== $this->_aSortingFieldsOnLoad[$sParameterName]) {
1111 $dOldRating = $this->oxarticles__oxrating->value;
1112 $dOldCnt = $this->oxarticles__oxratingcnt->value;
1113 $this->oxarticles__oxrating->setValue(($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1));
1114 $this->oxarticles__oxratingcnt->setValue($dOldCnt + 1);
1115 $dRating = ($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1);
1116 $dRatingCnt = (int) ($dOldCnt + 1);
1119 $oDb->execute(
'update oxarticles set oxarticles.oxrating = ' . $dRating .
',oxarticles.oxratingcnt = ' . $dRatingCnt .
', oxarticles.oxtimestamp = oxarticles.oxtimestamp where oxarticles.oxid = ' . $oDb->quote($this->getId()));
1130 $this->oxarticles__oxrating =
new oxField($iRating);
1140 $this->oxarticles__oxratingcnt =
new oxField($iRatingCnt);
1152 if (!$blIncludeVariants) {
1153 return round($this->oxarticles__oxrating->value, 1);
1155 $oRating =
oxNew(
'oxRating');
1170 if (!$blIncludeVariants) {
1171 return $this->oxarticles__oxratingcnt->value;
1173 $oRating =
oxNew(
'oxRating');
1187 $aIds = array($this->
getId());
1189 if ($this->oxarticles__oxparentid->value) {
1190 $aIds[] = $this->oxarticles__oxparentid->value;
1194 if ($this->
getConfig()->getConfigParam(
'blShowVariantReviews')) {
1196 if (is_array($aAdd)) {
1197 $aIds = array_merge($aIds, $aAdd);
1201 $oReview =
oxNew(
'oxreview');
1202 $oRevs = $oReview->loadList(
'oxarticle', $aIds);
1205 if ($oRevs->count() < 1) {
1219 $oCrosslist =
oxNew(
"oxarticlelist");
1220 $oCrosslist->loadArticleCrossSell($this->oxarticles__oxid->value);
1221 if ($oCrosslist->count()) {
1236 if (!
$myConfig->getConfigParam(
'bl_perfLoadAccessoires')) {
1240 $oAcclist =
oxNew(
"oxarticlelist");
1241 $oAcclist->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofCrossellArticles'));
1242 $oAcclist->loadArticleAccessoires($this->oxarticles__oxid->value);
1244 if ($oAcclist->count()) {
1258 if (!
$myConfig->getConfigParam(
'bl_perfLoadSimilar')) {
1263 if(
$myConfig->getConfigParam(
'iNrofSimilarArticles') < 1) {
1279 if (count($aList)) {
1280 uasort($aList,
'cmpart');
1284 $oSimilarlist =
oxNew(
'oxarticlelist');
1285 $oSimilarlist->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofSimilarArticles'));
1286 $oSimilarlist->selectString($sSearch);
1288 return $oSimilarlist;
1301 if (!
$myConfig->getConfigParam(
'bl_perfLoadCustomerWhoBoughtThis')) {
1308 $oArticles =
oxNew(
'oxarticlelist');
1309 $oArticles->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofCustomerWhoArticles'));
1310 $oArticles->selectString($sQ);
1311 if ($oArticles->count()) {
1325 if (!
$myConfig->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice || !$this->_blCalcPrice || !$this->
hasAmountPrice()) {
1329 if ($this->_oAmountPriceInfo === null) {
1330 $this->_oAmountPriceInfo = array();
1350 $sKey = $this->
getId();
1351 if (isset($sKeyPrefix)) {
1352 $sKey = $sKeyPrefix .
'__' . $sKey;
1355 if (!isset(self::$_aSelList[$sKey])) {
1359 $sQ =
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid
1360 where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
1363 $oLists =
oxNew(
'oxlist');
1364 $oLists->init(
'oxselectlist');
1365 $oLists->selectString(sprintf($sQ, $oDb->quote($this->getId())));
1368 if ($oLists->count() == 0 && $this->oxarticles__oxparentid->value) {
1369 $oLists->selectString(sprintf($sQ, $oDb->quote($this->oxarticles__oxparentid->value)));
1379 self::$_aSelList[$sKey] = array();
1380 foreach ($oLists as $oSelectlist) {
1381 self::$_aSelList[$sKey][$iCnt] = $oSelectlist->getFieldList($dVat);
1382 self::$_aSelList[$sKey][$iCnt][
'name'] = $oSelectlist->oxselectlist__oxtitle->value;
1387 return self::$_aSelList[$sKey];
1397 return $this->oxarticles__oxvarcount->value;
1417 return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxnonmaterial->value && !$this->
hasDownloadableAgreement();
1427 return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxisdownloadable->value;
1441 $iLimit = (int) $iLimit;
1442 if (!isset($this->_aVariantSelections[$iLimit])) {
1443 $aVariantSelections =
false;
1444 if ($this->oxarticles__oxvarcount->value) {
1446 $aVariantSelections =
oxNew(
"oxVariantHandler")->buildVariantSelections($this->oxarticles__oxvarname->getRawValue(), $oVariants, $aFilterIds, $sActVariantId, $iLimit);
1448 if (!empty($oVariants) && empty($aVariantSelections[
'rawselections'])) {
1449 $aVariantSelections =
false;
1452 $this->_aVariantSelections[$iLimit] = $aVariantSelections;
1455 return $this->_aVariantSelections[$iLimit];
1468 $sId = $this->
getId() . ((int) $iLimit);
1469 if (!array_key_exists($sId, self::$_aSelections)) {
1474 $sQ =
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid
1475 where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
1477 if (($iLimit = (
int) $iLimit)) {
1478 $sQ .=
" limit $iLimit ";
1483 if (($oPrice = $this->
getPrice()) != null) {
1484 $dVat = $oPrice->getVat();
1488 $oList =
oxNew(
'oxlist');
1489 $oList->init(
'oxselectlist');
1490 $oList->getBaseObject()->setVat($dVat);
1491 $oList->selectString(sprintf($sQ, $oDb->quote($this->getId())));
1494 if ($oList->count() == 0 && $this->oxarticles__oxparentid->value) {
1495 $oList->selectString(sprintf($sQ, $oDb->quote($this->oxarticles__oxparentid->value)));
1498 self::$_aSelections[$sId] = $oList->count() ? $oList :
false;
1501 if (self::$_aSelections[$sId]) {
1506 foreach (self::$_aSelections[$sId] as $oSelection) {
1507 if (isset($aFilter[$iSelIdx])) {
1508 $oSelection->setActiveSelectionByIndex($aFilter[$iSelIdx]);
1515 return self::$_aSelections[$sId];
1528 return $this->
_loadVariantList(
false, $blRemoveNotOrderables, $blForceCoreTable);
1540 public function getVariants($blRemoveNotOrderables =
true, $blForceCoreTable = null)
1552 if ($this->oxarticles__oxvarcount->value) {
1567 $oVariants =
oxNew(
'oxarticlelist');
1568 if (($sId = $this->
getId())) {
1570 $oBaseObj = $oVariants->getBaseObject();
1572 if (is_null($sLanguage)) {
1575 $oBaseObj->setLanguage($sLanguage);
1578 $sSql =
"select * from " . $oBaseObj->getViewName() .
" where oxparentid = '{$sId}' order by oxsort ";
1579 $oVariants->selectString($sSql);
1582 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') && ($oVariants->count() > 0)) {
1584 $this->_blNotBuyableParent =
true;
1600 $oCategory =
oxNew(
'oxcategory');
1604 $sOXID = $this->
getId();
1605 if (isset($this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
1606 $sOXID = $this->oxarticles__oxparentid->value;
1611 if (!isset($this->_aCategoryCache[$sOXID])) {
1612 startPRofile(
'getCategory');
1614 $sWhere = $oCategory->getSqlActiveSnippet();
1616 $sSelect .= ($oStr->strstr($sSelect,
'where') ?
' and ' :
' where ') . $sWhere .
" order by oxobject2category.oxtime limit 1";
1619 if (!$oCategory->assignRecord($sSelect)) {
1622 $sSelect .= ($oStr->strstr($sSelect,
'where') ?
' and ' :
' where ') . $sWhere .
" limit 1";
1625 if (!$oCategory->assignRecord($sSelect)) {
1630 $this->_aCategoryCache[$sOXID] = $oCategory;
1631 stopPRofile(
'getCategory');
1634 $oCategory = $this->_aCategoryCache[$sOXID];
1651 $sArticleId = $this->
getId();
1653 if (!isset(self::$_aArticleCats[$sArticleId]) || $blSkipCache) {
1661 self::$_aArticleCats[$sArticleId] = array_unique(array_merge($aCategoryIds, $aPriceCategoryIds));
1664 return self::$_aArticleCats[$sArticleId];
1679 $oVendor =
oxNew(
'oxvendor');
1680 } elseif (!$blShopCheck && $this->oxarticles__oxvendorid->value) {
1681 $oVendor =
oxNew(
'oxi18n');
1682 $oVendor->init(
'oxvendor');
1683 $oVendor->setReadOnly(
true);
1684 $sVendorId = $this->oxarticles__oxvendorid->value;
1686 if ($sVendorId && $oVendor->load($sVendorId) && $oVendor->oxvendor__oxactive->value) {
1704 if ($this->oxarticles__oxvendorid->value) {
1705 $sVendorId = $this->oxarticles__oxvendorid->value;
1721 $sManufacturerId =
false;
1722 if ($this->oxarticles__oxmanufacturerid->value) {
1724 $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
1728 return $sManufacturerId;
1742 $oManufacturer =
oxNew(
'oxmanufacturer');
1744 !$blShopCheck && $this->oxarticles__oxmanufacturerid->value
1746 $oManufacturer->setReadOnly(
true);
1747 $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
1750 if ($sManufacturerId && $oManufacturer->load($sManufacturerId)) {
1751 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadManufacturerTree')) {
1752 $oManufacturer->setReadOnly(
true);
1754 $oManufacturer = $oManufacturer->oxmanufacturers__oxactive->value ? $oManufacturer : null;
1756 $oManufacturer = null;
1759 return $oManufacturer;
1785 $sOXID = $this->
getId();
1786 if (isset($this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
1787 $sOXID = $this->oxarticles__oxparentid->value;
1792 $sOXID = $oDb->getOne($sSelect);
1794 if (isset($sOXID) && $sOXID) {
1799 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') && $this->_blLoadPrice) {
1800 $dPriceFromTo = $this->
getPrice()->getBruttoPrice();
1801 if ($dPriceFromTo > 0) {
1803 $sOXID = $oDb->getOne($sSelect);
1805 if (isset($sOXID) && $sOXID) {
1821 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
1826 if ($this->_oTPrice !== null) {
1832 $dBasePrice = $this->oxarticles__oxtprice->value;
1835 $oPrice->setPrice($dBasePrice);
1848 if ($oPrice->getPrice() <= $oPrice2->getPrice()) {
1853 $this->_oTPrice = $oPrice;
1866 if ($this->_blSkipDiscounts !== null) {
1870 if ($this->oxarticles__oxskipdiscounts->value) {
1875 $this->_blSkipDiscounts =
false;
1881 $sSelect =
"select 1 from $sO2CView as $sO2CView left join {$sViewName} on {$sViewName}.oxid = $sO2CView.oxcatnid
1882 where $sO2CView.oxobjectid=" . $oDb->quote($this->
getId()) .
" and {$sViewName}.oxactive = 1 and {$sViewName}.oxskipdiscounts = '1' ";
1883 $this->_blSkipDiscounts = ($oDb->getOne($sSelect) == 1);
1896 $this->_oPrice = $oPrice;
1941 if ($dAmount != 1 || $this->_oPrice === null) {
1949 $oPrice->setPrice($dBasePrice);
1952 if (!$this->_blCalcPrice && $dAmount == 1) {
1953 return $this->_oPrice = $oPrice;
1957 if ($dAmount != 1) {
1961 $this->_oPrice = $oPrice;
1974 $this->_oUser = $oUser;
1984 if ($this->_oUser) {
2002 $oUser = $oBasket->getBasketUser();
2005 $oBasketPrice = $this->
_getPriceObject($oBasket->isCalculationModeNetto());
2016 $oBasketPrice->setPrice($dBasePrice);
2018 $dVat =
oxRegistry::get(
"oxVatSelector")->getBasketItemVat($this, $oBasket);
2022 return $oBasketPrice;
2033 public function delete($sOXID = null)
2036 $sOXID = $this->
getId();
2046 $this->
load($sOXID);
2048 $this->
_onChangeResetCounts($sOXID, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value);
2057 $this->
onChange(ACTION_DELETE, $sOXID, $this->oxarticles__oxparentid->value);
2074 $iStockCount = $this->oxarticles__oxstock->value - $dAmount;
2075 if (!$blAllowNegativeStock && ($iStockCount < 0)) {
2076 $dAmount += $iStockCount;
2079 $this->oxarticles__oxstock =
new oxField($iStockCount);
2082 $oDb->execute(
'update oxarticles set oxarticles.oxstock = ' . $oDb->quote($iStockCount) .
' where oxarticles.oxid = ' . $oDb->quote($this->
getId()));
2083 $this->
onChange(ACTION_UPDATE_STOCK);
2103 if (!$this->oxarticles__oxparentid->value) {
2105 $dAmount = (double) $dAmount;
2107 $rs = $oDb->execute(
"update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + $dAmount where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2108 } elseif ($this->oxarticles__oxparentid->value) {
2111 if ($oUpdateArticle) {
2112 $oUpdateArticle->updateSoldAmount($dAmount);
2128 return $oDb->execute(
"update oxarticles set oxarticles.oxremindactive = 2 where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2140 if (($blRet = parent::save())) {
2153 $sParentId = $this->oxarticles__oxparentid->value;
2155 $this->_blAllowEmptyParentId =
true;
2157 $this->_blAllowEmptyParentId =
false;
2159 if ($sParentId !==
'') {
2160 $this->
onChange(ACTION_UPDATE, null, $sParentId);
2177 $aArtPics = array();
2178 $aArtIcons = array();
2188 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
2189 $blCheckActivePicId =
true;
2191 for ($i = 1; $i <= $iPicCount; $i++) {
2194 if (!$oStr->strstr($sIcoVal,
'nopic_ico.jpg') && !$oStr->strstr($sIcoVal,
'nopic.jpg') &&
2195 !$oStr->strstr($sPicVal,
'nopic_ico.jpg') && !$oStr->strstr($sPicVal,
'nopic.jpg') &&
2201 $aArtIcons[$i] = $sIcoVal;
2202 $aArtPics[$i] = $sPicVal;
2205 if ($iActPicId == $i) {
2206 $sActPic = $sPicVal;
2207 $blCheckActivePicId =
false;
2210 } elseif ($blCheckActivePicId && $iActPicId <= $i) {
2218 $aZoomPics = array();
2219 $iZoomPicCount =
$myConfig->getConfigParam(
'iPicCount');
2221 for ($j = 1, $c = 1; $j <= $iZoomPicCount; $j++) {
2224 if ($sVal && !$oStr->strstr($sVal,
'nopic.jpg')) {
2226 $aZoomPics[$c][
'id'] = $c;
2227 $aZoomPics[$c][
'file'] = $sVal;
2230 $aZoomPics[$c][
'file'] =
"nopic.jpg";
2236 $aPicGallery = array(
'ActPicID' => $iActPicId,
2237 'ActPic' => $sActPic,
2238 'MorePics' => $blMorePic,
2239 'Pics' => $aArtPics,
2240 'Icons' => $aArtIcons,
2241 'ZoomPic' => $blZoomPic,
2242 'ZoomPics' => $aZoomPics);
2244 return $aPicGallery;
2260 public function onChange($sAction = null, $sOXID = null, $sParentID = null)
2264 if (!isset($sOXID)) {
2265 if ($this->
getId()) {
2266 $sOXID = $this->
getId();
2268 if (!isset ($sOXID)) {
2269 $sOXID = $this->oxarticles__oxid->value;
2271 if ($this->oxarticles__oxparentid->value) {
2272 $sParentID = $this->oxarticles__oxparentid->value;
2275 if (!isset($sOXID)) {
2280 if (
$myConfig->getConfigParam(
'blUseStock')) {
2283 if (!isset($sParentID)) {
2285 $sQ =
'select oxparentid from oxarticles where oxid = ' . $oDb->quote($sOXID);
2286 $sParentID = $oDb->getOne($sQ);
2299 $sId = ($sParentID) ? $sParentID : $sOXID;
2306 if ($sAction === ACTION_UPDATE_STOCK) {
2321 if (isset($this->oxarticles__oxvat->value)) {
2322 return $this->oxarticles__oxvat->value;
2337 if (!
$myConfig->getConfigParam(
'blUseStock')) {
2343 $sQ =
'select oxstock, oxstockflag from oxarticles where oxid = ' . $oDb->quote($this->
getId());
2344 $rs = $oDb->select($sQ);
2348 if ($rs !==
false && $rs->recordCount() > 0) {
2349 $iOnStock = $rs->fields[
'oxstock'] - $dArtStockAmount;
2350 $iStockFlag = $rs->fields[
'oxstockflag'];
2353 if ($iStockFlag == 1 || $iStockFlag == 4) {
2356 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts')) {
2357 $iOnStock = floor($iOnStock);
2360 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
2361 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
2363 if ($iOnStock >= $dAmount) {
2366 if ($iOnStock > 0) {
2369 $oEx =
oxNew(
'oxArticleInputException');
2370 $oEx->setMessage(
'ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE');
2386 if ($this->_oLongDesc === null) {
2388 $this->_oLongDesc =
new oxField();
2392 $sOxid = $this->
getId();
2396 $sDbValue = $oDb->getOne(
"select oxlongdesc from {$sViewName} where oxid = " . $oDb->quote($sOxid));
2398 if ($sDbValue !=
false) {
2400 } elseif ($this->oxarticles__oxparentid->value) {
2401 if (!$this->
isAdmin() || $this->_blLoadParentData) {
2404 $this->_oLongDesc->setValue($oParent->getLongDescription()->getRawValue(),
oxField::T_RAW);
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());
2479 if ($iLang === null) {
2483 $this->_aSeoAddParams[$iLang] = isset($this->_aSeoAddParams[$iLang]) ? $this->_aSeoAddParams[$iLang] .
"&" :
"";
2484 $this->_aSeoAddParams[$iLang] .= $sAddParams;
2501 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);
2559 $this->_sDetailLink = null;
2562 $this->_iLinkType = (int) $iType;
2584 if ($iLang === null) {
2588 $this->_aStdAddParams[$iLang] = isset($this->_aStdAddParams[$iLang]) ? $this->_aStdAddParams[$iLang] .
"&" :
"";
2589 $this->_aStdAddParams[$iLang] .= $sAddParams;
2607 $sUrl = $this->
getConfig()->getShopUrl($iLang,
false);
2610 $sUrl .=
"index.php?cl=details" . ($blAddId ?
"&anid=" . $this->
getId() :
"");
2612 return $sUrl . (isset($this->_aStdAddParams[$iLang]) ?
"&" . $this->_aStdAddParams[$iLang] :
"");
2625 if ($iLang === null) {
2629 if (!isset($this->_aStdUrls[$iLang])) {
2633 return oxRegistry::get(
"oxUtilsUrl")->processUrl($this->_aStdUrls[$iLang],
true, $aParams, $iLang);
2643 if ($this->_aMediaUrls === null) {
2644 $this->_aMediaUrls =
oxNew(
"oxlist");
2645 $this->_aMediaUrls->init(
"oxmediaurl");
2646 $this->_aMediaUrls->getBaseObject()->setLanguage($this->
getLanguage());
2649 $sQ =
"select * from {$sViewName} where oxobjectid = '" . $this->
getId() .
"'";
2650 $this->_aMediaUrls->selectString($sQ);
2673 if ($this->_aDispSelList === null) {
2674 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists') && $this->
getConfig()->getConfigParam(
'bl_perfLoadSelectListsInAList')) {
2689 if ($this->_sMoreDetailLink == null) {
2692 $this->_sMoreDetailLink = $this->
getConfig()->getShopHomeURL() .
'cl=moredetails';
2696 $this->_sMoreDetailLink .=
'&cnid=' . $sActCat;
2698 $this->_sMoreDetailLink .=
'&anid=' . $this->
getId();
2712 if ($this->_sToBasketLink == null) {
2716 $this->_sToBasketLink = $this->
getLink();
2719 $this->_sToBasketLink =
$myConfig->getShopHomeURL();
2723 if ($sActClass ==
'thankyou') {
2724 $sActClass =
'basket';
2726 $this->_sToBasketLink .=
'cl=' . $sActClass;
2730 $this->_sToBasketLink .=
'&cnid=' . $sActCat;
2733 $this->_sToBasketLink .=
'&fnc=tobasket&aid=' . $this->
getId() .
'&anid=' . $this->
getId();
2736 $this->_sToBasketLink .=
'&tpl=' . $sTpl;
2761 if ($this->oxarticles__oxdelivery->value !=
'0000-00-00') {
2762 return oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxarticles__oxdelivery->value);
2807 if ($this->oxarticles__oxremindactive->value == 2 &&
2808 $this->oxarticles__oxremindamount->value <= $this->oxarticles__oxstock->value
2810 $this->oxarticles__oxremindactive->value = 1;
2855 $this->_blNotBuyable = !$blBuyable;
2865 $this->_aDispSelList = $aSelList;
2880 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2883 $sSize = $this->
getConfig()->getConfigParam(
'aDetailImageSizes');
2885 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2900 $sDirname =
"product/1/";
2901 if ($iIndex && !$this->
_isFieldEmpty(
"oxarticles__oxpic{$iIndex}")) {
2902 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2903 $sDirname =
"product/{$iIndex}/";
2905 $sImgName = basename($this->oxarticles__oxicon->value);
2906 $sDirname =
"product/icon/";
2908 $sImgName = basename($this->oxarticles__oxpic1->value);
2911 $sSize = $this->
getConfig()->getConfigParam(
'sIconsize');
2913 $sIconUrl =
oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, $iIndex);
2928 $sDirname =
"product/1/";
2930 $sImgName = basename($this->oxarticles__oxthumb->value);
2931 $sDirname =
"product/thumb/";
2933 $sImgName = basename($this->oxarticles__oxpic1->value);
2936 $sSize = $this->
getConfig()->getConfigParam(
'sThumbnailsize');
2938 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, 0, $bSsl);
2950 $iIndex = (int) $iIndex;
2951 if ($iIndex > 0 && !$this->
_isFieldEmpty(
"oxarticles__oxpic" . $iIndex)) {
2952 $sImgName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
2953 $sSize = $this->
getConfig()->getConfigParam(
"sZoomImageSize");
2955 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2979 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
2982 foreach ($aDiscounts as $oDiscount) {
2983 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
2985 $oPrice->calculateDiscount();
2996 if (($sParentId = $this->oxarticles__oxparentid->value)) {
2997 $sIndex = $sParentId .
"_" . $this->
getLanguage();
2998 if (!isset(self::$_aLoadedParents[$sIndex])) {
2999 self::$_aLoadedParents[$sIndex] =
oxNew(
'oxarticle');
3000 self::$_aLoadedParents[$sIndex]->_blLoadPrice =
false;
3001 self::$_aLoadedParents[$sIndex]->_blLoadVariants =
false;
3005 self::$_aLoadedParents[$sIndex] =
false;
3009 return self::$_aLoadedParents[$sIndex];
3021 $sOxId = $oDb->quote($this->
getId());
3022 $sOxShopId = $oDb->quote($this->
getShopId());
3023 $iRemindActive = $oDb->quote($this->oxarticles__oxremindactive->value);
3026 set oxremindactive = $iRemindActive
3027 where oxparentid = $sOxId and
3028 oxshopid = $sOxShopId
3030 $oDb->execute($sUpdate);
3042 return $this->
getId();
3052 return $this->oxarticles__oxparentid->value;
3072 return (
bool) (isset($this->oxarticles__oxparentid) ? $this->oxarticles__oxparentid->value :
false);
3082 $oMdVariant =
oxNew(
"oxVariantHandler");
3084 return $oMdVariant->isMdVariant($this);
3099 $sSelectWhere =
"select $sFields from " . $this->
_getObjectViewName(
'oxcategories') .
" where";
3100 $sQuotedPrice =
oxDb::getDb()->quote($this->oxarticles__oxprice->value);
3102 return "$sSelectWhere oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice"
3103 .
" union $sSelectWhere oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice"
3104 .
" union $sSelectWhere oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice";
3118 $sQuotedPrice = $oDb->quote($this->oxarticles__oxprice->value);
3119 $sQuotedCnid = $oDb->quote($sCatNid);
3121 return (
bool) $oDb->getOne(
3122 "select 1 from " . $this->
_getObjectViewName(
'oxcategories') .
" where oxid=$sQuotedCnid and"
3123 .
"( (oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice)"
3124 .
" or (oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice)"
3125 .
" or (oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice)"
3137 if ($this->_oMdVariants) {
3142 if ($oParentArticle) {
3143 $oVariants = $oParentArticle->getVariants();
3148 $oVariantHandler =
oxNew(
"oxVariantHandler");
3149 $this->_oMdVariants = $oVariantHandler->buildMdVariants($oVariants, $this->
getId());
3175 $sFieldName =
"oxarticles__" . $sFieldName . $iIndex;
3177 return $this->$sFieldName->value;
3191 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
3193 if ($sPicName && $sPicName !=
"nopic.jpg") {
3194 $sPicUrl = $this->
getConfig()->getPictureUrl(
"master/product/" . $iIndex .
"/" . $sPicName);
3195 if (!$sPicUrl || basename($sPicUrl) ==
"nopic.jpg") {
3210 if ($this->oxarticles__oxunitname->value) {
3224 if ($this->_aArticleFiles === null) {
3226 $this->_aArticleFiles =
false;
3228 $sQ =
"SELECT * FROM `oxfiles` WHERE `oxartid` = '" . $this->
getId() .
"'";
3230 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') && $blAddFromParent) {
3231 $sQ .=
" OR `oxartId` = '" . $this->oxarticles__oxparentid->value .
"'";
3234 $oArticleFiles =
oxNew(
"oxlist");
3235 $oArticleFiles->init(
"oxfile");
3236 $oArticleFiles->selectString($sQ);
3237 $this->_aArticleFiles = $oArticleFiles;
3251 return $this->oxarticles__oxisdownloadable->value;
3261 if (self::$_blHasAmountPrice === null) {
3263 self::$_blHasAmountPrice =
false;
3266 $sQ =
"SELECT 1 FROM `oxprice2article` LIMIT 1";
3268 if ($oDb->getOne($sQ)) {
3269 self::$_blHasAmountPrice =
true;
3285 protected function _loadVariantList($blSimple, $blRemoveNotOrderables =
true, $blForceCoreTable = null)
3287 $oVariants = array();
3288 if (($sId = $this->
getId())) {
3290 self::$_aLoadedParents[$sId .
"_" . $this->
getLanguage()] = $this;
3294 if (!$this->_blLoadVariants ||
3296 (!$this->
isAdmin() && !$this->oxarticles__oxvarcount->value)
3302 $sCacheKey = $blSimple ?
"simple" :
"full";
3303 if ($blRemoveNotOrderables) {
3304 if (isset($this->_aVariants[$sCacheKey])) {
3305 return $this->_aVariants[$sCacheKey];
3307 $this->_aVariants[$sCacheKey] = & $oVariants;
3309 } elseif (!$blRemoveNotOrderables) {
3310 if (isset($this->_aVariantsWithNotOrderables[$sCacheKey])) {
3311 return $this->_aVariantsWithNotOrderables[$sCacheKey];
3313 $this->_aVariantsWithNotOrderables[$sCacheKey] = & $oVariants;
3317 if (($this->_blHasVariants = $this->
_hasAnyVariant($blForceCoreTable))) {
3321 $oVariants =
oxNew(
'oxsimplevariantlist');
3322 $oVariants->setParent($this);
3325 $oVariants =
oxNew(
'oxarticlelist');
3326 $oVariants->getBaseObject()->modifyCacheKey(
'_variants');
3329 startProfile(
"selectVariants");
3330 $blUseCoreTable = (bool) $blForceCoreTable;
3331 $oBaseObject = $oVariants->getBaseObject();
3335 $sArticleTable = $this->
getViewName($blUseCoreTable);
3337 $sSelect =
"select " . $oBaseObject->getSelectFields($blUseCoreTable) .
" from $sArticleTable where " .
3340 " order by $sArticleTable.oxsort";
3341 $oVariants->selectString($sSelect);
3344 if (
$myConfig->getConfigParam(
'blUseMultidimensionVariants')) {
3345 $oMdVariants =
oxNew(
"oxVariantHandler");
3346 $this->_blHasMdVariants = $oMdVariants->isMdVariant($oVariants->current());
3348 stopProfile(
"selectVariants");
3353 $this->_blNotBuyableParent =
true;
3358 $this->_blNotBuyable =
true;
3376 $aResult = $oDb->getAll($sSql);
3380 foreach ($aResult as $aValue) {
3381 $aValue = array_change_key_case($aValue, CASE_LOWER);
3384 $aReturn[] = $aValue[$sField];
3402 $sArticleIdSql =
'oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getId());
3404 $sArticleIdSql =
'(' . $sArticleIdSql .
' or oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getParentId()) .
')';
3409 oxobject2category.oxcatnid as oxcatnid
3410 from $sO2CView as oxobject2category
3411 left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid
3412 where $sArticleIdSql and oxcategories.oxid is not null and oxcategories.oxactive = 1 $sActiveCategorySql
3413 order by oxobject2category.oxtime";
3426 $sActiveCategorySql =
"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 ";
3428 return $sActiveCategorySql;
3445 $sSelect =
"select oxobject2category.oxcatnid as oxcatnid from $sO2CView as oxobject2category left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
3446 $sSelect .=
'where oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($sOXID) .
' and oxcategories.oxid is not null and oxcategories.oxactive = 1 ';
3448 $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 ";
3450 $sSelect .=
'order by oxobject2category.oxtime ';
3466 if (isset($dVat) || !$this->
getConfig()->getConfigParam(
'bl_perfCalcVatOnlyForBasketOrder')) {
3475 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
3478 foreach ($aDiscounts as $oDiscount) {
3479 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
3481 $oPrice->calculateDiscount();
3497 if (($sId = $this->
getId())) {
3498 if ($this->oxarticles__oxshopid->value == $this->getConfig()->getShopId()) {
3499 $blHas = (bool) $this->oxarticles__oxvarcount->value;
3501 $sArticleTable = $this->
getViewName($blForceCoreTable);
3502 $blHas = (bool)
oxDb::getDb()->getOne(
"select 1 from $sArticleTable where oxparentid='{$sId}'");
3526 return $this->
_isStockStatusChanged() && ($this->_iStockStatus == -1 || $this->_iStockStatusOnLoad == -1);
3538 if (in_array(
"oxlongdesc", $this->_aSkipSaveFields)) {
3542 if ($this->_blEmployMultilanguage) {
3544 if ($sValue !== null) {
3545 $oArtExt =
oxNew(
'oxI18n');
3546 $oArtExt->init(
'oxartextends');
3547 $oArtExt->setLanguage((
int) $this->
getLanguage());
3548 if (!$oArtExt->load($this->getId())) {
3549 $oArtExt->setId($this->
getId());
3555 $oArtExt =
oxNew(
'oxI18n');
3556 $oArtExt->setEnableMultilang(
false);
3557 $oArtExt->init(
'oxartextends');
3558 $aObjFields = $oArtExt->_getAllFields(
true);
3559 if (!$oArtExt->load($this->getId())) {
3560 $oArtExt->setId($this->
getId());
3563 foreach ($aObjFields as $sKey => $sValue) {
3564 if (preg_match(
'/^oxlongdesc(_(\d{1,2}))?$/', $sKey)) {
3567 if (isset($this->$sField)) {
3569 if ($this->$sField instanceof
oxField) {
3570 $sLongDesc = $this->$sField->getRawValue();
3571 } elseif (is_object($this->$sField)) {
3572 $sLongDesc = $this->$sField->value;
3574 if (isset($sLongDesc)) {
3575 $sAEField = $oArtExt->_getFieldLongName($sKey);
3592 $this->_aSkipSaveFields = array();
3594 $this->_aSkipSaveFields[] =
'oxtimestamp';
3596 $this->_aSkipSaveFields[] =
'oxinsert';
3599 if (!$this->_blAllowEmptyParentId && (!isset($this->oxarticles__oxparentid->value) || $this->oxarticles__oxparentid->value ==
'')) {
3600 $this->_aSkipSaveFields[] =
'oxparentid';
3616 foreach ($aItemDiscounts as $sKey => $oDiscount) {
3618 if (array_key_exists($sKey, $aDiscounts)) {
3619 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
3621 $aDiscounts[$sKey] = $oDiscount;
3636 $sVarName =
"oxarticles__oxprice{$sPriceSufix}";
3637 $dPrice = $this->$sVarName->value;
3640 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices') && (
double) $dPrice == 0) {
3641 $dPrice = $this->oxarticles__oxprice->value;
3657 startProfile(
"_getAmountPrice");
3661 foreach ($oAmtPrices as $oAmPrice) {
3662 if ($oAmPrice->oxprice2article__oxamount->value <= $dAmount
3663 && $dAmount <= $oAmPrice->oxprice2article__oxamountto->value
3664 && $dPrice > $oAmPrice->oxprice2article__oxaddabs->value
3666 $dPrice = $oAmPrice->oxprice2article__oxaddabs->value;
3670 stopProfile(
"_getAmountPrice");
3687 if (
$myConfig->getConfigParam(
'bl_perfLoadSelectLists') &&
$myConfig->getConfigParam(
'bl_perfUseSelectlistPrice')) {
3691 foreach ($aSelLists as $key => $aSel) {
3692 if (isset($aChosenList[$key]) && isset($aSel[$aChosenList[$key]])) {
3693 $oSel = $aSel[$aChosenList[$key]];
3694 if ($oSel->priceUnit ==
'abs') {
3695 $dPrice += $oSel->price;
3696 } elseif ($oSel->priceUnit ==
'%') {
3718 foreach ($aAmPriceList as $sId => $oItem) {
3721 if ($oItem->oxprice2article__oxaddabs->value) {
3723 $dBasePrice = $oItem->oxprice2article__oxaddabs->value;
3726 $oItemPrice->setPrice($dBasePrice);
3732 $oItemPrice->setPrice($dBasePrice);
3733 $oItemPrice->subtractPercent($oItem->oxprice2article__oxaddperc->value);
3737 $aAmPriceList[$sId]->fbrutprice = $oLang->formatCurrency($this->
_getPriceForView($oItemPrice));
3740 return $aAmPriceList;
3753 $sId = $this->
getId();
3755 $sActiveSqlSnippet =
"";
3756 if ($blActiveVariants) {
3760 $sQ =
"select oxid from " . $this->
getViewName(
true) .
" where oxparentid = " . $oDb->quote($sId) .
3761 $sActiveSqlSnippet .
" order by oxsort";
3762 $oRs = $oDb->select($sQ);
3763 if ($oRs !=
false && $oRs->recordCount() > 0) {
3764 while (!$oRs->EOF) {
3765 $aSelect[] = reset($oRs->fields);
3795 if (!isset($this->_dArticleVat)) {
3796 $this->_dArticleVat =
oxRegistry::get(
"oxVatSelector")->getArticleVat($this);
3810 startProfile(__FUNCTION__);
3811 $oPrice->setVAT($dVat);
3814 if (($dVat = $oVatSelector->getArticleUserVat($this)) !==
false) {
3817 stopProfile(__FUNCTION__);
3829 $oCur = $this->
getConfig()->getActShopCurrencyObject();
3846 $sSelect =
'select oxattrid from oxobject2attribute where oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getId());
3848 $sSelect .=
' OR oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getParentId());
3850 $sAttributeSql =
'';
3851 $aAttributeIds = $oDb->getCol($sSelect);
3852 if (is_array($aAttributeIds) && count($aAttributeIds)) {
3853 $aAttributeIds = array_unique($aAttributeIds);
3854 $iCnt = count($aAttributeIds);
3855 $sAttributeSql .=
't1.oxattrid IN ( ' . implode(
',', $oDb->quoteArray($aAttributeIds)) .
') ';
3870 $iAttrPercent = $this->
getConfig()->getConfigParam(
'iAttributesPercent') / 100;
3872 if (!$iAttrPercent || $iAttrPercent < 0 || $iAttrPercent > 1) {
3873 $iAttrPercent = 0.70;
3876 $iHitMin = ceil($iCnt * $iAttrPercent);
3878 $aExcludeIds = array();
3879 $aExcludeIds[] = $this->
getId();
3885 $sSelect =
"select oxobjectid from oxobject2attribute as t1 where
3887 and t1.oxobjectid NOT IN (" . implode(
', ',
oxDb::getDb()->quoteArray($aExcludeIds)) .
")
3888 group by t1.oxobjectid having count(*) >= $iHitMin LIMIT 0, 20";
3904 $aList = array_slice($aList, 0, $this->
getConfig()->getConfigParam(
'iNrofSimilarArticles'));
3906 $sSearch =
"select $sFieldList from $sArticleTable where " . $this->
getSqlActiveSnippet() .
" and $sArticleTable.oxissearch = 1 and $sArticleTable.oxid in ( ";
3908 $sSearch .= implode(
',',
oxdb::getDb()->quoteArray($aList)) .
')';
3911 $sSearch .=
' order by rand() ';
3931 if (!$blSearchPriceCat) {
3932 $sSelect =
"select {$sCatView}.* from {$sO2CView} as oxobject2category left join {$sCatView} on
3933 {$sCatView}.oxid = oxobject2category.oxcatnid
3934 where oxobject2category.oxobjectid=" .
oxDb::getDb()->quote($sOXID) .
" and {$sCatView}.oxid is not null ";
3936 $sSelect =
"select {$sCatView}.* from {$sCatView} where
3937 '{$this->oxarticles__oxprice->value}' >= {$sCatView}.oxpricefrom and
3938 '{$this->oxarticles__oxprice->value}' <= {$sCatView}.oxpriceto ";
3955 $sIn =
" '{$this->oxarticles__oxid->value}' ";
3956 if ($this->oxarticles__oxparentid->value) {
3959 $sIn .=
", '{$this->oxarticles__oxparentid->value}' ";
3960 $sParentIdForVariants = $this->oxarticles__oxparentid->value;
3963 $sParentIdForVariants = $this->
getId();
3968 $oRs = $oDb->select(
"select oxid from {$sArtTable} where oxparentid = " . $oDb->quote($sParentIdForVariants) .
" and oxid != " . $oDb->quote($this->oxarticles__oxid->value));
3969 if ($oRs !=
false && $oRs->recordCount() > 0) {
3970 while (!$oRs->EOF) {
3971 $sIn .=
", " . $oDb->quote(current($oRs->fields)) .
" ";
3976 $iLimit = (int) $this->
getConfig()->getConfigParam(
'iNrofCustomerWhoArticles');
3977 $iLimit = $iLimit ? ($iLimit * 10) : 50;
3980 $sQ =
"select distinct {$sArtTable}.* from (
3981 select d.oxorderid as suborderid from {$sOrderArtTable} as d use index ( oxartid ) where d.oxartid in ( {$sIn} ) limit {$iLimit}
3983 left join {$sOrderArtTable} force index ( oxorderid ) on suborder.suborderid = {$sOrderArtTable}.oxorderid
3984 left join {$sArtTable} on {$sArtTable}.oxid = {$sOrderArtTable}.oxartid
3985 where {$sArtTable}.oxid not in ( {$sIn} )
3986 and ( {$sArtTable}.oxissearch = 1 or {$sArtTable}.oxparentid <> '' ) and " . $this->
getSqlActiveSnippet();
4015 $sOXID = $oDb->quote($sOXID);
4016 $sCatId = $oDb->quote($sCatId);
4018 if (!$dPriceFromTo) {
4019 $sSelect =
"select oxobject2category.oxcatnid from $sO2CView as oxobject2category ";
4020 $sSelect .=
"left join $sCategoryView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
4021 $sSelect .=
"where oxobject2category.oxcatnid=$sCatId and oxobject2category.oxobjectid=$sOXID ";
4022 $sSelect .=
"and oxcategories.oxactive = 1 order by oxobject2category.oxtime ";
4024 $dPriceFromTo = $oDb->quote($dPriceFromTo);
4025 $sSelect =
"select oxcategories.oxid from $sCategoryView as oxcategories where ";
4026 $sSelect .=
"oxcategories.oxid=$sCatId and $dPriceFromTo >= oxcategories.oxpricefrom and ";
4027 $sSelect .=
"$dPriceFromTo <= oxcategories.oxpriceto ";
4040 if ($this->_oAmountPriceList === null) {
4041 $oAmPriceList =
oxNew(
'oxAmountPricelist');
4045 $oAmPriceList->load($this);
4049 foreach ($oAmPriceList as $oAmPrice) {
4050 if ($oAmPrice->oxprice2article__oxaddperc->value) {
4057 $this->_oAmountPriceList = $oAmPriceList;
4072 $mValue = $this->$sFieldName->value;
4074 if (is_null($mValue)) {
4078 if ($mValue ===
'') {
4083 $aZeroValueFields = array(
'oxarticles__oxprice',
'oxarticles__oxvat',
'oxarticles__oxunitquantity');
4085 if (!$mValue && in_array($sFieldName, $aZeroValueFields)) {
4090 if (!strcmp($mValue,
'0000-00-00 00:00:00') || !strcmp($mValue,
'0000-00-00')) {
4094 $sFieldName = strtolower($sFieldName);
4096 if ($sFieldName ==
'oxarticles__oxicon' && (strpos($mValue,
"nopic_ico.jpg") !==
false || strpos($mValue,
"nopic.jpg") !==
false)) {
4100 if (strpos($mValue,
"nopic.jpg") !==
false && ($sFieldName ==
'oxarticles__oxthumb' || substr($sFieldName, 0, 17) ==
'oxarticles__oxpic' || substr($sFieldName, 0, 18) ==
'oxarticles__oxzoom')) {
4123 if ($oParentArticle->$sCopyFieldName != null) {
4126 if (substr($sCopyFieldName, 0, 12) !=
'oxarticles__') {
4131 if (in_array($sCopyFieldName, $this->_aNonCopyParentFields)) {
4142 $this->$sCopyFieldName = clone $oParentArticle->$sCopyFieldName;
4156 $blIsImageField = (stristr($sFieldName,
'_oxthumb') || stristr($sFieldName,
'_oxicon') || stristr($sFieldName,
'_oxzoom') || stristr($sFieldName,
'_oxpic'));
4158 return $blIsImageField;
4166 startProfile(
'articleAssignParentInternal');
4167 if ($this->oxarticles__oxparentid->value) {
4169 if (!$this->
isAdmin() || ($this->_blLoadParentData && $this->
isAdmin())) {
4170 foreach ($this->_aFieldNames as $sFieldName => $sVal) {
4175 stopProfile(
'articleAssignParentInternal');
4183 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') &&
4184 ($this->_blHasVariants || $this->oxarticles__oxvarstock->value || $this->oxarticles__oxvarcount->value)
4186 $this->_blNotBuyableParent =
true;
4202 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts') && !$this->
isAdmin()) {
4203 $this->oxarticles__oxstock =
new oxField((
int) floor($this->oxarticles__oxstock->value));
4206 $this->_iStockStatus = 0;
4209 if (
$myConfig->getConfigParam(
'blUseStock') &&
4210 $this->oxarticles__oxstockflag->value != 4
4213 $iStock = $this->oxarticles__oxstock->value;
4215 if ($this->_blNotBuyableParent) {
4216 $iStock = $this->oxarticles__oxvarstock->value;
4220 if ($iStock <= $myConfig->getConfigParam(
'sStockWarningLimit') && $iStock > 0) {
4221 $this->_iStockStatus = 1;
4226 $this->_iStockStatus = -1;
4232 if (
$myConfig->getConfigParam(
'blUseStock') && ($this->oxarticles__oxstockflag->value == 3 || $this->oxarticles__oxstockflag->value == 2)) {
4233 $iOnStock = $this->oxarticles__oxstock->value;
4234 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
4235 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
4237 if ($iOnStock <= 0) {
4243 if ($this->_blNotBuyable && $this->oxarticles__oxvarstock->value) {
4246 $this->_blNotBuyableParent =
true;
4252 if (!
$myConfig->getConfigParam(
'blVariantParentBuyable') && !
$myConfig->getConfigParam(
'blLoadVariants') && $this->oxarticles__oxvarstock->value) {
4257 if (!$this->_blNotBuyable && $this->_blNotBuyableParent && $this->oxarticles__oxvarcount->value == 0) {
4269 if (isset($aPersParam) && isset($aPersParam[$this->
getId()])) {
4270 $this->_aPersistParam = $aPersParam[$this->
getId()];
4281 $sThisShop = $this->oxarticles__oxshopid->value;
4283 $this->_sDynImageDir =
$myConfig->getPictureUrl(null,
false);
4284 $this->dabsimagedir =
$myConfig->getPictureDir(
false);
4285 $this->nossl_dimagedir =
$myConfig->getPictureUrl(null,
false,
false, null, $sThisShop);
4286 $this->ssl_dimagedir =
$myConfig->getPictureUrl(null,
false,
true, null, $sThisShop);
4297 if (isset($aItems[$this->
getId()])) {
4298 $this->_blIsOnComparisonList =
true;
4312 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
4313 $this->oxarticles__oxinsert =
new oxField($sNow);
4314 if (!is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value ==
'') {
4315 $this->oxarticles__oxsubclass =
new oxField(
'oxarticle');
4357 $sOXID = $oDb->quote($sOXID);
4360 $sDelete =
'delete from oxobject2article where oxarticlenid = ' . $sOXID .
' or oxobjectid = ' . $sOXID .
' ';
4361 $oDb->execute($sDelete);
4363 $sDelete =
'delete from oxobject2attribute where oxobjectid = ' . $sOXID .
' ';
4364 $oDb->execute($sDelete);
4366 $sDelete =
'delete from oxobject2category where oxobjectid = ' . $sOXID .
' ';
4367 $oDb->execute($sDelete);
4369 $sDelete =
'delete from oxobject2selectlist where oxobjectid = ' . $sOXID .
' ';
4370 $oDb->execute($sDelete);
4372 $sDelete =
'delete from oxprice2article where oxartid = ' . $sOXID .
' ';
4373 $oDb->execute($sDelete);
4375 $sDelete =
'delete from oxreviews where oxtype="oxarticle" and oxobjectid = ' . $sOXID .
' ';
4376 $oDb->execute($sDelete);
4378 $sDelete =
'delete from oxratings where oxobjectid = ' . $sOXID .
' ';
4379 $rs = $oDb->execute($sDelete);
4381 $sDelete =
'delete from oxaccessoire2article where oxobjectid = ' . $sOXID .
' or oxarticlenid = ' . $sOXID .
' ';
4382 $oDb->execute($sDelete);
4385 $sDelete =
'delete from oxobject2delivery where oxobjectid = ' . $sOXID .
' and oxtype=\'oxarticles\' ';
4386 $oDb->execute($sDelete);
4388 $sDelete =
'delete from oxartextends where oxid = ' . $sOXID .
' ';
4389 $oDb->execute($sDelete);
4393 $oDb->execute(
"delete from $sSetTbl where oxid = {$sOXID}");
4396 $sDelete =
'delete from oxactions2article where oxartid = ' . $sOXID .
' ';
4397 $rs = $oDb->execute($sDelete);
4399 $sDelete =
'delete from oxobject2list where oxobjectid = ' . $sOXID .
' ';
4400 $rs = $oDb->execute($sDelete);
4416 $sQ =
'select oxid from ' . $this->
getViewName() .
' where oxparentid = ' . $oDb->quote($sOXID);
4417 $rs = $oDb->select($sQ,
false,
false);
4418 $oArticle =
oxNew(
"oxArticle");
4419 if ($rs !=
false && $rs->recordCount() > 0) {
4421 $oArticle->setId($rs->fields[0]);
4422 $oArticle->delete();
4439 $oPictureHandler->deleteMainIcon($this);
4442 $oPictureHandler->deleteThumbnail($this);
4444 $sAbsDynImageDir =
$myConfig->getPictureDir(
false);
4447 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
4448 for ($i = 1; $i <= $iPicCount; $i++) {
4449 $oPictureHandler->deleteArticleMasterPicture($this, $i);
4465 $myUtilsCount->resetVendorArticleCount($sVendorId);
4468 if ($sManufacturerId) {
4469 $myUtilsCount->resetManufacturerArticleCount($sManufacturerId);
4474 foreach ($aCategoryIds as $sCatId) {
4475 $myUtilsCount->resetCatArticleCount($sCatId,
false);
4488 $sParentIdQuoted = $oDb->quote($sParentID);
4489 $sQ =
'select oxstock, oxvendorid, oxmanufacturerid from oxarticles where oxid = ' . $sParentIdQuoted;
4490 $rs = $oDb->select($sQ,
false,
false);
4491 $iOldStock = $rs->fields[0];
4492 $iVendorID = $rs->fields[1];
4493 $iManufacturerID = $rs->fields[2];
4495 $sQ =
'select sum(oxstock) from ' . $this->
getViewName(
true) .
' where oxparentid = ' . $sParentIdQuoted .
' and ' . $this->
getSqlActiveSnippet(
true) .
' and oxstock > 0 ';
4496 $iStock = (float) $oDb->getOne($sQ,
false,
false);
4498 $sQ =
'update oxarticles set oxvarstock = ' . $iStock .
' where oxid = ' . $sParentIdQuoted;
4506 if ($iOldStock < 0) {
4509 if ($this->oxarticles__oxstockflag->value == 2 && $iOldStock xor $iStock) {
4526 if (
$myConfig->getConfigParam(
'blUseStock') && $this->oxarticles__oxstockflag->value == 2 &&
4527 ($this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value) <= 0
4530 $this->
_onChangeResetCounts($sOxid, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value);
4543 $sParentIdQuoted = $oDb->quote($sParentID);
4544 $sQ =
"select count(*) as varcount from oxarticles where oxparentid = {$sParentIdQuoted}";
4545 $iVarCount = (int) $oDb->getOne($sQ,
false,
false);
4547 $sQ =
"update oxarticles set oxvarcount = {$iVarCount} where oxid = {$sParentIdQuoted}";
4563 MIN( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varminprice`,
4564 MAX( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varmaxprice`
4565 FROM ' . $this->
getViewName(
true) .
' AS `oxarticles`
4566 LEFT JOIN ' . $this->
getViewName(
true) .
' AS `p` ON ( `p`.`oxid` = `oxarticles`.`oxparentid` AND `p`.`oxprice` > 0 )
4568 AND ( `oxarticles`.`oxparentid` = ' . $oDb->quote($sParentId) .
' )';
4570 $aPrices = $oDb->getRow($sQ,
false,
false);
4571 if (!is_null($aPrices[
'varminprice']) || !is_null($aPrices[
'varmaxprice'])) {
4575 `oxvarminprice` = ' . $oDb->quote($aPrices[
'varminprice']) .
',
4576 `oxvarmaxprice` = ' . $oDb->quote($aPrices[
'varmaxprice']) .
'
4578 `oxid` = ' . $oDb->quote($sParentId);
4583 `oxvarminprice` = `oxprice`,
4584 `oxvarmaxprice` = `oxprice`
4586 `oxid` = ' . $oDb->quote($sParentId);
4601 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
4603 if ($sPicName ==
"nopic.jpg" || $sPicName ==
"") {
4608 $this->
getParentArticle()->{
"oxarticles__oxpic" . $iIndex}->value == $this->{
"oxarticles__oxpic" . $iIndex}->value
4613 $sMasterPic =
'product/' . $iIndex .
"/" . $sPicName;
4615 if ($this->
getConfig()->getMasterPicturePath($sMasterPic)) {
4629 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
4632 $blResult = $oUser->isPriceViewModeNetto();
4648 $oPrice =
oxNew(
'oxPrice');
4650 if ($blCalculationModeNetto === null) {
4654 if ($blCalculationModeNetto) {
4655 $oPrice->setNettoPriceMode();
4657 $oPrice->setBruttoPriceMode();
4674 $dPrice = $oPrice->getNettoPrice();
4676 $dPrice = $oPrice->getBruttoPrice();
4692 protected function _preparePrice($dPrice, $dVat, $blCalculationModeNetto = null)
4694 if ($blCalculationModeNetto === null) {
4698 $oCurrency = $this->
getConfig()->getActShopCurrencyObject();
4700 $blEnterNetPrice = $this->
getConfig()->getConfigParam(
'blEnterNetPrice');
4701 if ($blCalculationModeNetto && !$blEnterNetPrice) {
4703 } elseif (!$blCalculationModeNetto && $blEnterNetPrice) {
4721 if ($oUser->inGroup(
'oxidpricea')) {
4722 $sPriceSuffix =
'a';
4723 } elseif ($oUser->inGroup(
'oxidpriceb')) {
4724 $sPriceSuffix =
'b';
4725 } elseif ($oUser->inGroup(
'oxidpricec')) {
4726 $sPriceSuffix =
'c';
4730 return $sPriceSuffix;
4742 if ($sPriceSuffix ===
'') {
4743 $dPrice = $this->oxarticles__oxprice->value;
4745 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4746 $dPrice = ($this->{oxarticles__oxprice . $sPriceSuffix}->value != 0) ? $this->{oxarticles__oxprice . $sPriceSuffix}->value : $this->oxarticles__oxprice->value;
4748 $dPrice = $this->{oxarticles__oxprice . $sPriceSuffix}->value;
4763 if ($this->_dVarMinPrice === null) {
4767 if (is_null($dPrice)) {
4769 if ($sPriceSuffix ===
'') {
4770 $dPrice = $this->oxarticles__oxvarminprice->value;
4773 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4774 $sSql .=
'MIN( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varminprice` ';
4776 $sSql .=
'MIN(`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4787 $this->_dVarMinPrice = $dPrice;
4802 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4805 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4806 $sSql .=
'MIN(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varminprice` ';
4808 $sSql .=
'MIN(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4810 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4811 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4813 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4814 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4828 if ($this->_dVarMaxPrice === null) {
4832 if (is_null($dPrice)) {
4834 if ($sPriceSuffix ===
'') {
4835 $dPrice = $this->oxarticles__oxvarmaxprice->value;
4838 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4839 $sSql .=
'MAX( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varmaxprice` ';
4841 $sSql .=
'MAX(`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4852 $this->_dVarMaxPrice = $dPrice;
4867 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4870 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4871 $sSql .=
'MAX(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varmaxprice` ';
4873 $sSql .=
'MAX(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4875 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4876 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4878 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4879 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4914 $sValue = isset($this->$sField->value) ? $this->$sField->value : 0;
4915 $sSqlSets[] =
'`' . str_replace(
'oxarticles__',
'', $sField) .
'` = ' . $oDb->quote($sValue);
4918 $sSql =
"UPDATE `oxarticles` SET ";
4919 $sSql .= implode(
', ', $sSqlSets) .
'';
4920 $sSql .=
" WHERE `oxparentid` = " . $oDb->quote($this->
getId());
4922 return $oDb->execute($sSql);
4944 $this->$sField =
new oxField($sParent->$sField->value);
4957 $aSortingFields = !empty($aSortingFields) ? (array) $aSortingFields : array();
4959 foreach ($aSortingFields as $sField) {
4961 $this->_aSortingFieldsOnLoad[$sFullField] = $this->$sFullField->value;