4 define(
'OXARTICLE_LINKTYPE_CATEGORY', 0);
5 define(
'OXARTICLE_LINKTYPE_VENDOR', 1);
6 define(
'OXARTICLE_LINKTYPE_MANUFACTURER', 2);
7 define(
'OXARTICLE_LINKTYPE_PRICECATEGORY', 3);
8 define(
'OXARTICLE_LINKTYPE_TAG', 4);
9 define(
'OXARTICLE_LINKTYPE_RECOMM', 5);
372 'oxarticles__oxtimestamp',
375 'oxarticles__oxparentid');
383 'oxarticles__oxfreeshipping',
384 'oxarticles__oxisdownloadable',
385 'oxarticles__oxshowcustomagreement');
455 if ($aParams && is_array($aParams)) {
456 foreach ($aParams as $sParam => $mValue) {
457 $this->$sParam = $mValue;
461 $this->
init(
'oxarticles');
480 return $this->$sName;
489 public function __set($sName, $sValue)
517 $this->oxarticles__oxnid = $this->oxarticles__oxid;
536 $sQ =
" $sTable.oxactive = 1 ";
539 if ($this->
getConfig()->getConfigParam(
'blUseTimeCheck')) {
540 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
541 $sQ =
"( $sQ or ( $sTable.oxactivefrom < '$sDate' and $sTable.oxactiveto > '$sDate' ) ) ";
568 if (
$myConfig->getConfigParam(
'blUseStock')) {
569 $sQ =
" and ( $sTable.oxstockflag != 2 or ( $sTable.oxstock + $sTable.oxvarstock ) > 0 ) ";
571 if (!
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
573 if (
$myConfig->getConfigParam(
'blUseTimeCheck')) {
574 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
575 $sTimeCheckQ =
" or ( art.oxactivefrom < '$sDate' and art.oxactiveto > '$sDate' )";
577 $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 ) ) ";
598 $sQ =
" and $sTable.oxparentid = '" . $this->
getId() .
"' ";
601 if ($this->
getConfig()->getConfigParam(
'blUseStock')) {
602 $sQ .=
" and ( $sTable.oxstock > 0 or ( $sTable.oxstock <= 0 and $sTable.oxstockflag != 2 ";
603 if ($blRemoveNotOrderables) {
604 $sQ .=
" and $sTable.oxstockflag != 3 ";
619 return $this->oxarticles__oxunitquantity->value;
629 $dSize = $this->oxarticles__oxlength->value *
630 $this->oxarticles__oxwidth->value *
631 $this->oxarticles__oxheight->value;
643 return $this->oxarticles__oxweight->value;
672 $this->_blSkipAssign = $blSkipAssign;
680 $this->_blLoadPrice =
false;
688 $this->_blLoadPrice =
true;
708 $this->_sItemKey = $sItemKey;
718 $this->_blLoadVariants = !$blLoadVariants;
728 if ($this->_blNotBuyableParent) {
762 $this->_blIsOnComparisonList = $blOnList;
772 $this->_blLoadParentData = $blLoadParentData;
795 switch ($sFieldName) {
812 if ($this->_fPricePerUnit == null) {
831 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
836 if ((
double) $this->
getUnitQuantity() && $this->oxarticles__oxunitname->value) {
887 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
898 $oPrice->setPrice($dPrice);
912 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
926 $oPrice->setPrice($dPrice);
939 if ($this->_blIsRangePrice === null) {
948 if ($dMinPrice != $dMaxPrice) {
969 return $this->_blIsRangePrice = $blIsRangePrice;
982 return $blCanPreview;
986 $sNow = date(
'Y-m-d H:i:s');
987 if (!$this->oxarticles__oxactive->value &&
988 ($this->oxarticles__oxactivefrom->value > $sNow ||
989 $this->oxarticles__oxactiveto->value < $sNow
996 if ($this->
getConfig()->getConfigParam(
'blUseStock') && $this->oxarticles__oxstockflag->value == 2) {
997 $iOnStock = $this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value;
998 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
999 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
1001 if ($iOnStock <= 0) {
1019 startProfile(
'articleAssign');
1024 $this->oxarticles__oxnid = $this->oxarticles__oxid;
1027 if ($this->_blSkipAssign) {
1041 stopProfile(
'articleAssign');
1058 $this->_blNotBuyableParent =
false;
1070 $this->_isLoaded =
true;
1086 $aSortingFields = !empty($aSortingFields) ? (array) $aSortingFields : array();
1088 foreach ($aSortingFields as $sField) {
1089 $sParameterName =
'oxarticles__' . $sField;
1090 if ($this->$sParameterName->value !== $this->_aSortingFieldsOnLoad[$sParameterName]) {
1107 $dOldRating = $this->oxarticles__oxrating->value;
1108 $dOldCnt = $this->oxarticles__oxratingcnt->value;
1109 $this->oxarticles__oxrating->setValue(($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1));
1110 $this->oxarticles__oxratingcnt->setValue($dOldCnt + 1);
1111 $dRating = ($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1);
1112 $dRatingCnt = (int) ($dOldCnt + 1);
1115 $oDb->execute(
'update oxarticles set oxarticles.oxrating = ' . $dRating .
',oxarticles.oxratingcnt = ' . $dRatingCnt .
', oxarticles.oxtimestamp = oxarticles.oxtimestamp where oxarticles.oxid = ' . $oDb->quote($this->getId()));
1126 $this->oxarticles__oxrating =
new oxField($iRating);
1136 $this->oxarticles__oxratingcnt =
new oxField($iRatingCnt);
1148 if (!$blIncludeVariants) {
1149 return round($this->oxarticles__oxrating->value, 1);
1151 $oRating =
oxNew(
'oxRating');
1166 if (!$blIncludeVariants) {
1167 return $this->oxarticles__oxratingcnt->value;
1169 $oRating =
oxNew(
'oxRating');
1183 $aIds = array($this->
getId());
1185 if ($this->oxarticles__oxparentid->value) {
1186 $aIds[] = $this->oxarticles__oxparentid->value;
1190 if ($this->
getConfig()->getConfigParam(
'blShowVariantReviews')) {
1192 if (is_array($aAdd)) {
1193 $aIds = array_merge($aIds, $aAdd);
1197 $oReview =
oxNew(
'oxreview');
1198 $oRevs = $oReview->loadList(
'oxarticle', $aIds);
1201 if ($oRevs->count() < 1) {
1215 $oCrosslist =
oxNew(
"oxarticlelist");
1216 $oCrosslist->loadArticleCrossSell($this->oxarticles__oxid->value);
1217 if ($oCrosslist->count()) {
1232 if (!
$myConfig->getConfigParam(
'bl_perfLoadAccessoires')) {
1236 $oAcclist =
oxNew(
"oxarticlelist");
1237 $oAcclist->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofCrossellArticles'));
1238 $oAcclist->loadArticleAccessoires($this->oxarticles__oxid->value);
1240 if ($oAcclist->count()) {
1254 if (!
$myConfig->getConfigParam(
'bl_perfLoadSimilar')) {
1270 if (count($aList)) {
1271 uasort($aList,
'cmpart');
1275 $oSimilarlist =
oxNew(
'oxarticlelist');
1276 $oSimilarlist->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofSimilarArticles'));
1277 $oSimilarlist->selectString($sSearch);
1279 return $oSimilarlist;
1292 if (!
$myConfig->getConfigParam(
'bl_perfLoadCustomerWhoBoughtThis')) {
1299 $oArticles =
oxNew(
'oxarticlelist');
1300 $oArticles->setSqlLimit(0,
$myConfig->getConfigParam(
'iNrofCustomerWhoArticles'));
1301 $oArticles->selectString($sQ);
1302 if ($oArticles->count()) {
1316 if (!
$myConfig->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice || !$this->_blCalcPrice || !$this->
hasAmountPrice()) {
1320 if ($this->_oAmountPriceInfo === null) {
1321 $this->_oAmountPriceInfo = array();
1341 $sKey = $this->
getId();
1342 if (isset($sKeyPrefix)) {
1343 $sKey = $sKeyPrefix .
'__' . $sKey;
1346 if (!isset(self::$_aSelList[$sKey])) {
1350 $sQ =
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid
1351 where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
1354 $oLists =
oxNew(
'oxlist');
1355 $oLists->init(
'oxselectlist');
1356 $oLists->selectString(sprintf($sQ, $oDb->quote($this->getId())));
1359 if ($oLists->count() == 0 && $this->oxarticles__oxparentid->value) {
1360 $oLists->selectString(sprintf($sQ, $oDb->quote($this->oxarticles__oxparentid->value)));
1370 self::$_aSelList[$sKey] = array();
1371 foreach ($oLists as $oSelectlist) {
1372 self::$_aSelList[$sKey][$iCnt] = $oSelectlist->getFieldList($dVat);
1373 self::$_aSelList[$sKey][$iCnt][
'name'] = $oSelectlist->oxselectlist__oxtitle->value;
1378 return self::$_aSelList[$sKey];
1388 return $this->oxarticles__oxvarcount->value;
1408 return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxnonmaterial->value && !$this->
hasDownloadableAgreement();
1418 return $this->oxarticles__oxshowcustomagreement->value && $this->oxarticles__oxisdownloadable->value;
1432 $iLimit = (int) $iLimit;
1433 if (!isset($this->_aVariantSelections[$iLimit])) {
1434 $aVariantSelections =
false;
1435 if ($this->oxarticles__oxvarcount->value) {
1437 $aVariantSelections =
oxNew(
"oxVariantHandler")->buildVariantSelections($this->oxarticles__oxvarname->getRawValue(), $oVariants, $aFilterIds, $sActVariantId, $iLimit);
1439 if (!empty($oVariants) && empty($aVariantSelections[
'rawselections'])) {
1440 $aVariantSelections =
false;
1443 $this->_aVariantSelections[$iLimit] = $aVariantSelections;
1446 return $this->_aVariantSelections[$iLimit];
1459 $sId = $this->
getId() . ((int) $iLimit);
1460 if (!array_key_exists($sId, self::$_aSelections)) {
1465 $sQ =
"select {$sSLViewName}.* from oxobject2selectlist join {$sSLViewName} on $sSLViewName.oxid=oxobject2selectlist.oxselnid
1466 where oxobject2selectlist.oxobjectid=%s order by oxobject2selectlist.oxsort";
1468 if (($iLimit = (
int) $iLimit)) {
1469 $sQ .=
" limit $iLimit ";
1474 if (($oPrice = $this->
getPrice()) != null) {
1475 $dVat = $oPrice->getVat();
1479 $oList =
oxNew(
'oxlist');
1480 $oList->init(
'oxselectlist');
1481 $oList->getBaseObject()->setVat($dVat);
1482 $oList->selectString(sprintf($sQ, $oDb->quote($this->getId())));
1485 if ($oList->count() == 0 && $this->oxarticles__oxparentid->value) {
1486 $oList->selectString(sprintf($sQ, $oDb->quote($this->oxarticles__oxparentid->value)));
1489 self::$_aSelections[$sId] = $oList->count() ? $oList :
false;
1492 if (self::$_aSelections[$sId]) {
1497 foreach (self::$_aSelections[$sId] as $oSelection) {
1498 if (isset($aFilter[$iSelIdx])) {
1499 $oSelection->setActiveSelectionByIndex($aFilter[$iSelIdx]);
1506 return self::$_aSelections[$sId];
1519 return $this->
_loadVariantList(
false, $blRemoveNotOrderables, $blForceCoreTable);
1531 public function getVariants($blRemoveNotOrderables =
true, $blForceCoreTable = null)
1543 if ($this->oxarticles__oxvarcount->value) {
1558 $oVariants =
oxNew(
'oxarticlelist');
1559 if (($sId = $this->
getId())) {
1561 $oBaseObj = $oVariants->getBaseObject();
1563 if (is_null($sLanguage)) {
1566 $oBaseObj->setLanguage($sLanguage);
1569 $sSql =
"select * from " . $oBaseObj->getViewName() .
" where oxparentid = '{$sId}' order by oxsort ";
1570 $oVariants->selectString($sSql);
1573 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') && ($oVariants->count() > 0)) {
1575 $this->_blNotBuyableParent =
true;
1591 $oCategory =
oxNew(
'oxcategory');
1595 $sOXID = $this->
getId();
1596 if (isset($this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
1597 $sOXID = $this->oxarticles__oxparentid->value;
1602 if (!isset($this->_aCategoryCache[$sOXID])) {
1603 startPRofile(
'getCategory');
1605 $sWhere = $oCategory->getSqlActiveSnippet();
1607 $sSelect .= ($oStr->strstr($sSelect,
'where') ?
' and ' :
' where ') . $sWhere .
" order by oxobject2category.oxtime limit 1";
1610 if (!$oCategory->assignRecord($sSelect)) {
1613 $sSelect .= ($oStr->strstr($sSelect,
'where') ?
' and ' :
' where ') . $sWhere .
" limit 1";
1616 if (!$oCategory->assignRecord($sSelect)) {
1621 $this->_aCategoryCache[$sOXID] = $oCategory;
1622 stopPRofile(
'getCategory');
1625 $oCategory = $this->_aCategoryCache[$sOXID];
1642 $sArticleId = $this->
getId();
1644 if (!isset(self::$_aArticleCats[$sArticleId]) || $blSkipCache) {
1652 self::$_aArticleCats[$sArticleId] = array_unique(array_merge($aCategoryIds, $aPriceCategoryIds));
1655 return self::$_aArticleCats[$sArticleId];
1670 $oVendor =
oxNew(
'oxvendor');
1671 } elseif (!$blShopCheck && $this->oxarticles__oxvendorid->value) {
1672 $oVendor =
oxNew(
'oxi18n');
1673 $oVendor->init(
'oxvendor');
1674 $oVendor->setReadOnly(
true);
1675 $sVendorId = $this->oxarticles__oxvendorid->value;
1677 if ($sVendorId && $oVendor->load($sVendorId) && $oVendor->oxvendor__oxactive->value) {
1695 if ($this->oxarticles__oxvendorid->value) {
1696 $sVendorId = $this->oxarticles__oxvendorid->value;
1712 $sManufacturerId =
false;
1713 if ($this->oxarticles__oxmanufacturerid->value) {
1715 $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
1719 return $sManufacturerId;
1733 $oManufacturer =
oxNew(
'oxmanufacturer');
1735 !$blShopCheck && $this->oxarticles__oxmanufacturerid->value
1737 $oManufacturer->setReadOnly(
true);
1738 $sManufacturerId = $this->oxarticles__oxmanufacturerid->value;
1741 if ($sManufacturerId && $oManufacturer->load($sManufacturerId)) {
1742 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadManufacturerTree')) {
1743 $oManufacturer->setReadOnly(
true);
1745 $oManufacturer = $oManufacturer->oxmanufacturers__oxactive->value ? $oManufacturer : null;
1747 $oManufacturer = null;
1750 return $oManufacturer;
1776 $sOXID = $this->
getId();
1777 if (isset($this->oxarticles__oxparentid->value) && $this->oxarticles__oxparentid->value) {
1778 $sOXID = $this->oxarticles__oxparentid->value;
1783 $sOXID = $oDb->getOne($sSelect);
1785 if (isset($sOXID) && $sOXID) {
1790 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') && $this->_blLoadPrice) {
1791 $dPriceFromTo = $this->
getPrice()->getBruttoPrice();
1792 if ($dPriceFromTo > 0) {
1794 $sOXID = $oDb->getOne($sSelect);
1796 if (isset($sOXID) && $sOXID) {
1812 if (!$this->
getConfig()->getConfigParam(
'bl_perfLoadPrice') || !$this->_blLoadPrice) {
1817 if ($this->_oTPrice !== null) {
1823 $dBasePrice = $this->oxarticles__oxtprice->value;
1826 $oPrice->setPrice($dBasePrice);
1839 if ($oPrice->getPrice() <= $oPrice2->getPrice()) {
1844 $this->_oTPrice = $oPrice;
1857 if ($this->_blSkipDiscounts !== null) {
1861 if ($this->oxarticles__oxskipdiscounts->value) {
1866 $this->_blSkipDiscounts =
false;
1872 $sSelect =
"select 1 from $sO2CView as $sO2CView left join {$sViewName} on {$sViewName}.oxid = $sO2CView.oxcatnid
1873 where $sO2CView.oxobjectid=" . $oDb->quote($this->
getId()) .
" and {$sViewName}.oxactive = 1 and {$sViewName}.oxskipdiscounts = '1' ";
1874 $this->_blSkipDiscounts = ($oDb->getOne($sSelect) == 1);
1887 $this->_oPrice = $oPrice;
1932 if ($dAmount != 1 || $this->_oPrice === null) {
1940 $oPrice->setPrice($dBasePrice);
1943 if (!$this->_blCalcPrice && $dAmount == 1) {
1944 return $this->_oPrice = $oPrice;
1948 if ($dAmount != 1) {
1952 $this->_oPrice = $oPrice;
1965 $this->_oUser = $oUser;
1975 if ($this->_oUser) {
1993 $oUser = $oBasket->getBasketUser();
1996 $oBasketPrice = $this->
_getPriceObject($oBasket->isCalculationModeNetto());
2007 $oBasketPrice->setPrice($dBasePrice);
2009 $dVat =
oxRegistry::get(
"oxVatSelector")->getBasketItemVat($this, $oBasket);
2013 return $oBasketPrice;
2024 public function delete($sOXID = null)
2027 $sOXID = $this->
getId();
2037 $this->
load($sOXID);
2039 $this->
_onChangeResetCounts($sOXID, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value);
2048 $this->
onChange(ACTION_DELETE, $sOXID, $this->oxarticles__oxparentid->value);
2065 $iStockCount = $this->oxarticles__oxstock->value - $dAmount;
2066 if (!$blAllowNegativeStock && ($iStockCount < 0)) {
2067 $dAmount += $iStockCount;
2070 $this->oxarticles__oxstock =
new oxField($iStockCount);
2073 $oDb->execute(
'update oxarticles set oxarticles.oxstock = ' . $oDb->quote($iStockCount) .
' where oxarticles.oxid = ' . $oDb->quote($this->
getId()));
2074 $this->
onChange(ACTION_UPDATE_STOCK);
2094 if (!$this->oxarticles__oxparentid->value) {
2096 $dAmount = (double) $dAmount;
2098 $rs = $oDb->execute(
"update oxarticles set oxarticles.oxsoldamount = oxarticles.oxsoldamount + $dAmount where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2099 } elseif ($this->oxarticles__oxparentid->value) {
2102 if ($oUpdateArticle) {
2103 $oUpdateArticle->updateSoldAmount($dAmount);
2119 return $oDb->execute(
"update oxarticles set oxarticles.oxremindactive = 2 where oxarticles.oxid = " . $oDb->quote($this->oxarticles__oxid->value));
2131 if (($blRet = parent::save())) {
2144 $sParentId = $this->oxarticles__oxparentid->value;
2146 $this->_blAllowEmptyParentId =
true;
2148 $this->_blAllowEmptyParentId =
false;
2150 if ($sParentId !==
'') {
2151 $this->
onChange(ACTION_UPDATE, null, $sParentId);
2168 $aArtPics = array();
2169 $aArtIcons = array();
2179 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
2180 $blCheckActivePicId =
true;
2182 for ($i = 1; $i <= $iPicCount; $i++) {
2185 if (!$oStr->strstr($sIcoVal,
'nopic_ico.jpg') && !$oStr->strstr($sIcoVal,
'nopic.jpg') &&
2186 !$oStr->strstr($sPicVal,
'nopic_ico.jpg') && !$oStr->strstr($sPicVal,
'nopic.jpg')
2191 $aArtIcons[$i] = $sIcoVal;
2192 $aArtPics[$i] = $sPicVal;
2195 if ($iActPicId == $i) {
2196 $sActPic = $sPicVal;
2197 $blCheckActivePicId =
false;
2200 } elseif ($blCheckActivePicId && $iActPicId <= $i) {
2208 $aZoomPics = array();
2209 $iZoomPicCount =
$myConfig->getConfigParam(
'iPicCount');
2211 for ($j = 1, $c = 1; $j <= $iZoomPicCount; $j++) {
2214 if ($sVal && !$oStr->strstr($sVal,
'nopic.jpg')) {
2216 $aZoomPics[$c][
'id'] = $c;
2217 $aZoomPics[$c][
'file'] = $sVal;
2220 $aZoomPics[$c][
'file'] =
"nopic.jpg";
2226 $aPicGallery = array(
'ActPicID' => $iActPicId,
2227 'ActPic' => $sActPic,
2228 'MorePics' => $blMorePic,
2229 'Pics' => $aArtPics,
2230 'Icons' => $aArtIcons,
2231 'ZoomPic' => $blZoomPic,
2232 'ZoomPics' => $aZoomPics);
2234 return $aPicGallery;
2250 public function onChange($sAction = null, $sOXID = null, $sParentID = null)
2254 if (!isset($sOXID)) {
2255 if ($this->
getId()) {
2256 $sOXID = $this->
getId();
2258 if (!isset ($sOXID)) {
2259 $sOXID = $this->oxarticles__oxid->value;
2261 if ($this->oxarticles__oxparentid->value) {
2262 $sParentID = $this->oxarticles__oxparentid->value;
2265 if (!isset($sOXID)) {
2270 if (
$myConfig->getConfigParam(
'blUseStock')) {
2273 if (!isset($sParentID)) {
2275 $sQ =
'select oxparentid from oxarticles where oxid = ' . $oDb->quote($sOXID);
2276 $sParentID = $oDb->getOne($sQ);
2289 $sId = ($sParentID) ? $sParentID : $sOXID;
2296 if ($sAction === ACTION_UPDATE_STOCK) {
2311 if (isset($this->oxarticles__oxvat->value)) {
2312 return $this->oxarticles__oxvat->value;
2327 if (!
$myConfig->getConfigParam(
'blUseStock')) {
2333 $sQ =
'select oxstock, oxstockflag from oxarticles where oxid = ' . $oDb->quote($this->
getId());
2334 $rs = $oDb->select($sQ);
2338 if ($rs !==
false && $rs->recordCount() > 0) {
2339 $iOnStock = $rs->fields[
'oxstock'] - $dArtStockAmount;
2340 $iStockFlag = $rs->fields[
'oxstockflag'];
2343 if ($iStockFlag == 1 || $iStockFlag == 4) {
2346 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts')) {
2347 $iOnStock = floor($iOnStock);
2350 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
2351 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
2353 if ($iOnStock >= $dAmount) {
2356 if ($iOnStock > 0) {
2359 $oEx =
oxNew(
'oxArticleInputException');
2360 $oEx->setMessage(
'ERROR_MESSAGE_ARTICLE_ARTICLE_NOT_BUYABLE');
2376 if ($this->_oLongDesc === null) {
2378 $this->_oLongDesc =
new oxField();
2382 $sOxid = $this->
getId();
2386 $sDbValue = $oDb->getOne(
"select oxlongdesc from {$sViewName} where oxid = " . $oDb->quote($sOxid));
2388 if ($sDbValue !=
false) {
2390 } elseif ($this->oxarticles__oxparentid->value) {
2391 if (!$this->
isAdmin() || $this->_blLoadParentData) {
2394 $this->_oLongDesc->setValue($oParent->getLongDescription()->getRawValue(),
oxField::T_RAW);
2436 if ($this->_oAttributeList === null) {
2437 $this->_oAttributeList =
oxNew(
'oxattributelist');
2438 $this->_oAttributeList->loadAttributes($this->
getId(), $this->
getParentId());
2451 if ($this->_oAttributeList === null) {
2452 $this->_oAttributeList =
oxNew(
'oxattributelist');
2453 $this->_oAttributeList->loadAttributesDisplayableInBasket($this->
getId(), $this->
getParentId());
2469 if ($iLang === null) {
2473 $this->_aSeoAddParams[$iLang] = isset($this->_aSeoAddParams[$iLang]) ? $this->_aSeoAddParams[$iLang] .
"&" :
"";
2474 $this->_aSeoAddParams[$iLang] .= $sAddParams;
2491 return $oEncoder->getArticleUrl($this, $iLang, $this->
getLinkType());
2494 return $oEncoder->getArticleMainUrl($this, $iLang);
2505 public function getLink($iLang = null, $blMain =
false)
2511 if ($iLang === null) {
2516 if (!isset($this->_aSeoUrls[$iLang][$iLinkType])) {
2517 $this->_aSeoUrls[$iLang][$iLinkType] = $this->
getBaseSeoLink($iLang, $blMain);
2520 $sUrl = $this->_aSeoUrls[$iLang][$iLinkType];
2521 if (isset($this->_aSeoAddParams[$iLang])) {
2522 $sUrl .= ((strpos($sUrl . $this->_aSeoAddParams[$iLang],
'?') ===
false) ?
'?' :
'&') . $this->_aSeoAddParams[$iLang];
2538 return $this->
getLink($iLang,
true);
2549 $this->_sDetailLink = null;
2552 $this->_iLinkType = (int) $iType;
2574 if ($iLang === null) {
2578 $this->_aStdAddParams[$iLang] = isset($this->_aStdAddParams[$iLang]) ? $this->_aStdAddParams[$iLang] .
"&" :
"";
2579 $this->_aStdAddParams[$iLang] .= $sAddParams;
2597 $sUrl = $this->
getConfig()->getShopUrl($iLang,
false);
2600 $sUrl .=
"index.php?cl=details" . ($blAddId ?
"&anid=" . $this->
getId() :
"");
2602 return $sUrl . (isset($this->_aStdAddParams[$iLang]) ?
"&" . $this->_aStdAddParams[$iLang] :
"");
2615 if ($iLang === null) {
2619 if (!isset($this->_aStdUrls[$iLang])) {
2623 return oxRegistry::get(
"oxUtilsUrl")->processUrl($this->_aStdUrls[$iLang],
true, $aParams, $iLang);
2633 if ($this->_aMediaUrls === null) {
2634 $this->_aMediaUrls =
oxNew(
"oxlist");
2635 $this->_aMediaUrls->init(
"oxmediaurl");
2636 $this->_aMediaUrls->getBaseObject()->setLanguage($this->
getLanguage());
2639 $sQ =
"select * from {$sViewName} where oxobjectid = '" . $this->
getId() .
"'";
2640 $this->_aMediaUrls->selectString($sQ);
2663 if ($this->_aDispSelList === null) {
2664 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists') && $this->
getConfig()->getConfigParam(
'bl_perfLoadSelectListsInAList')) {
2679 if ($this->_sMoreDetailLink == null) {
2682 $this->_sMoreDetailLink = $this->
getConfig()->getShopHomeURL() .
'cl=moredetails';
2686 $this->_sMoreDetailLink .=
'&cnid=' . $sActCat;
2688 $this->_sMoreDetailLink .=
'&anid=' . $this->
getId();
2702 if ($this->_sToBasketLink == null) {
2706 $this->_sToBasketLink = $this->
getLink();
2709 $this->_sToBasketLink =
$myConfig->getShopHomeURL();
2713 if ($sActClass ==
'thankyou') {
2714 $sActClass =
'basket';
2716 $this->_sToBasketLink .=
'cl=' . $sActClass;
2720 $this->_sToBasketLink .=
'&cnid=' . $sActCat;
2723 $this->_sToBasketLink .=
'&fnc=tobasket&aid=' . $this->
getId() .
'&anid=' . $this->
getId();
2726 $this->_sToBasketLink .=
'&tpl=' . $sTpl;
2751 if ($this->oxarticles__oxdelivery->value !=
'0000-00-00') {
2752 return oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxarticles__oxdelivery->value);
2797 if ($this->oxarticles__oxremindactive->value == 2 &&
2798 $this->oxarticles__oxremindamount->value <= $this->oxarticles__oxstock->value
2800 $this->oxarticles__oxremindactive->value = 1;
2845 $this->_blNotBuyable = !$blBuyable;
2855 $this->_aDispSelList = $aSelList;
2870 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2873 $sSize = $this->
getConfig()->getConfigParam(
'aDetailImageSizes');
2875 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2890 $sDirname =
"product/1/";
2891 if ($iIndex && !$this->
_isFieldEmpty(
"oxarticles__oxpic{$iIndex}")) {
2892 $sImgName = basename($this->{
"oxarticles__oxpic$iIndex"}->value);
2893 $sDirname =
"product/{$iIndex}/";
2895 $sImgName = basename($this->oxarticles__oxicon->value);
2896 $sDirname =
"product/icon/";
2898 $sImgName = basename($this->oxarticles__oxpic1->value);
2901 $sSize = $this->
getConfig()->getConfigParam(
'sIconsize');
2903 $sIconUrl =
oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, $iIndex);
2918 $sDirname =
"product/1/";
2920 $sImgName = basename($this->oxarticles__oxthumb->value);
2921 $sDirname =
"product/thumb/";
2923 $sImgName = basename($this->oxarticles__oxpic1->value);
2926 $sSize = $this->
getConfig()->getConfigParam(
'sThumbnailsize');
2928 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl($sDirname, $sImgName, $sSize, 0, $bSsl);
2940 $iIndex = (int) $iIndex;
2941 if ($iIndex > 0 && !$this->
_isFieldEmpty(
"oxarticles__oxpic" . $iIndex)) {
2942 $sImgName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
2943 $sSize = $this->
getConfig()->getConfigParam(
"sZoomImageSize");
2945 return oxRegistry::get(
"oxPictureHandler")->getProductPicUrl(
"product/{$iIndex}/", $sImgName, $sSize,
'oxpic' . $iIndex);
2969 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
2972 foreach ($aDiscounts as $oDiscount) {
2973 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
2975 $oPrice->calculateDiscount();
2986 if (($sParentId = $this->oxarticles__oxparentid->value)) {
2987 $sIndex = $sParentId .
"_" . $this->
getLanguage();
2988 if (!isset(self::$_aLoadedParents[$sIndex])) {
2989 self::$_aLoadedParents[$sIndex] =
oxNew(
'oxarticle');
2990 self::$_aLoadedParents[$sIndex]->_blLoadPrice =
false;
2991 self::$_aLoadedParents[$sIndex]->_blLoadVariants =
false;
2995 self::$_aLoadedParents[$sIndex] =
false;
2999 return self::$_aLoadedParents[$sIndex];
3011 $sOxId = $oDb->quote($this->
getId());
3012 $sOxShopId = $oDb->quote($this->
getShopId());
3013 $iRemindActive = $oDb->quote($this->oxarticles__oxremindactive->value);
3016 set oxremindactive = $iRemindActive
3017 where oxparentid = $sOxId and
3018 oxshopid = $sOxShopId
3020 $oDb->execute($sUpdate);
3032 return $this->
getId();
3042 return $this->oxarticles__oxparentid->value;
3062 return (
bool) (isset($this->oxarticles__oxparentid) ? $this->oxarticles__oxparentid->value :
false);
3072 $oMdVariant =
oxNew(
"oxVariantHandler");
3074 return $oMdVariant->isMdVariant($this);
3089 $sSelectWhere =
"select $sFields from " . $this->
_getObjectViewName(
'oxcategories') .
" where";
3090 $sQuotedPrice =
oxDb::getDb()->quote($this->oxarticles__oxprice->value);
3092 return "$sSelectWhere oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice"
3093 .
" union $sSelectWhere oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice"
3094 .
" union $sSelectWhere oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice";
3108 $sQuotedPrice = $oDb->quote($this->oxarticles__oxprice->value);
3109 $sQuotedCnid = $oDb->quote($sCatNid);
3111 return (
bool) $oDb->getOne(
3112 "select 1 from " . $this->
_getObjectViewName(
'oxcategories') .
" where oxid=$sQuotedCnid and"
3113 .
"( (oxpricefrom != 0 and oxpriceto != 0 and oxpricefrom <= $sQuotedPrice and oxpriceto >= $sQuotedPrice)"
3114 .
" or (oxpricefrom != 0 and oxpriceto = 0 and oxpricefrom <= $sQuotedPrice)"
3115 .
" or (oxpricefrom = 0 and oxpriceto != 0 and oxpriceto >= $sQuotedPrice)"
3127 if ($this->_oMdVariants) {
3132 if ($oParentArticle) {
3133 $oVariants = $oParentArticle->getVariants();
3138 $oVariantHandler =
oxNew(
"oxVariantHandler");
3139 $this->_oMdVariants = $oVariantHandler->buildMdVariants($oVariants, $this->
getId());
3165 $sFieldName =
"oxarticles__" . $sFieldName . $iIndex;
3167 return $this->$sFieldName->value;
3181 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
3183 if ($sPicName && $sPicName !=
"nopic.jpg") {
3184 $sPicUrl = $this->
getConfig()->getPictureUrl(
"master/product/" . $iIndex .
"/" . $sPicName);
3185 if (!$sPicUrl || basename($sPicUrl) ==
"nopic.jpg") {
3200 if ($this->oxarticles__oxunitname->value) {
3214 if ($this->_aArticleFiles === null) {
3216 $this->_aArticleFiles =
false;
3218 $sQ =
"SELECT * FROM `oxfiles` WHERE `oxartid` = '" . $this->
getId() .
"'";
3220 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') && $blAddFromParent) {
3221 $sQ .=
" OR `oxartId` = '" . $this->oxarticles__oxparentid->value .
"'";
3224 $oArticleFiles =
oxNew(
"oxlist");
3225 $oArticleFiles->init(
"oxfile");
3226 $oArticleFiles->selectString($sQ);
3227 $this->_aArticleFiles = $oArticleFiles;
3241 return $this->oxarticles__oxisdownloadable->value;
3251 if (self::$_blHasAmountPrice === null) {
3253 self::$_blHasAmountPrice =
false;
3256 $sQ =
"SELECT 1 FROM `oxprice2article` LIMIT 1";
3258 if ($oDb->getOne($sQ)) {
3259 self::$_blHasAmountPrice =
true;
3275 protected function _loadVariantList($blSimple, $blRemoveNotOrderables =
true, $blForceCoreTable = null)
3277 $oVariants = array();
3278 if (($sId = $this->
getId())) {
3280 self::$_aLoadedParents[$sId .
"_" . $this->
getLanguage()] = $this;
3284 if (!$this->_blLoadVariants ||
3286 (!$this->
isAdmin() && !$this->oxarticles__oxvarcount->value)
3292 $sCacheKey = $blSimple ?
"simple" :
"full";
3293 if ($blRemoveNotOrderables) {
3294 if (isset($this->_aVariants[$sCacheKey])) {
3295 return $this->_aVariants[$sCacheKey];
3297 $this->_aVariants[$sCacheKey] = & $oVariants;
3299 } elseif (!$blRemoveNotOrderables) {
3300 if (isset($this->_aVariantsWithNotOrderables[$sCacheKey])) {
3301 return $this->_aVariantsWithNotOrderables[$sCacheKey];
3303 $this->_aVariantsWithNotOrderables[$sCacheKey] = & $oVariants;
3307 if (($this->_blHasVariants = $this->
_hasAnyVariant($blForceCoreTable))) {
3311 $oVariants =
oxNew(
'oxsimplevariantlist');
3312 $oVariants->setParent($this);
3315 $oVariants =
oxNew(
'oxarticlelist');
3316 $oVariants->getBaseObject()->modifyCacheKey(
'_variants');
3319 startProfile(
"selectVariants");
3320 $blUseCoreTable = (bool) $blForceCoreTable;
3321 $oBaseObject = $oVariants->getBaseObject();
3325 $sArticleTable = $this->
getViewName($blUseCoreTable);
3327 $sSelect =
"select " . $oBaseObject->getSelectFields($blUseCoreTable) .
" from $sArticleTable where " .
3330 " order by $sArticleTable.oxsort";
3331 $oVariants->selectString($sSelect);
3334 if (
$myConfig->getConfigParam(
'blUseMultidimensionVariants')) {
3335 $oMdVariants =
oxNew(
"oxVariantHandler");
3336 $this->_blHasMdVariants = $oMdVariants->isMdVariant($oVariants->current());
3338 stopProfile(
"selectVariants");
3343 $this->_blNotBuyableParent =
true;
3348 $this->_blNotBuyable =
true;
3366 $aResult = $oDb->getAll($sSql);
3370 foreach ($aResult as $aValue) {
3371 $aValue = array_change_key_case($aValue, CASE_LOWER);
3374 $aReturn[] = $aValue[$sField];
3392 $sArticleIdSql =
'oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getId());
3394 $sArticleIdSql =
'(' . $sArticleIdSql .
' or oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($this->
getParentId()) .
')';
3399 oxobject2category.oxcatnid as oxcatnid
3400 from $sO2CView as oxobject2category
3401 left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid
3402 where $sArticleIdSql and oxcategories.oxid is not null and oxcategories.oxactive = 1 $sActiveCategorySql
3403 order by oxobject2category.oxtime";
3416 $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 ";
3418 return $sActiveCategorySql;
3435 $sSelect =
"select oxobject2category.oxcatnid as oxcatnid from $sO2CView as oxobject2category left join $sCatView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
3436 $sSelect .=
'where oxobject2category.oxobjectid=' .
oxDb::getDb()->quote($sOXID) .
' and oxcategories.oxid is not null and oxcategories.oxactive = 1 ';
3438 $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 ";
3440 $sSelect .=
'order by oxobject2category.oxtime ';
3456 if (isset($dVat) || !$this->
getConfig()->getConfigParam(
'bl_perfCalcVatOnlyForBasketOrder')) {
3465 $aDiscounts = $oDiscountList->getArticleDiscounts($this, $this->
getArticleUser());
3468 foreach ($aDiscounts as $oDiscount) {
3469 $oPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
3471 $oPrice->calculateDiscount();
3487 if (($sId = $this->
getId())) {
3488 if ($this->oxarticles__oxshopid->value == $this->getConfig()->getShopId()) {
3489 $blHas = (bool) $this->oxarticles__oxvarcount->value;
3491 $sArticleTable = $this->
getViewName($blForceCoreTable);
3492 $blHas = (bool)
oxDb::getDb()->getOne(
"select 1 from $sArticleTable where oxparentid='{$sId}'");
3516 return $this->
_isStockStatusChanged() && ($this->_iStockStatus == -1 || $this->_iStockStatusOnLoad == -1);
3528 if (in_array(
"oxlongdesc", $this->_aSkipSaveFields)) {
3532 if ($this->_blEmployMultilanguage) {
3534 if ($sValue !== null) {
3535 $oArtExt =
oxNew(
'oxI18n');
3536 $oArtExt->init(
'oxartextends');
3537 $oArtExt->setLanguage((
int) $this->
getLanguage());
3538 if (!$oArtExt->load($this->getId())) {
3539 $oArtExt->setId($this->
getId());
3545 $oArtExt =
oxNew(
'oxI18n');
3546 $oArtExt->setEnableMultilang(
false);
3547 $oArtExt->init(
'oxartextends');
3548 $aObjFields = $oArtExt->_getAllFields(
true);
3549 if (!$oArtExt->load($this->getId())) {
3550 $oArtExt->setId($this->
getId());
3553 foreach ($aObjFields as $sKey => $sValue) {
3554 if (preg_match(
'/^oxlongdesc(_(\d{1,2}))?$/', $sKey)) {
3557 if (isset($this->$sField)) {
3559 if ($this->$sField instanceof
oxField) {
3560 $sLongDesc = $this->$sField->getRawValue();
3561 } elseif (is_object($this->$sField)) {
3562 $sLongDesc = $this->$sField->value;
3564 if (isset($sLongDesc)) {
3565 $sAEField = $oArtExt->_getFieldLongName($sKey);
3582 $this->_aSkipSaveFields = array();
3584 $this->_aSkipSaveFields[] =
'oxtimestamp';
3586 $this->_aSkipSaveFields[] =
'oxinsert';
3589 if (!$this->_blAllowEmptyParentId && (!isset($this->oxarticles__oxparentid->value) || $this->oxarticles__oxparentid->value ==
'')) {
3590 $this->_aSkipSaveFields[] =
'oxparentid';
3606 foreach ($aItemDiscounts as $sKey => $oDiscount) {
3608 if (array_key_exists($sKey, $aDiscounts)) {
3609 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
3611 $aDiscounts[$sKey] = $oDiscount;
3626 $sVarName =
"oxarticles__oxprice{$sPriceSufix}";
3627 $dPrice = $this->$sVarName->value;
3630 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices') && (
double) $dPrice == 0) {
3631 $dPrice = $this->oxarticles__oxprice->value;
3647 startProfile(
"_getAmountPrice");
3651 foreach ($oAmtPrices as $oAmPrice) {
3652 if ($oAmPrice->oxprice2article__oxamount->value <= $dAmount
3653 && $dAmount <= $oAmPrice->oxprice2article__oxamountto->value
3654 && $dPrice > $oAmPrice->oxprice2article__oxaddabs->value
3656 $dPrice = $oAmPrice->oxprice2article__oxaddabs->value;
3660 stopProfile(
"_getAmountPrice");
3677 if (
$myConfig->getConfigParam(
'bl_perfLoadSelectLists') &&
$myConfig->getConfigParam(
'bl_perfUseSelectlistPrice')) {
3681 foreach ($aSelLists as $key => $aSel) {
3682 if (isset($aChosenList[$key]) && isset($aSel[$aChosenList[$key]])) {
3683 $oSel = $aSel[$aChosenList[$key]];
3684 if ($oSel->priceUnit ==
'abs') {
3685 $dPrice += $oSel->price;
3686 } elseif ($oSel->priceUnit ==
'%') {
3708 foreach ($aAmPriceList as $sId => $oItem) {
3711 if ($oItem->oxprice2article__oxaddabs->value) {
3713 $dBasePrice = $oItem->oxprice2article__oxaddabs->value;
3716 $oItemPrice->setPrice($dBasePrice);
3722 $oItemPrice->setPrice($dBasePrice);
3723 $oItemPrice->subtractPercent($oItem->oxprice2article__oxaddperc->value);
3727 $aAmPriceList[$sId]->fbrutprice = $oLang->formatCurrency($this->
_getPriceForView($oItemPrice));
3730 return $aAmPriceList;
3743 $sId = $this->
getId();
3745 $sActiveSqlSnippet =
"";
3746 if ($blActiveVariants) {
3750 $sQ =
"select oxid from " . $this->
getViewName(
true) .
" where oxparentid = " . $oDb->quote($sId) .
3751 $sActiveSqlSnippet .
" order by oxsort";
3752 $oRs = $oDb->select($sQ);
3753 if ($oRs !=
false && $oRs->recordCount() > 0) {
3754 while (!$oRs->EOF) {
3755 $aSelect[] = reset($oRs->fields);
3785 if (!isset($this->_dArticleVat)) {
3786 $this->_dArticleVat =
oxRegistry::get(
"oxVatSelector")->getArticleVat($this);
3800 startProfile(__FUNCTION__);
3801 $oPrice->setVAT($dVat);
3804 if (($dVat = $oVatSelector->getArticleUserVat($this)) !==
false) {
3807 stopProfile(__FUNCTION__);
3819 $oCur = $this->
getConfig()->getActShopCurrencyObject();
3836 $sSelect =
'select oxattrid from oxobject2attribute where oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getId());
3838 $sSelect .=
' OR oxobject2attribute.oxobjectid=' . $oDb->quote($this->
getParentId());
3840 $sAttributeSql =
'';
3841 $aAttributeIds = $oDb->getCol($sSelect);
3842 if (is_array($aAttributeIds) && count($aAttributeIds)) {
3843 $aAttributeIds = array_unique($aAttributeIds);
3844 $iCnt = count($aAttributeIds);
3845 $sAttributeSql .=
't1.oxattrid IN ( ' . implode(
',', $oDb->quoteArray($aAttributeIds)) .
') ';
3860 $iAttrPercent = $this->
getConfig()->getConfigParam(
'iAttributesPercent') / 100;
3862 if (!$iAttrPercent || $iAttrPercent < 0 || $iAttrPercent > 1) {
3863 $iAttrPercent = 0.70;
3866 $iHitMin = ceil($iCnt * $iAttrPercent);
3868 $aExcludeIds = array();
3869 $aExcludeIds[] = $this->
getId();
3875 $sSelect =
"select oxobjectid from oxobject2attribute as t1 where
3877 and t1.oxobjectid NOT IN (" . implode(
', ',
oxDb::getDb()->quoteArray($aExcludeIds)) .
")
3878 group by t1.oxobjectid having count(*) >= $iHitMin LIMIT 0, 20";
3894 $aList = array_slice($aList, 0, $this->
getConfig()->getConfigParam(
'iNrofSimilarArticles'));
3896 $sSearch =
"select $sFieldList from $sArticleTable where " . $this->
getSqlActiveSnippet() .
" and $sArticleTable.oxissearch = 1 and $sArticleTable.oxid in ( ";
3898 $sSearch .= implode(
',',
oxdb::getDb()->quoteArray($aList)) .
')';
3901 $sSearch .=
' order by rand() ';
3921 if (!$blSearchPriceCat) {
3922 $sSelect =
"select {$sCatView}.* from {$sO2CView} as oxobject2category left join {$sCatView} on
3923 {$sCatView}.oxid = oxobject2category.oxcatnid
3924 where oxobject2category.oxobjectid=" .
oxDb::getDb()->quote($sOXID) .
" and {$sCatView}.oxid is not null ";
3926 $sSelect =
"select {$sCatView}.* from {$sCatView} where
3927 '{$this->oxarticles__oxprice->value}' >= {$sCatView}.oxpricefrom and
3928 '{$this->oxarticles__oxprice->value}' <= {$sCatView}.oxpriceto ";
3945 $sIn =
" '{$this->oxarticles__oxid->value}' ";
3946 if ($this->oxarticles__oxparentid->value) {
3949 $sIn .=
", '{$this->oxarticles__oxparentid->value}' ";
3950 $sParentIdForVariants = $this->oxarticles__oxparentid->value;
3953 $sParentIdForVariants = $this->
getId();
3958 $oRs = $oDb->select(
"select oxid from {$sArtTable} where oxparentid = " . $oDb->quote($sParentIdForVariants) .
" and oxid != " . $oDb->quote($this->oxarticles__oxid->value));
3959 if ($oRs !=
false && $oRs->recordCount() > 0) {
3960 while (!$oRs->EOF) {
3961 $sIn .=
", " . $oDb->quote(current($oRs->fields)) .
" ";
3966 $iLimit = (int) $this->
getConfig()->getConfigParam(
'iNrofCustomerWhoArticles');
3967 $iLimit = $iLimit ? ($iLimit * 10) : 50;
3970 $sQ =
"select distinct {$sArtTable}.* from (
3971 select d.oxorderid as suborderid from {$sOrderArtTable} as d use index ( oxartid ) where d.oxartid in ( {$sIn} ) limit {$iLimit}
3973 left join {$sOrderArtTable} force index ( oxorderid ) on suborder.suborderid = {$sOrderArtTable}.oxorderid
3974 left join {$sArtTable} on {$sArtTable}.oxid = {$sOrderArtTable}.oxartid
3975 where {$sArtTable}.oxid not in ( {$sIn} )
3976 and ( {$sArtTable}.oxissearch = 1 or {$sArtTable}.oxparentid <> '' ) and " . $this->
getSqlActiveSnippet();
4005 $sOXID = $oDb->quote($sOXID);
4006 $sCatId = $oDb->quote($sCatId);
4008 if (!$dPriceFromTo) {
4009 $sSelect =
"select oxobject2category.oxcatnid from $sO2CView as oxobject2category ";
4010 $sSelect .=
"left join $sCategoryView as oxcategories on oxcategories.oxid = oxobject2category.oxcatnid ";
4011 $sSelect .=
"where oxobject2category.oxcatnid=$sCatId and oxobject2category.oxobjectid=$sOXID ";
4012 $sSelect .=
"and oxcategories.oxactive = 1 order by oxobject2category.oxtime ";
4014 $dPriceFromTo = $oDb->quote($dPriceFromTo);
4015 $sSelect =
"select oxcategories.oxid from $sCategoryView as oxcategories where ";
4016 $sSelect .=
"oxcategories.oxid=$sCatId and $dPriceFromTo >= oxcategories.oxpricefrom and ";
4017 $sSelect .=
"$dPriceFromTo <= oxcategories.oxpriceto ";
4030 if ($this->_oAmountPriceList === null) {
4031 $oAmPriceList =
oxNew(
'oxAmountPricelist');
4035 $oAmPriceList->load($this);
4039 foreach ($oAmPriceList as $oAmPrice) {
4040 if ($oAmPrice->oxprice2article__oxaddperc->value) {
4047 $this->_oAmountPriceList = $oAmPriceList;
4062 $mValue = $this->$sFieldName->value;
4064 if (is_null($mValue)) {
4068 if ($mValue ===
'') {
4073 $aZeroValueFields = array(
'oxarticles__oxprice',
'oxarticles__oxvat',
'oxarticles__oxunitquantity');
4075 if (!$mValue && in_array($sFieldName, $aZeroValueFields)) {
4080 if (!strcmp($mValue,
'0000-00-00 00:00:00') || !strcmp($mValue,
'0000-00-00')) {
4084 $sFieldName = strtolower($sFieldName);
4086 if ($sFieldName ==
'oxarticles__oxicon' && (strpos($mValue,
"nopic_ico.jpg") !==
false || strpos($mValue,
"nopic.jpg") !==
false)) {
4090 if (strpos($mValue,
"nopic.jpg") !==
false && ($sFieldName ==
'oxarticles__oxthumb' || substr($sFieldName, 0, 17) ==
'oxarticles__oxpic' || substr($sFieldName, 0, 18) ==
'oxarticles__oxzoom')) {
4113 if ($oParentArticle->$sCopyFieldName != null) {
4116 if (substr($sCopyFieldName, 0, 12) !=
'oxarticles__') {
4121 if (in_array($sCopyFieldName, $this->_aNonCopyParentFields)) {
4132 $this->$sCopyFieldName = clone $oParentArticle->$sCopyFieldName;
4146 $blIsImageField = (stristr($sFieldName,
'_oxthumb') || stristr($sFieldName,
'_oxicon') || stristr($sFieldName,
'_oxzoom') || stristr($sFieldName,
'_oxpic'));
4148 return $blIsImageField;
4156 startProfile(
'articleAssignParentInternal');
4157 if ($this->oxarticles__oxparentid->value) {
4159 if (!$this->
isAdmin() || ($this->_blLoadParentData && $this->
isAdmin())) {
4160 foreach ($this->_aFieldNames as $sFieldName => $sVal) {
4165 stopProfile(
'articleAssignParentInternal');
4173 if (!$this->
getConfig()->getConfigParam(
'blVariantParentBuyable') &&
4174 ($this->_blHasVariants || $this->oxarticles__oxvarstock->value || $this->oxarticles__oxvarcount->value)
4176 $this->_blNotBuyableParent =
true;
4192 if (!
$myConfig->getConfigParam(
'blAllowUnevenAmounts') && !$this->
isAdmin()) {
4193 $this->oxarticles__oxstock =
new oxField((
int) floor($this->oxarticles__oxstock->value));
4196 $this->_iStockStatus = 0;
4199 if (
$myConfig->getConfigParam(
'blUseStock') &&
4200 $this->oxarticles__oxstockflag->value != 4
4203 $iStock = $this->oxarticles__oxstock->value;
4205 if ($this->_blNotBuyableParent) {
4206 $iStock = $this->oxarticles__oxvarstock->value;
4210 if ($iStock <= $myConfig->getConfigParam(
'sStockWarningLimit') && $iStock > 0) {
4211 $this->_iStockStatus = 1;
4216 $this->_iStockStatus = -1;
4222 if (
$myConfig->getConfigParam(
'blUseStock') && ($this->oxarticles__oxstockflag->value == 3 || $this->oxarticles__oxstockflag->value == 2)) {
4223 $iOnStock = $this->oxarticles__oxstock->value;
4224 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
4225 $iOnStock += $this->
getSession()->getBasketReservations()->getReservedAmount($this->
getId());
4227 if ($iOnStock <= 0) {
4233 if ($this->_blNotBuyable && $this->oxarticles__oxvarstock->value) {
4236 $this->_blNotBuyableParent =
true;
4242 if (!
$myConfig->getConfigParam(
'blVariantParentBuyable') && !
$myConfig->getConfigParam(
'blLoadVariants') && $this->oxarticles__oxvarstock->value) {
4247 if (!$this->_blNotBuyable && $this->_blNotBuyableParent && $this->oxarticles__oxvarcount->value == 0) {
4259 if (isset($aPersParam) && isset($aPersParam[$this->
getId()])) {
4260 $this->_aPersistParam = $aPersParam[$this->
getId()];
4271 $sThisShop = $this->oxarticles__oxshopid->value;
4273 $this->_sDynImageDir =
$myConfig->getPictureUrl(null,
false);
4274 $this->dabsimagedir =
$myConfig->getPictureDir(
false);
4275 $this->nossl_dimagedir =
$myConfig->getPictureUrl(null,
false,
false, null, $sThisShop);
4276 $this->ssl_dimagedir =
$myConfig->getPictureUrl(null,
false,
true, null, $sThisShop);
4287 if (isset($aItems[$this->
getId()])) {
4288 $this->_blIsOnComparisonList =
true;
4302 $sNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
4303 $this->oxarticles__oxinsert =
new oxField($sNow);
4304 if (!is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value ==
'') {
4305 $this->oxarticles__oxsubclass =
new oxField(
'oxarticle');
4347 $sOXID = $oDb->quote($sOXID);
4350 $sDelete =
'delete from oxobject2article where oxarticlenid = ' . $sOXID .
' or oxobjectid = ' . $sOXID .
' ';
4351 $oDb->execute($sDelete);
4353 $sDelete =
'delete from oxobject2attribute where oxobjectid = ' . $sOXID .
' ';
4354 $oDb->execute($sDelete);
4356 $sDelete =
'delete from oxobject2category where oxobjectid = ' . $sOXID .
' ';
4357 $oDb->execute($sDelete);
4359 $sDelete =
'delete from oxobject2selectlist where oxobjectid = ' . $sOXID .
' ';
4360 $oDb->execute($sDelete);
4362 $sDelete =
'delete from oxprice2article where oxartid = ' . $sOXID .
' ';
4363 $oDb->execute($sDelete);
4365 $sDelete =
'delete from oxreviews where oxtype="oxarticle" and oxobjectid = ' . $sOXID .
' ';
4366 $oDb->execute($sDelete);
4368 $sDelete =
'delete from oxratings where oxobjectid = ' . $sOXID .
' ';
4369 $rs = $oDb->execute($sDelete);
4371 $sDelete =
'delete from oxaccessoire2article where oxobjectid = ' . $sOXID .
' or oxarticlenid = ' . $sOXID .
' ';
4372 $oDb->execute($sDelete);
4375 $sDelete =
'delete from oxobject2delivery where oxobjectid = ' . $sOXID .
' and oxtype=\'oxarticles\' ';
4376 $oDb->execute($sDelete);
4378 $sDelete =
'delete from oxartextends where oxid = ' . $sOXID .
' ';
4379 $oDb->execute($sDelete);
4383 $oDb->execute(
"delete from $sSetTbl where oxid = {$sOXID}");
4386 $sDelete =
'delete from oxactions2article where oxartid = ' . $sOXID .
' ';
4387 $rs = $oDb->execute($sDelete);
4389 $sDelete =
'delete from oxobject2list where oxobjectid = ' . $sOXID .
' ';
4390 $rs = $oDb->execute($sDelete);
4406 $sQ =
'select oxid from ' . $this->
getViewName() .
' where oxparentid = ' . $oDb->quote($sOXID);
4407 $rs = $oDb->select($sQ,
false,
false);
4408 $oArticle =
oxNew(
"oxArticle");
4409 if ($rs !=
false && $rs->recordCount() > 0) {
4411 $oArticle->setId($rs->fields[0]);
4412 $oArticle->delete();
4429 $oPictureHandler->deleteMainIcon($this);
4432 $oPictureHandler->deleteThumbnail($this);
4434 $sAbsDynImageDir =
$myConfig->getPictureDir(
false);
4437 $iPicCount =
$myConfig->getConfigParam(
'iPicCount');
4438 for ($i = 1; $i <= $iPicCount; $i++) {
4439 $oPictureHandler->deleteArticleMasterPicture($this, $i);
4455 $myUtilsCount->resetVendorArticleCount($sVendorId);
4458 if ($sManufacturerId) {
4459 $myUtilsCount->resetManufacturerArticleCount($sManufacturerId);
4464 foreach ($aCategoryIds as $sCatId) {
4465 $myUtilsCount->resetCatArticleCount($sCatId,
false);
4478 $sParentIdQuoted = $oDb->quote($sParentID);
4479 $sQ =
'select oxstock, oxvendorid, oxmanufacturerid from oxarticles where oxid = ' . $sParentIdQuoted;
4480 $rs = $oDb->select($sQ,
false,
false);
4481 $iOldStock = $rs->fields[0];
4482 $iVendorID = $rs->fields[1];
4483 $iManufacturerID = $rs->fields[2];
4485 $sQ =
'select sum(oxstock) from ' . $this->
getViewName(
true) .
' where oxparentid = ' . $sParentIdQuoted .
' and ' . $this->
getSqlActiveSnippet(
true) .
' and oxstock > 0 ';
4486 $iStock = (float) $oDb->getOne($sQ,
false,
false);
4488 $sQ =
'update oxarticles set oxvarstock = ' . $iStock .
' where oxid = ' . $sParentIdQuoted;
4496 if ($iOldStock < 0) {
4499 if ($this->oxarticles__oxstockflag->value == 2 && $iOldStock xor $iStock) {
4516 if (
$myConfig->getConfigParam(
'blUseStock') && $this->oxarticles__oxstockflag->value == 2 &&
4517 ($this->oxarticles__oxstock->value + $this->oxarticles__oxvarstock->value) <= 0
4520 $this->
_onChangeResetCounts($sOxid, $this->oxarticles__oxvendorid->value, $this->oxarticles__oxmanufacturerid->value);
4533 $sParentIdQuoted = $oDb->quote($sParentID);
4534 $sQ =
"select count(*) as varcount from oxarticles where oxparentid = {$sParentIdQuoted}";
4535 $iVarCount = (int) $oDb->getOne($sQ,
false,
false);
4537 $sQ =
"update oxarticles set oxvarcount = {$iVarCount} where oxid = {$sParentIdQuoted}";
4553 MIN( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varminprice`,
4554 MAX( IF( `oxarticles`.`oxprice` > 0, `oxarticles`.`oxprice`, `p`.`oxprice` ) ) AS `varmaxprice`
4555 FROM ' . $this->
getViewName(
true) .
' AS `oxarticles`
4556 LEFT JOIN ' . $this->
getViewName(
true) .
' AS `p` ON ( `p`.`oxid` = `oxarticles`.`oxparentid` AND `p`.`oxprice` > 0 )
4558 AND ( `oxarticles`.`oxparentid` = ' . $oDb->quote($sParentId) .
' )';
4560 $aPrices = $oDb->getRow($sQ,
false,
false);
4561 if (!is_null($aPrices[
'varminprice']) || !is_null($aPrices[
'varmaxprice'])) {
4565 `oxvarminprice` = ' . $oDb->quote($aPrices[
'varminprice']) .
',
4566 `oxvarmaxprice` = ' . $oDb->quote($aPrices[
'varmaxprice']) .
'
4568 `oxid` = ' . $oDb->quote($sParentId);
4573 `oxvarminprice` = `oxprice`,
4574 `oxvarmaxprice` = `oxprice`
4576 `oxid` = ' . $oDb->quote($sParentId);
4591 $sPicName = basename($this->{
"oxarticles__oxpic" . $iIndex}->value);
4593 if ($sPicName ==
"nopic.jpg" || $sPicName ==
"") {
4598 $this->
getParentArticle()->{
"oxarticles__oxpic" . $iIndex}->value == $this->{
"oxarticles__oxpic" . $iIndex}->value
4603 $sMasterPic =
'product/' . $iIndex .
"/" . $sPicName;
4605 if ($this->
getConfig()->getMasterPicturePath($sMasterPic)) {
4619 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
4622 $blResult = $oUser->isPriceViewModeNetto();
4638 $oPrice =
oxNew(
'oxPrice');
4640 if ($blCalculationModeNetto === null) {
4644 if ($blCalculationModeNetto) {
4645 $oPrice->setNettoPriceMode();
4647 $oPrice->setBruttoPriceMode();
4664 $dPrice = $oPrice->getNettoPrice();
4666 $dPrice = $oPrice->getBruttoPrice();
4682 protected function _preparePrice($dPrice, $dVat, $blCalculationModeNetto = null)
4684 if ($blCalculationModeNetto === null) {
4688 $oCurrency = $this->
getConfig()->getActShopCurrencyObject();
4690 $blEnterNetPrice = $this->
getConfig()->getConfigParam(
'blEnterNetPrice');
4691 if ($blCalculationModeNetto && !$blEnterNetPrice) {
4693 } elseif (!$blCalculationModeNetto && $blEnterNetPrice) {
4711 if ($oUser->inGroup(
'oxidpricea')) {
4712 $sPriceSuffix =
'a';
4713 } elseif ($oUser->inGroup(
'oxidpriceb')) {
4714 $sPriceSuffix =
'b';
4715 } elseif ($oUser->inGroup(
'oxidpricec')) {
4716 $sPriceSuffix =
'c';
4720 return $sPriceSuffix;
4732 if ($sPriceSuffix ===
'') {
4733 $dPrice = $this->oxarticles__oxprice->value;
4735 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4736 $dPrice = ($this->{oxarticles__oxprice . $sPriceSuffix}->value != 0) ? $this->{oxarticles__oxprice . $sPriceSuffix}->value : $this->oxarticles__oxprice->value;
4738 $dPrice = $this->{oxarticles__oxprice . $sPriceSuffix}->value;
4753 if ($this->_dVarMinPrice === null) {
4757 if (is_null($dPrice)) {
4759 if ($sPriceSuffix ===
'') {
4760 $dPrice = $this->oxarticles__oxvarminprice->value;
4763 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4764 $sSql .=
'MIN( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varminprice` ';
4766 $sSql .=
'MIN(`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4777 $this->_dVarMinPrice = $dPrice;
4792 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4795 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4796 $sSql .=
'MIN(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varminprice` ';
4798 $sSql .=
'MIN(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varminprice` ';
4800 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4801 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4803 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4804 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4818 if ($this->_dVarMaxPrice === null) {
4822 if (is_null($dPrice)) {
4824 if ($sPriceSuffix ===
'') {
4825 $dPrice = $this->oxarticles__oxvarmaxprice->value;
4828 if ($this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4829 $sSql .=
'MAX( IF(`oxprice' . $sPriceSuffix .
'` = 0, `oxprice`, `oxprice' . $sPriceSuffix .
'`) ) AS `varmaxprice` ';
4831 $sSql .=
'MAX(`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4842 $this->_dVarMaxPrice = $dPrice;
4857 if ($this->
getConfig()->getConfigParam(
'blMallCustomPrice') && $sShopId != $this->oxarticles__oxshopid->value) {
4860 if ($sPriceSuffix !=
'' && $this->
getConfig()->getConfigParam(
'blOverrideZeroABCPrices')) {
4861 $sSql .=
'MAX(IF(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'` = 0, `oxfield2shop`.`oxprice`, `oxfield2shop`.`oxprice' . $sPriceSuffix .
'`)) AS `varmaxprice` ';
4863 $sSql .=
'MAX(`oxfield2shop`.`oxprice' . $sPriceSuffix .
'`) AS `varmaxprice` ';
4865 $sSql .=
' FROM ' .
getViewName(
'oxfield2shop') .
' AS oxfield2shop
4866 INNER JOIN ' . $this->
getViewName(
true) .
' AS oxarticles ON `oxfield2shop`.`oxartid` = `oxarticles`.`oxid`
4868 AND ( `oxarticles`.`oxparentid` = ' .
oxDb::getDb()->quote($this->
getId()) .
' )
4869 AND ( `oxfield2shop`.`oxshopid` = ' .
oxDb::getDb()->quote($sShopId) .
' )';
4904 $sValue = isset($this->$sField->value) ? $this->$sField->value : 0;
4905 $sSqlSets[] =
'`' . str_replace(
'oxarticles__',
'', $sField) .
'` = ' . $oDb->quote($sValue);
4908 $sSql =
"UPDATE `oxarticles` SET ";
4909 $sSql .= implode(
', ', $sSqlSets) .
'';
4910 $sSql .=
" WHERE `oxparentid` = " . $oDb->quote($this->
getId());
4912 return $oDb->execute($sSql);
4934 $this->$sField =
new oxField($sParent->$sField->value);
4947 $aSortingFields = !empty($aSortingFields) ? (array) $aSortingFields : array();
4949 foreach ($aSortingFields as $sField) {
4951 $this->_aSortingFieldsOnLoad[$sFullField] = $this->$sFullField->value;