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);
2075 $sQuery =
'select oxstock from oxarticles where oxid = ' . $oDb->quote($this->
getId()) .
' FOR UPDATE ';
2076 $actualStock = $oDb->getOne($sQuery);
2078 $iStockCount = $actualStock - $dAmount;
2079 if (!$blAllowNegativeStock && ($iStockCount < 0)) {
2080 $dAmount += $iStockCount;
2083 $this->oxarticles__oxstock =
new oxField($iStockCount);
2085 $sQuery =
'update oxarticles set oxarticles.oxstock = ' . $oDb->quote($iStockCount) .
2086 ' where oxarticles.oxid = ' . $oDb->quote($this->
getId());
2087 $oDb->execute($sQuery);
2088 $this->
onChange(ACTION_UPDATE_STOCK);
2108 if (!$this->oxarticles__oxparentid->value) {
2110 $dAmount = (double) $dAmount;
2112 $rs = $oDb->execute(
"update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + $dAmount where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2113 } elseif ($this->oxarticles__oxparentid->value) {
2116 if ($oUpdateArticle) {
2117 $oUpdateArticle->updateSoldAmount($dAmount);
2133 return $oDb->execute(
"update oxarticles set oxarticles.oxremindactive = 2 where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2145 if (($blRet = parent::save())) {
2158 $sParentId = $this->oxarticles__oxparentid->value;
2160 $this->_blAllowEmptyParentId =
true;
2162 $this->_blAllowEmptyParentId =
false;
2164 if ($sParentId !==
'') {
2165 $this->
onChange(ACTION_UPDATE, null, $sParentId);
2182 $aArtPics = array();
2183 $aArtIcons = array();
2193 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
2194 $blCheckActivePicId =
true;
2196 for ($i = 1; $i <= $iPicCount; $i++) {
2199 if (!$oStr->strstr($sIcoVal,
'nopic_ico.jpg') && !$oStr->strstr($sIcoVal,
'nopic.jpg') &&
2200 !$oStr->strstr($sPicVal,
'nopic_ico.jpg') && !$oStr->strstr($sPicVal,
'nopic.jpg') &&
2206 $aArtIcons[$i] = $sIcoVal;
2207 $aArtPics[$i] = $sPicVal;
2210 if ($iActPicId == $i) {
2211 $sActPic = $sPicVal;
2212 $blCheckActivePicId =
false;
2215 } elseif ($blCheckActivePicId && $iActPicId <= $i) {
2223 $aZoomPics = array();
2224 $iZoomPicCount =
$myConfig->getConfigParam(
'iPicCount');
2226 for ($j = 1, $c = 1; $j <= $iZoomPicCount; $j++) {
2229 if ($sVal && !$oStr->strstr($sVal,
'nopic.jpg')) {
2231 $aZoomPics[$c][
'id'] = $c;
2232 $aZoomPics[$c][
'file'] = $sVal;
2235 $aZoomPics[$c][
'file'] =
"nopic.jpg";
2241 $aPicGallery = array(
'ActPicID' => $iActPicId,
2242 'ActPic' => $sActPic,
2243 'MorePics' => $blMorePic,
2244 'Pics' => $aArtPics,
2245 'Icons' => $aArtIcons,
2246 'ZoomPic' => $blZoomPic,
2247 'ZoomPics' => $aZoomPics);
2249 return $aPicGallery;
2265 public function onChange($sAction = null, $sOXID = null, $sParentID = null)
2269 if (!isset($sOXID)) {
2270 if ($this->
getId()) {
2271 $sOXID = $this->
getId();
2273 if (!isset ($sOXID)) {
2274 $sOXID = $this->oxarticles__oxid->value;
2276 if ($this->oxarticles__oxparentid->value) {
2277 $sParentID = $this->oxarticles__oxparentid->value;
2280 if (!isset($sOXID)) {
2285 if (
$myConfig->getConfigParam(
'blUseStock')) {
2288 if (!isset($sParentID)) {
2290 $sQ =
'select oxparentid from oxarticles where oxid = ' . $oDb->quote($sOXID);
2291 $sParentID = $oDb->getOne($sQ);
2304 $sId = ($sParentID) ? $sParentID : $sOXID;
2311 if ($sAction === ACTION_UPDATE_STOCK) {
2326 if (isset($this->oxarticles__oxvat->value)) {
2327 return $this->oxarticles__oxvat->value;
2340 public function checkForStock($dAmount, $dArtStockAmount = 0, $selectForUpdate =
false)
2343 if (!
$myConfig->getConfigParam(
'blUseStock')) {
2349 $sQ =
'select oxstock, oxstockflag from oxarticles where oxid = ' . $oDb->quote($this->
getId());
2350 $sQ .= $selectForUpdate ?
' FOR UPDATE ' :
'';
2351 $rs = $oDb->select($sQ);
2355 if ($rs !==
false && $rs->recordCount() > 0) {
2356 $iOnStock = $rs->fields[
'oxstock'] - $dArtStockAmount;
2357 $iStockFlag = $rs->fields[
'oxstockflag'];
2363 if (!
$myConfig->getConfigParam(
'blPsBasketReservationEnabled')
2364 || (
$myConfig->getConfigParam(
'blPsBasketReservationEnabled')
2365 &&
$myConfig->getConfigParam(
'blAllowNegativeStock'))
2368 if ($iStockFlag == 1 || $iStockFlag == 4) {
2372 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts')) {
2373 $iOnStock = floor($iOnStock);
2376 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
2377 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
2379 if ($iOnStock >= $dAmount) {
2382 if ($iOnStock > 0) {
2385 $oEx =
oxNew(
'oxArticleInputException');
2386 $oEx->setMessage(
'ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE');
2402 if ($this->_oLongDesc === null) {
2404 $this->_oLongDesc =
new oxField();
2408 $sOxid = $this->
getId();
2412 $sDbValue = $oDb->getOne(
"select oxlongdesc from {$sViewName} where oxid = " . $oDb->quote($sOxid));
2414 if ($sDbValue !=
false) {
2416 } elseif ($this->oxarticles__oxparentid->value) {
2417 if (!$this->
isAdmin() || $this->_blLoadParentData) {
2420 $this->_oLongDesc->setValue($oParent->getLongDescription()->getRawValue(),
oxField::T_RAW);
2462 if ($this->_oAttributeList === null) {
2463 $this->_oAttributeList =
oxNew(
'oxattributelist');
2464 $this->_oAttributeList->loadAttributes($this->
getId(), $this->
getParentId());
2477 if ($this->_oAttributeList === null) {
2478 $this->_oAttributeList =
oxNew(
'oxattributelist');
2479 $this->_oAttributeList->loadAttributesDisplayableInBasket($this->
getId(), $this->
getParentId());
2495 if ($iLang === null) {
2499 $this->_aSeoAddParams[$iLang] = isset($this->_aSeoAddParams[$iLang]) ? $this->_aSeoAddParams[$iLang] .
"&" :
"";
2500 $this->_aSeoAddParams[$iLang] .= $sAddParams;
2517 return $oEncoder->getArticleUrl($this, $iLang, $this->
getLinkType());
2520 return $oEncoder->getArticleMainUrl($this, $iLang);
2531 public function getLink($iLang = null, $blMain =
false)
2537 if ($iLang === null) {
2542 if (!isset($this->_aSeoUrls[$iLang][$iLinkType])) {
2543 $this->_aSeoUrls[$iLang][$iLinkType] = $this->
getBaseSeoLink($iLang, $blMain);
2546 $sUrl = $this->_aSeoUrls[$iLang][$iLinkType];
2547 if (isset($this->_aSeoAddParams[$iLang])) {
2548 $sUrl .= ((strpos($sUrl . $this->_aSeoAddParams[$iLang],
'?') ===
false) ?
'?' :
'&') . $this->_aSeoAddParams[$iLang];
2564 return $this->
getLink($iLang,
true);
2575 $this->_sDetailLink = null;
2578 $this->_iLinkType = (int) $iType;
2600 if ($iLang === null) {
2604 $this->_aStdAddParams[$iLang] = isset($this->_aStdAddParams[$iLang]) ? $this->_aStdAddParams[$iLang] .
"&" :
"";
2605 $this->_aStdAddParams[$iLang] .= $sAddParams;
2623 $sUrl = $this->
getConfig()->getShopUrl($iLang,
false);
2626 $sUrl .=
"index.php?cl=details" . ($blAddId ?
"&anid=" . $this->
getId() :
"");
2628 return $sUrl . (isset($this->_aStdAddParams[$iLang]) ?
"&" . $this->_aStdAddParams[$iLang] :
"");
2641 if ($iLang === null) {
2645 if (!isset($this->_aStdUrls[$iLang])) {
2649 return oxRegistry::get(
"oxUtilsUrl")->processUrl($this->_aStdUrls[$iLang],
true, $aParams, $iLang);
2659 if ($this->_aMediaUrls === null) {
2660 $this->_aMediaUrls =
oxNew(
"oxlist");
2661 $this->_aMediaUrls->init(
"oxmediaurl");
2662 $this->_aMediaUrls->getBaseObject()->setLanguage($this->
getLanguage());
2665 $sQ =
"select * from {$sViewName} where oxobjectid = '" . $this->
getId() .
"'";
2666 $this->_aMediaUrls->selectString($sQ);
2689 if ($this->_aDispSelList === null) {
2690 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists') && $this->
getConfig()->getConfigParam(
'bl_perfLoadSelectListsInAList')) {
2705 if ($this->_sMoreDetailLink == null) {
2708 $this->_sMoreDetailLink = $this->
getConfig()->getShopHomeURL() .
'cl=moredetails';
2712 $this->_sMoreDetailLink .=
'&cnid=' . $sActCat;
2714 $this->_sMoreDetailLink .=
'&anid=' . $this->
getId();
2728 if ($this->_sToBasketLink == null) {
2732 $this->_sToBasketLink = $this->
getLink();
2735 $this->_sToBasketLink =
$myConfig->getShopHomeURL();
2739 if ($sActClass ==
'thankyou') {
2740 $sActClass =
'basket';
2742 $this->_sToBasketLink .=
'cl=' . $sActClass;
2746 $this->_sToBasketLink .=
'&cnid=' . $sActCat;
2749 $this->_sToBasketLink .=
'&fnc=tobasket&aid=' . $this->
getId() .
'&anid=' . $this->
getId();
2752 $this->_sToBasketLink .=
'&tpl=' . $sTpl;
2777 if ($this->oxarticles__oxdelivery->value !=
'0000-00-00') {
2778 return oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxarticles__oxdelivery->value);
2823 if ($this->oxarticles__oxremindactive->value == 2 &&
2824 $this->oxarticles__oxremindamount->value <= $this->oxarticles__oxstock->value
2826 $this->oxarticles__oxremindactive->value = 1;
2871 $this->_blNotBuyable = !$blBuyable;
2881 $this->_aDispSelList = $aSelList;
2896 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2899 $sSize = $this->
getConfig()->getConfigParam(
'aDetailImageSizes');
2901 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2916 $sDirname =
"product/1/";
2917 if ($iIndex && !$this->
_isFieldEmpty(
"oxarticles__oxpic{$iIndex}")) {
2918 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2919 $sDirname =
"product/{$iIndex}/";
2921 $sImgName = basename($this->oxarticles__oxicon->value);
2922 $sDirname =
"product/icon/";
2924 $sImgName = basename($this->oxarticles__oxpic1->value);
2927 $sSize = $this->
getConfig()->getConfigParam(
'sIconsize');
2929 $sIconUrl =
oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, $iIndex);
2944 $sDirname =
"product/1/";
2946 $sImgName = basename($this->oxarticles__oxthumb->value);
2947 $sDirname =
"product/thumb/";
2949 $sImgName = basename($this->oxarticles__oxpic1->value);
2952 $sSize = $this->
getConfig()->getConfigParam(
'sThumbnailsize');
2954 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, 0, $bSsl);
2966 $iIndex = (int) $iIndex;
2967 if ($iIndex > 0 && !$this->
_isFieldEmpty(
"oxarticles__oxpic" . $iIndex)) {
2968 $sImgName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
2969 $sSize = $this->
getConfig()->getConfigParam(
"sZoomImageSize");
2971 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2995 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
2998 foreach ($aDiscounts as $oDiscount) {
2999 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
3001 $oPrice->calculateDiscount();
3012 if (($sParentId = $this->oxarticles__oxparentid->value)) {
3013 $sIndex = $sParentId .
"_" . $this->
getLanguage();
3014 if (!isset(self::$_aLoadedParents[$sIndex])) {
3015 self::$_aLoadedParents[$sIndex] =
oxNew(
'oxarticle');
3016 self::$_aLoadedParents[$sIndex]->_blLoadPrice =
false;
3017 self::$_aLoadedParents[$sIndex]->_blLoadVariants =
false;
3021 self::$_aLoadedParents[$sIndex] =
false;
3025 return self::$_aLoadedParents[$sIndex];
3037 $sOxId = $oDb->quote($this->
getId());
3038 $sOxShopId = $oDb->quote($this->
getShopId());
3039 $iRemindActive = $oDb->quote($this->oxarticles__oxremindactive->value);
3042 set oxremindactive = $iRemindActive
3043 where oxparentid = $sOxId and
3044 oxshopid = $sOxShopId
3046 $oDb->execute($sUpdate);
3058 return $this->
getId();
3068 return $this->oxarticles__oxparentid->value;
3088 return (
bool) (isset($this->oxarticles__oxparentid) ? $this->oxarticles__oxparentid->value :
false);
3098 $oMdVariant =
oxNew(
"oxVariantHandler");
3100 return $oMdVariant->isMdVariant($this);
3115 $sSelectWhere =
"select $sFields from " . $this->
_getObjectViewName(
'oxcategories') .
" where";
3116 $sQuotedPrice =
oxDb::getDb()->quote($this->oxarticles__oxprice->value);
3118 return "$sSelectWhere oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice"
3119 .
" union $sSelectWhere oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice"
3120 .
" union $sSelectWhere oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice";
3134 $sQuotedPrice = $oDb->quote($this->oxarticles__oxprice->value);
3135 $sQuotedCnid = $oDb->quote($sCatNid);
3137 return (
bool) $oDb->getOne(
3138 "select 1 from " . $this->
_getObjectViewName(
'oxcategories') .
" where oxid=$sQuotedCnid and"
3139 .
"( (oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice)"
3140 .
" or (oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice)"
3141 .
" or (oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice)"
3153 if ($this->_oMdVariants) {
3158 if ($oParentArticle) {
3159 $oVariants = $oParentArticle->getVariants();
3164 $oVariantHandler =
oxNew(
"oxVariantHandler");
3165 $this->_oMdVariants = $oVariantHandler->buildMdVariants($oVariants, $this->
getId());
3191 $sFieldName =
"oxarticles__" . $sFieldName . $iIndex;
3193 return $this->$sFieldName->value;
3207 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
3209 if ($sPicName && $sPicName !=
"nopic.jpg") {
3210 $sPicUrl = $this->
getConfig()->getPictureUrl(
"master/product/" . $iIndex .
"/" . $sPicName);
3211 if (!$sPicUrl || basename($sPicUrl) ==
"nopic.jpg") {
3226 if ($this->oxarticles__oxunitname->value) {
3240 if ($this->_aArticleFiles === null) {
3242 $this->_aArticleFiles =
false;
3244 $sQ =
"SELECT * FROM `oxfiles` WHERE `oxartid` = '" . $this->
getId() .
"'";
3246 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') && $blAddFromParent) {
3247 $sQ .=
" OR `oxartId` = '" . $this->oxarticles__oxparentid->value .
"'";
3250 $oArticleFiles =
oxNew(
"oxlist");
3251 $oArticleFiles->init(
"oxfile");
3252 $oArticleFiles->selectString($sQ);
3253 $this->_aArticleFiles = $oArticleFiles;
3267 return $this->oxarticles__oxisdownloadable->value;
3277 if (self::$_blHasAmountPrice === null) {
3279 self::$_blHasAmountPrice =
false;
3282 $sQ =
"SELECT 1 FROM `oxprice2article` LIMIT 1";
3284 if ($oDb->getOne($sQ)) {
3285 self::$_blHasAmountPrice =
true;
3301 protected function _loadVariantList($blSimple, $blRemoveNotOrderables =
true, $blForceCoreTable = null)
3303 $oVariants = array();
3304 if (($sId = $this->
getId())) {
3306 self::$_aLoadedParents[$sId .
"_" . $this->
getLanguage()] = $this;
3310 if (!$this->_blLoadVariants ||
3312 (!$this->
isAdmin() && !$this->oxarticles__oxvarcount->value)
3318 $sCacheKey = $blSimple ?
"simple" :
"full";
3319 if ($blRemoveNotOrderables) {
3320 if (isset($this->_aVariants[$sCacheKey])) {
3321 return $this->_aVariants[$sCacheKey];
3323 $this->_aVariants[$sCacheKey] = & $oVariants;
3325 } elseif (!$blRemoveNotOrderables) {
3326 if (isset($this->_aVariantsWithNotOrderables[$sCacheKey])) {
3327 return $this->_aVariantsWithNotOrderables[$sCacheKey];
3329 $this->_aVariantsWithNotOrderables[$sCacheKey] = & $oVariants;
3333 if (($this->_blHasVariants = $this->
_hasAnyVariant($blForceCoreTable))) {
3337 $oVariants =
oxNew(
'oxsimplevariantlist');
3338 $oVariants->setParent($this);
3341 $oVariants =
oxNew(
'oxarticlelist');
3342 $oVariants->getBaseObject()->modifyCacheKey(
'_variants');
3345 startProfile(
"selectVariants");
3346 $blUseCoreTable = (bool) $blForceCoreTable;
3347 $oBaseObject = $oVariants->getBaseObject();
3351 $sArticleTable = $this->
getViewName($blUseCoreTable);
3353 $sSelect =
"select " . $oBaseObject->getSelectFields($blUseCoreTable) .
" from $sArticleTable where " .
3356 " order by $sArticleTable.oxsort";
3357 $oVariants->selectString($sSelect);
3360 if (
$myConfig->getConfigParam(
'blUseMultidimensionVariants')) {
3361 $oMdVariants =
oxNew(
"oxVariantHandler");
3362 $this->_blHasMdVariants = $oMdVariants->isMdVariant($oVariants->current());
3364 stopProfile(
"selectVariants");
3369 $this->_blNotBuyableParent =
true;
3374 $this->_blNotBuyable =
true;
3392 $aResult = $oDb->getAll($sSql);
3396 foreach ($aResult as $aValue) {
3397 $aValue = array_change_key_case($aValue, CASE_LOWER);
3400 $aReturn[] = $aValue[$sField];
3418 $sArticleIdSql =
'oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getId());
3420 $sArticleIdSql =
'(' . $sArticleIdSql .
' or oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getParentId()) .
')';
3425 oxobject2category.oxcatnid as oxcatnid
3426 from $sO2CView as oxobject2category
3427 left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid
3428 where $sArticleIdSql and oxcategories.oxid is not null and oxcategories.oxactive = 1 $sActiveCategorySql
3429 order by oxobject2category.oxtime";
3442 $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 ";
3444 return $sActiveCategorySql;
3461 $sSelect =
"select oxobject2category.oxcatnid as oxcatnid from $sO2CView as oxobject2category left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
3462 $sSelect .=
'where oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($sOXID) .
' and oxcategories.oxid is not null and oxcategories.oxactive = 1 ';
3464 $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 ";
3466 $sSelect .=
'order by oxobject2category.oxtime ';
3482 if (isset($dVat) || !$this->
getConfig()->getConfigParam(
'bl_perfCalcVatOnlyForBasketOrder')) {
3491 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
3494 foreach ($aDiscounts as $oDiscount) {
3495 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
3497 $oPrice->calculateDiscount();
3513 if (($sId = $this->
getId())) {
3514 if ($this->oxarticles__oxshopid->value == $this->getConfig()->getShopId()) {
3515 $blHas = (bool) $this->oxarticles__oxvarcount->value;
3517 $sArticleTable = $this->
getViewName($blForceCoreTable);
3518 $blHas = (bool)
oxDb::getDb()->getOne(
"select 1 from $sArticleTable where oxparentid='{$sId}'");
3542 return $this->
_isStockStatusChanged() && ($this->_iStockStatus == -1 || $this->_iStockStatusOnLoad == -1);
3554 if (in_array(
"oxlongdesc", $this->_aSkipSaveFields)) {
3558 if ($this->_blEmployMultilanguage) {
3560 if ($sValue !== null) {
3561 $oArtExt =
oxNew(
'oxI18n');
3562 $oArtExt->init(
'oxartextends');
3563 $oArtExt->setLanguage((
int) $this->
getLanguage());
3564 if (!$oArtExt->load($this->getId())) {
3565 $oArtExt->setId($this->
getId());
3571 $oArtExt =
oxNew(
'oxI18n');
3572 $oArtExt->setEnableMultilang(
false);
3573 $oArtExt->init(
'oxartextends');
3574 $aObjFields = $oArtExt->_getAllFields(
true);
3575 if (!$oArtExt->load($this->getId())) {
3576 $oArtExt->setId($this->
getId());
3579 foreach ($aObjFields as $sKey => $sValue) {
3580 if (preg_match(
'/^oxlongdesc(_(\d{1,2}))?$/', $sKey)) {
3583 if (isset($this->$sField)) {
3585 if ($this->$sField instanceof
oxField) {
3586 $sLongDesc = $this->$sField->getRawValue();
3587 } elseif (is_object($this->$sField)) {
3588 $sLongDesc = $this->$sField->value;
3590 if (isset($sLongDesc)) {
3591 $sAEField = $oArtExt->_getFieldLongName($sKey);
3608 $this->_aSkipSaveFields = array();
3610 $this->_aSkipSaveFields[] =
'oxtimestamp';
3612 $this->_aSkipSaveFields[] =
'oxinsert';
3615 if (!$this->_blAllowEmptyParentId && (!isset($this->oxarticles__oxparentid->value) || $this->oxarticles__oxparentid->value ==
'')) {
3616 $this->_aSkipSaveFields[] =
'oxparentid';
3632 foreach ($aItemDiscounts as $sKey => $oDiscount) {
3634 if (array_key_exists($sKey, $aDiscounts)) {
3635 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
3637 $aDiscounts[$sKey] = $oDiscount;
3652 $sVarName =
"oxarticles__oxprice{$sPriceSufix}";
3653 $dPrice = $this->$sVarName->value;
3656 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices') && (
double) $dPrice == 0) {
3657 $dPrice = $this->oxarticles__oxprice->value;
3673 startProfile(
"_getAmountPrice");
3677 foreach ($oAmtPrices as $oAmPrice) {
3678 if ($oAmPrice->oxprice2article__oxamount->value <= $dAmount
3679 && $dAmount <= $oAmPrice->oxprice2article__oxamountto->value
3680 && $dPrice > $oAmPrice->oxprice2article__oxaddabs->value
3682 $dPrice = $oAmPrice->oxprice2article__oxaddabs->value;
3686 stopProfile(
"_getAmountPrice");
3703 if (
$myConfig->getConfigParam(
'bl_perfLoadSelectLists') &&
$myConfig->getConfigParam(
'bl_perfUseSelectlistPrice')) {
3707 foreach ($aSelLists as $key => $aSel) {
3708 if (isset($aChosenList[$key]) && isset($aSel[$aChosenList[$key]])) {
3709 $oSel = $aSel[$aChosenList[$key]];
3710 if ($oSel->priceUnit ==
'abs') {
3711 $dPrice += $oSel->price;
3712 } elseif ($oSel->priceUnit ==
'%') {
3734 foreach ($aAmPriceList as $sId => $oItem) {
3737 if ($oItem->oxprice2article__oxaddabs->value) {
3739 $dBasePrice = $oItem->oxprice2article__oxaddabs->value;
3742 $oItemPrice->setPrice($dBasePrice);
3748 $oItemPrice->setPrice($dBasePrice);
3749 $oItemPrice->subtractPercent($oItem->oxprice2article__oxaddperc->value);
3753 $aAmPriceList[$sId]->fbrutprice = $oLang->formatCurrency($this->
_getPriceForView($oItemPrice));
3756 return $aAmPriceList;
3769 $sId = $this->
getId();
3771 $sActiveSqlSnippet =
"";
3772 if ($blActiveVariants) {
3776 $sQ =
"select oxid from " . $this->
getViewName(
true) .
" where oxparentid = " . $oDb->quote($sId) .
3777 $sActiveSqlSnippet .
" order by oxsort";
3778 $oRs = $oDb->select($sQ);
3779 if ($oRs !=
false && $oRs->recordCount() > 0) {
3780 while (!$oRs->EOF) {
3781 $aSelect[] = reset($oRs->fields);
3811 if (!isset($this->_dArticleVat)) {
3812 $this->_dArticleVat =
oxRegistry::get(
"oxVatSelector")->getArticleVat($this);
3826 startProfile(__FUNCTION__);
3827 $oPrice->setVAT($dVat);
3830 if (($dVat = $oVatSelector->getArticleUserVat($this)) !==
false) {
3833 stopProfile(__FUNCTION__);
3845 $oCur = $this->
getConfig()->getActShopCurrencyObject();
3862 $sSelect =
'select oxattrid from oxobject2attribute where oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getId());
3864 $sSelect .=
' OR oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getParentId());
3866 $sAttributeSql =
'';
3867 $aAttributeIds = $oDb->getCol($sSelect);
3868 if (is_array($aAttributeIds) && count($aAttributeIds)) {
3869 $aAttributeIds = array_unique($aAttributeIds);
3870 $iCnt = count($aAttributeIds);
3871 $sAttributeSql .=
't1.oxattrid IN ( ' . implode(
',', $oDb->quoteArray($aAttributeIds)) .
') ';
3886 $iAttrPercent = $this->
getConfig()->getConfigParam(
'iAttributesPercent') / 100;
3888 if (!$iAttrPercent || $iAttrPercent < 0 || $iAttrPercent > 1) {
3889 $iAttrPercent = 0.70;
3892 $iHitMin = ceil($iCnt * $iAttrPercent);
3894 $aExcludeIds = array();
3895 $aExcludeIds[] = $this->
getId();
3901 $sSelect =
"select oxobjectid from oxobject2attribute as t1 where
3903 and t1.oxobjectid NOT IN (" . implode(
', ',
oxDb::getDb()->quoteArray($aExcludeIds)) .
")
3904 group by t1.oxobjectid having count(*) >= $iHitMin LIMIT 0, 20";
3920 $aList = array_slice($aList, 0, $this->
getConfig()->getConfigParam(
'iNrofSimilarArticles'));
3922 $sSearch =
"select $sFieldList from $sArticleTable where " . $this->
getSqlActiveSnippet() .
" and $sArticleTable.oxissearch = 1 and $sArticleTable.oxid in ( ";
3924 $sSearch .= implode(
',',
oxdb::getDb()->quoteArray($aList)) .
')';
3927 $sSearch .=
' order by rand() ';
3947 if (!$blSearchPriceCat) {
3948 $sSelect =
"select {$sCatView}.* from {$sO2CView} as oxobject2category left join {$sCatView} on
3949 {$sCatView}.oxid = oxobject2category.oxcatnid
3950 where oxobject2category.oxobjectid=" .
oxDb::getDb()->quote($sOXID) .
" and {$sCatView}.oxid is not null ";
3952 $sSelect =
"select {$sCatView}.* from {$sCatView} where
3953 '{$this->oxarticles__oxprice->value}' >= {$sCatView}.oxpricefrom and
3954 '{$this->oxarticles__oxprice->value}' <= {$sCatView}.oxpriceto ";
3971 $sIn =
" '{$this->oxarticles__oxid->value}' ";
3972 if ($this->oxarticles__oxparentid->value) {
3975 $sIn .=
", '{$this->oxarticles__oxparentid->value}' ";
3976 $sParentIdForVariants = $this->oxarticles__oxparentid->value;
3979 $sParentIdForVariants = $this->
getId();
3984 $oRs = $oDb->select(
"select oxid from {$sArtTable} where oxparentid = " . $oDb->quote($sParentIdForVariants) .
" and oxid != " . $oDb->quote($this->oxarticles__oxid->value));
3985 if ($oRs !=
false && $oRs->recordCount() > 0) {
3986 while (!$oRs->EOF) {
3987 $sIn .=
", " . $oDb->quote(current($oRs->fields)) .
" ";
3992 $iLimit = (int) $this->
getConfig()->getConfigParam(
'iNrofCustomerWhoArticles');
3993 $iLimit = $iLimit ? ($iLimit * 10) : 50;
3996 $sQ =
"select distinct {$sArtTable}.* from (
3997 select d.oxorderid as suborderid from {$sOrderArtTable} as d use index ( oxartid ) where d.oxartid in ( {$sIn} ) limit {$iLimit}
3999 left join {$sOrderArtTable} force index ( oxorderid ) on suborder.suborderid = {$sOrderArtTable}.oxorderid
4000 left join {$sArtTable} on {$sArtTable}.oxid = {$sOrderArtTable}.oxartid
4001 where {$sArtTable}.oxid not in ( {$sIn} )
4002 and ( {$sArtTable}.oxissearch = 1 or {$sArtTable}.oxparentid <> '' ) and " . $this->
getSqlActiveSnippet();
4031 $sOXID = $oDb->quote($sOXID);
4032 $sCatId = $oDb->quote($sCatId);
4034 if (!$dPriceFromTo) {
4035 $sSelect =
"select oxobject2category.oxcatnid from $sO2CView as oxobject2category ";
4036 $sSelect .=
"left join $sCategoryView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
4037 $sSelect .=
"where oxobject2category.oxcatnid=$sCatId and oxobject2category.oxobjectid=$sOXID ";
4038 $sSelect .=
"and oxcategories.oxactive = 1 order by oxobject2category.oxtime ";
4040 $dPriceFromTo = $oDb->quote($dPriceFromTo);
4041 $sSelect =
"select oxcategories.oxid from $sCategoryView as oxcategories where ";
4042 $sSelect .=
"oxcategories.oxid=$sCatId and $dPriceFromTo >= oxcategories.oxpricefrom and ";
4043 $sSelect .=
"$dPriceFromTo <= oxcategories.oxpriceto ";
4056 if ($this->_oAmountPriceList === null) {
4057 $oAmPriceList =
oxNew(
'oxAmountPricelist');
4061 $oAmPriceList->load($this);
4065 foreach ($oAmPriceList as $oAmPrice) {
4066 if ($oAmPrice->oxprice2article__oxaddperc->value) {
4073 $this->_oAmountPriceList = $oAmPriceList;
4088 $mValue = $this->$sFieldName->value;
4090 if (is_null($mValue)) {
4094 if ($mValue ===
'') {
4099 $aZeroValueFields = array(
'oxarticles__oxprice',
'oxarticles__oxvat',
'oxarticles__oxunitquantity');
4101 if (!$mValue && in_array($sFieldName, $aZeroValueFields)) {
4106 if (!strcmp($mValue,
'0000-00-00 00:00:00') || !strcmp($mValue,
'0000-00-00')) {
4110 $sFieldName = strtolower($sFieldName);
4112 if ($sFieldName ==
'oxarticles__oxicon' && (strpos($mValue,
"nopic_ico.jpg") !==
false || strpos($mValue,
"nopic.jpg") !==
false)) {
4116 if (strpos($mValue,
"nopic.jpg") !==
false && ($sFieldName ==
'oxarticles__oxthumb' || substr($sFieldName, 0, 17) ==
'oxarticles__oxpic' || substr($sFieldName, 0, 18) ==
'oxarticles__oxzoom')) {
4139 if ($oParentArticle->$sCopyFieldName != null) {
4142 if (substr($sCopyFieldName, 0, 12) !=
'oxarticles__') {
4147 if (in_array($sCopyFieldName, $this->_aNonCopyParentFields)) {
4158 $this->$sCopyFieldName = clone $oParentArticle->$sCopyFieldName;
4172 $blIsImageField = (stristr($sFieldName,
'_oxthumb') || stristr($sFieldName,
'_oxicon') || stristr($sFieldName,
'_oxzoom') || stristr($sFieldName,
'_oxpic'));
4174 return $blIsImageField;
4182 startProfile(
'articleAssignParentInternal');
4183 if ($this->oxarticles__oxparentid->value) {
4185 if (!$this->
isAdmin() || ($this->_blLoadParentData && $this->
isAdmin())) {
4186 foreach ($this->_aFieldNames as $sFieldName => $sVal) {
4191 stopProfile(
'articleAssignParentInternal');
4199 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') &&
4200 ($this->_blHasVariants || $this->oxarticles__oxvarstock->value || $this->oxarticles__oxvarcount->value)
4202 $this->_blNotBuyableParent =
true;
4218 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts') && !$this->
isAdmin()) {
4219 $this->oxarticles__oxstock =
new oxField((
int) floor($this->oxarticles__oxstock->value));
4222 $this->_iStockStatus = 0;
4225 if (
$myConfig->getConfigParam(
'blUseStock') &&
4226 $this->oxarticles__oxstockflag->value != 4
4229 $iStock = $this->oxarticles__oxstock->value;
4231 if ($this->_blNotBuyableParent) {
4232 $iStock = $this->oxarticles__oxvarstock->value;
4236 if ($iStock <= $myConfig->getConfigParam(
'sStockWarningLimit') && $iStock > 0) {
4237 $this->_iStockStatus = 1;
4242 $this->_iStockStatus = -1;
4248 if (
$myConfig->getConfigParam(
'blUseStock') && ($this->oxarticles__oxstockflag->value == 3 || $this->oxarticles__oxstockflag->value == 2)) {
4249 $iOnStock = $this->oxarticles__oxstock->value;
4250 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
4251 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
4253 if ($iOnStock <= 0) {
4259 if ($this->_blNotBuyable && $this->oxarticles__oxvarstock->value) {
4262 $this->_blNotBuyableParent =
true;
4268 if (!
$myConfig->getConfigParam(
'blVariantParentBuyable') && !
$myConfig->getConfigParam(
'blLoadVariants') && $this->oxarticles__oxvarstock->value) {
4273 if (!$this->_blNotBuyable && $this->_blNotBuyableParent && $this->oxarticles__oxvarcount->value == 0) {
4285 if (isset($aPersParam) && isset($aPersParam[$this->
getId()])) {
4286 $this->_aPersistParam = $aPersParam[$this->
getId()];
4297 $sThisShop = $this->oxarticles__oxshopid->value;
4299 $this->_sDynImageDir =
$myConfig->getPictureUrl(null,
false);
4300 $this->dabsimagedir =
$myConfig->getPictureDir(
false);
4301 $this->nossl_dimagedir =
$myConfig->getPictureUrl(null,
false,
false, null, $sThisShop);
4302 $this->ssl_dimagedir =
$myConfig->getPictureUrl(null,
false,
true, null, $sThisShop);
4313 if (isset($aItems[$this->
getId()])) {
4314 $this->_blIsOnComparisonList =
true;
4328 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
4329 $this->oxarticles__oxinsert =
new oxField($sNow);
4330 if (!is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value ==
'') {
4331 $this->oxarticles__oxsubclass =
new oxField(
'oxarticle');
4373 $sOXID = $oDb->quote($sOXID);
4376 $sDelete =
'delete from oxobject2article where oxarticlenid = ' . $sOXID .
' or oxobjectid = ' . $sOXID .
' ';
4377 $oDb->execute($sDelete);
4379 $sDelete =
'delete from oxobject2attribute where oxobjectid = ' . $sOXID .
' ';
4380 $oDb->execute($sDelete);
4382 $sDelete =
'delete from oxobject2category where oxobjectid = ' . $sOXID .
' ';
4383 $oDb->execute($sDelete);
4385 $sDelete =
'delete from oxobject2selectlist where oxobjectid = ' . $sOXID .
' ';
4386 $oDb->execute($sDelete);
4388 $sDelete =
'delete from oxprice2article where oxartid = ' . $sOXID .
' ';
4389 $oDb->execute($sDelete);
4391 $sDelete =
'delete from oxreviews where oxtype="oxarticle" and oxobjectid = ' . $sOXID .
' ';
4392 $oDb->execute($sDelete);
4394 $sDelete =
'delete from oxratings where oxobjectid = ' . $sOXID .
' ';
4395 $rs = $oDb->execute($sDelete);
4397 $sDelete =
'delete from oxaccessoire2article where oxobjectid = ' . $sOXID .
' or oxarticlenid = ' . $sOXID .
' ';
4398 $oDb->execute($sDelete);
4401 $sDelete =
'delete from oxobject2delivery where oxobjectid = ' . $sOXID .
' and oxtype=\'oxarticles\' ';
4402 $oDb->execute($sDelete);
4404 $sDelete =
'delete from oxartextends where oxid = ' . $sOXID .
' ';
4405 $oDb->execute($sDelete);
4409 $oDb->execute(
"delete from $sSetTbl where oxid = {$sOXID}");
4412 $sDelete =
'delete from oxactions2article where oxartid = ' . $sOXID .
' ';
4413 $rs = $oDb->execute($sDelete);
4415 $sDelete =
'delete from oxobject2list where oxobjectid = ' . $sOXID .
' ';
4416 $rs = $oDb->execute($sDelete);
4432 $sQ =
'select oxid from ' . $this->
getViewName() .
' where oxparentid = ' . $oDb->quote($sOXID);
4433 $rs = $oDb->select($sQ,
false,
false);
4434 $oArticle =
oxNew(
"oxArticle");
4435 if ($rs !=
false && $rs->recordCount() > 0) {
4437 $oArticle->setId($rs->fields[0]);
4438 $oArticle->delete();
4455 $oPictureHandler->deleteMainIcon($this);
4458 $oPictureHandler->deleteThumbnail($this);
4460 $sAbsDynImageDir =
$myConfig->getPictureDir(
false);
4463 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
4464 for ($i = 1; $i <= $iPicCount; $i++) {
4465 $oPictureHandler->deleteArticleMasterPicture($this, $i);
4481 $myUtilsCount->resetVendorArticleCount($sVendorId);
4484 if ($sManufacturerId) {
4485 $myUtilsCount->resetManufacturerArticleCount($sManufacturerId);
4490 foreach ($aCategoryIds as $sCatId) {
4491 $myUtilsCount->resetCatArticleCount($sCatId,
false);
4504 $sParentIdQuoted = $oDb->quote($sParentID);
4505 $sQ =
'select oxstock, oxvendorid, oxmanufacturerid from oxarticles where oxid = ' . $sParentIdQuoted;
4506 $rs = $oDb->select($sQ,
false,
false);
4507 $iOldStock = $rs->fields[0];
4508 $iVendorID = $rs->fields[1];
4509 $iManufacturerID = $rs->fields[2];
4511 $sQ =
'select sum(oxstock) from ' . $this->
getViewName(
true) .
' where oxparentid = ' . $sParentIdQuoted .
' and ' . $this->
getSqlActiveSnippet(
true) .
' and oxstock > 0 ';
4512 $iStock = (float) $oDb->getOne($sQ,
false,
false);
4514 $sQ =
'update oxarticles set oxvarstock = ' . $iStock .
' where oxid = ' . $sParentIdQuoted;
4522 if ($iOldStock < 0) {
4525 if ($this->oxarticles__oxstockflag->value == 2 && $iOldStock xor $iStock) {
4542 if (
$myConfig->getConfigParam(
'blUseStock') && $this->oxarticles__oxstockflag->value == 2 &&
4543 ($this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value) <= 0
4546 $this->
_onChangeResetCounts($sOxid, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value);
4559 $sParentIdQuoted = $oDb->quote($sParentID);
4560 $sQ =
"select count(*) as varcount from oxarticles where oxparentid = {$sParentIdQuoted}";
4561 $iVarCount = (int) $oDb->getOne($sQ,
false,
false);
4563 $sQ =
"update oxarticles set oxvarcount = {$iVarCount} where oxid = {$sParentIdQuoted}";
4579 MIN( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varminprice`,
4580 MAX( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varmaxprice`
4581 FROM ' . $this->
getViewName(
true) .
' AS `oxarticles`
4582 LEFT JOIN ' . $this->
getViewName(
true) .
' AS `p` ON ( `p`.`oxid` = `oxarticles`.`oxparentid` AND `p`.`oxprice` > 0 )
4584 AND ( `oxarticles`.`oxparentid` = ' . $oDb->quote($sParentId) .
' )';
4586 $aPrices = $oDb->getRow($sQ,
false,
false);
4587 if (!is_null($aPrices[
'varminprice']) || !is_null($aPrices[
'varmaxprice'])) {
4591 `oxvarminprice` = ' . $oDb->quote($aPrices[
'varminprice']) .
',
4592 `oxvarmaxprice` = ' . $oDb->quote($aPrices[
'varmaxprice']) .
'
4594 `oxid` = ' . $oDb->quote($sParentId);
4599 `oxvarminprice` = `oxprice`,
4600 `oxvarmaxprice` = `oxprice`
4602 `oxid` = ' . $oDb->quote($sParentId);
4617 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
4619 if ($sPicName ==
"nopic.jpg" || $sPicName ==
"") {
4624 $this->
getParentArticle()->{
"oxarticles__oxpic" . $iIndex}->value == $this->{
"oxarticles__oxpic" . $iIndex}->value
4629 $sMasterPic =
'product/' . $iIndex .
"/" . $sPicName;
4631 if ($this->
getConfig()->getMasterPicturePath($sMasterPic)) {
4645 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
4648 $blResult = $oUser->isPriceViewModeNetto();
4664 $oPrice =
oxNew(
'oxPrice');
4666 if ($blCalculationModeNetto === null) {
4670 if ($blCalculationModeNetto) {
4671 $oPrice->setNettoPriceMode();
4673 $oPrice->setBruttoPriceMode();
4690 $dPrice = $oPrice->getNettoPrice();
4692 $dPrice = $oPrice->getBruttoPrice();
4708 protected function _preparePrice($dPrice, $dVat, $blCalculationModeNetto = null)
4710 if ($blCalculationModeNetto === null) {
4714 $oCurrency = $this->
getConfig()->getActShopCurrencyObject();
4716 $blEnterNetPrice = $this->
getConfig()->getConfigParam(
'blEnterNetPrice');
4717 if ($blCalculationModeNetto && !$blEnterNetPrice) {
4719 } elseif (!$blCalculationModeNetto && $blEnterNetPrice) {
4737 if ($oUser->inGroup(
'oxidpricea')) {
4738 $sPriceSuffix =
'a';
4739 } elseif ($oUser->inGroup(
'oxidpriceb')) {
4740 $sPriceSuffix =
'b';
4741 } elseif ($oUser->inGroup(
'oxidpricec')) {
4742 $sPriceSuffix =
'c';
4746 return $sPriceSuffix;
4758 if ($sPriceSuffix ===
'') {
4759 $dPrice = $this->oxarticles__oxprice->value;
4761 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4762 $dPrice = ($this->{oxarticles__oxprice . $sPriceSuffix}->value != 0) ? $this->{oxarticles__oxprice . $sPriceSuffix}->value : $this->oxarticles__oxprice->value;
4764 $dPrice = $this->{oxarticles__oxprice . $sPriceSuffix}->value;
4779 if ($this->_dVarMinPrice === null) {
4783 if (is_null($dPrice)) {
4785 if ($sPriceSuffix ===
'') {
4786 $dPrice = $this->oxarticles__oxvarminprice->value;
4789 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4790 $sSql .=
'MIN( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varminprice` ';
4792 $sSql .=
'MIN(`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4803 $this->_dVarMinPrice = $dPrice;
4818 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4821 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4822 $sSql .=
'MIN(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varminprice` ';
4824 $sSql .=
'MIN(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4826 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4827 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4829 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4830 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4844 if ($this->_dVarMaxPrice === null) {
4848 if (is_null($dPrice)) {
4850 if ($sPriceSuffix ===
'') {
4851 $dPrice = $this->oxarticles__oxvarmaxprice->value;
4854 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4855 $sSql .=
'MAX( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varmaxprice` ';
4857 $sSql .=
'MAX(`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4868 $this->_dVarMaxPrice = $dPrice;
4883 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4886 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4887 $sSql .=
'MAX(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varmaxprice` ';
4889 $sSql .=
'MAX(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4891 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4892 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4894 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4895 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4930 $sValue = isset($this->$sField->value) ? $this->$sField->value : 0;
4931 $sSqlSets[] =
'`' . str_replace(
'oxarticles__',
'', $sField) .
'` = ' . $oDb->quote($sValue);
4934 $sSql =
"UPDATE `oxarticles` SET ";
4935 $sSql .= implode(
', ', $sSqlSets) .
'';
4936 $sSql .=
" WHERE `oxparentid` = " . $oDb->quote($this->
getId());
4938 return $oDb->execute($sSql);
4960 $this->$sField =
new oxField($sParent->$sField->value);
4973 $aSortingFields = !empty($aSortingFields) ? (array) $aSortingFields : array();
4975 foreach ($aSortingFields as $sField) {
4977 $this->_aSortingFieldsOnLoad[$sFullField] = $this->$sFullField->value;