79 $this->
init(
'oxorderarticles');
89 $aObjectVars = get_object_vars($oProduct);
91 foreach ($aObjectVars as $sName => $sValue) {
92 if (isset($oProduct->$sName->value)) {
93 $sFieldName = preg_replace(
'/oxarticles__/',
'oxorderarticles__', $sName);
94 if ($sFieldName !=
"oxorderarticles__oxtimestamp") {
95 $this->$sFieldName = $oProduct->$sName;
98 if (!$this->
getConfig()->getConfigParam(
'blSkipFormatConversion')) {
99 if ($sFieldName ==
"oxorderarticles__oxinsert") {
100 oxRegistry::get(
"oxUtilsDate")->convertDBDate($this->$sFieldName,
true);
131 $oArticle =
oxNew(
'oxarticle');
132 $oArticle->load($this->oxorderarticles__oxartid->value);
133 $oArticle->beforeUpdate();
135 if ($this->
getConfig()->getConfigParam(
'blUseStock')) {
137 $iStockCount = $this->
_getArtStock($dAddAmount, $blAllowNegativeStock);
140 $oArticle->oxarticles__oxstock =
new oxField($iStockCount);
141 $oDb->execute(
'update oxarticles set oxarticles.oxstock = ' . $oDb->quote($iStockCount) .
' where oxarticles.oxid = ' . $oDb->quote($this->oxorderarticles__oxartid->value));
142 $oArticle->onChange(ACTION_UPDATE_STOCK);
146 $oArticle->updateSoldAmount($dAddAmount * (-1));
157 protected function _getArtStock($dAddAmount = 0, $blAllowNegativeStock =
false)
162 $sQ =
'select oxstock from oxarticles where oxid = ' . $oDb->quote($this->oxorderarticles__oxartid->value);
163 $iStockCount = ( float ) $oDb->getOne($sQ,
false,
false);
165 $iStockCount += $dAddAmount;
168 if (!$blAllowNegativeStock && $iStockCount < 0) {
183 if ($this->_aPersParam != null) {
187 if ($this->oxorderarticles__oxpersparam->value) {
188 $this->_aPersParam = unserialize($this->oxorderarticles__oxpersparam->value);
201 $this->_aPersParam = $aParams;
218 $sFieldName = strtolower($sFieldName);
219 switch ($sFieldName) {
221 case 'oxorderarticles__oxpersparam':
223 case 'oxorderarticles__oxerpstatus':
225 case 'oxorderarticles__oxtitle':
243 return $this->
load($sOxid);
253 return $this->oxorderarticles__oxartid->value;
276 if (isset($this->oxorderarticles__oxartparentid) && $this->oxorderarticles__oxartparentid->value !==
false) {
277 return $this->oxorderarticles__oxartparentid->value;
281 $oArticle =
oxNew(
"oxarticle");
282 $sQ =
"select oxparentid from " . $oArticle->getViewName() .
" where oxid=" . $oDb->quote($this->
getProductId());
283 $this->oxarticles__oxparentid =
new oxField($oDb->getOne($sQ));
285 return $this->oxarticles__oxparentid->value;
294 $this->oxarticles__oxstock = $this->oxorderarticles__oxamount;
295 $this->oxarticles__oxtitle = $this->oxorderarticles__oxtitle;
296 $this->oxarticles__oxwidth = $this->oxorderarticles__oxwidth;
297 $this->oxarticles__oxlength = $this->oxorderarticles__oxlength;
298 $this->oxarticles__oxheight = $this->oxorderarticles__oxheight;
299 $this->oxarticles__oxweight = $this->oxorderarticles__oxweight;
300 $this->oxarticles__oxsubclass = $this->oxorderarticles__oxsubclass;
301 $this->oxarticles__oxartnum = $this->oxorderarticles__oxartnum;
302 $this->oxarticles__oxshortdesc = $this->oxorderarticles__oxshortdesc;
304 $this->oxarticles__oxvat = $this->oxorderarticles__oxvat;
305 $this->oxarticles__oxprice = $this->oxorderarticles__oxprice;
306 $this->oxarticles__oxbprice = $this->oxorderarticles__oxbprice;
308 $this->oxarticles__oxthumb = $this->oxorderarticles__oxthumb;
309 $this->oxarticles__oxpic1 = $this->oxorderarticles__oxpic1;
310 $this->oxarticles__oxpic2 = $this->oxorderarticles__oxpic2;
311 $this->oxarticles__oxpic3 = $this->oxorderarticles__oxpic3;
312 $this->oxarticles__oxpic4 = $this->oxorderarticles__oxpic4;
313 $this->oxarticles__oxpic5 = $this->oxorderarticles__oxpic5;
315 $this->oxarticles__oxfile = $this->oxorderarticles__oxfile;
316 $this->oxarticles__oxdelivery = $this->oxorderarticles__oxdelivery;
317 $this->oxarticles__oxissearch = $this->oxorderarticles__oxissearch;
318 $this->oxarticles__oxfolder = $this->oxorderarticles__oxfolder;
319 $this->oxarticles__oxtemplate = $this->oxorderarticles__oxtemplate;
320 $this->oxarticles__oxexturl = $this->oxorderarticles__oxexturl;
321 $this->oxarticles__oxurlimg = $this->oxorderarticles__oxurlimg;
322 $this->oxarticles__oxurldesc = $this->oxorderarticles__oxurldesc;
323 $this->oxarticles__oxshopid = $this->oxorderarticles__oxordershopid;
324 $this->oxarticles__oxquestionemail = $this->oxorderarticles__oxquestionemail;
325 $this->oxarticles__oxsearchkeys = $this->oxorderarticles__oxsearchkeys;
351 if ($this->_oOrderArticle === null) {
352 $this->_oOrderArticle =
false;
354 $sArticleId = $sArticleId ? $sArticleId : $this->
getProductId();
355 $oArticle =
oxNew(
"oxArticle");
356 $oArticle->setLoadParentData(
true);
357 if ($oArticle->load($sArticleId)) {
358 $this->_oOrderArticle = $oArticle;
374 $aSelLists = array();
376 $aSelLists = $oArticle->getSelectLists();
392 if ($this->_aOrderArticleSelList === null) {
394 $sOrderArtSelList = $sOrderArtSelList ? $sOrderArtSelList : $this->oxorderarticles__oxselvariant->value;
399 $aList = explode(
", ", $sOrderArtSelList);
402 $aArticleSelList = $oArticle->getSelectLists();
405 foreach ($aList as $sList) {
408 $aVal = explode(
":", $sList);
409 if (isset($aVal[0]) && isset($aVal[1])) {
410 $sOrderArtListTitle = $oStr->strtolower(trim($aVal[0]));
411 $sOrderArtSelValue = $oStr->strtolower(trim($aVal[1]));
415 if (count($aArticleSelList) > 0) {
416 foreach ($aArticleSelList as $aSelect) {
419 if ($oStr->strtolower($aSelect[
'name']) == $sOrderArtListTitle) {
422 foreach ($aSelect as $oSel) {
423 if ($oStr->strtolower($oSel->name) == $sOrderArtSelValue) {
425 $aRet[$iSelListNum] = $iSelValueNum;
440 $this->_aOrderArticleSelList = $aRet;
460 return $oArticle->getBasketPrice($dAmount, $aSelList, $oBasket);
488 $aCatIds = $oOrderArticle->getCategoryIds($blActCats, $blSkipCache);
524 $oBasePrice =
oxNew(
'oxPrice');
526 $oBasePrice->setBruttoPriceMode();
527 $oBasePrice->setVat($this->oxorderarticles__oxvat->value);
528 $oBasePrice->setPrice($this->oxorderarticles__oxbprice->value);
540 $this->_blIsNewOrderItem = $blIsNew;
562 if ($iNewAmount >= 0) {
564 $oArticle =
oxNew(
"oxarticle");
565 if ($oArticle->load($this->oxorderarticles__oxartid->value)) {
568 $iStockChange = $iNewAmount - $this->oxorderarticles__oxamount->value;
569 if ($iStockChange > 0 && ($iOnStock = $oArticle->checkForStock($iStockChange)) !==
false) {
570 if ($iOnStock !==
true) {
571 $iStockChange = $iOnStock;
572 $iNewAmount = $this->oxorderarticles__oxamount->value + $iStockChange;
602 if ($this->oxorderarticles__oxstorno->value == 0) {
604 $this->oxorderarticles__oxstorno =
new oxField(1);
619 public function delete($sOXID = null)
621 if ($blDelete = parent::delete($sOXID)) {
623 if ($this->oxorderarticles__oxstorno->value != 1) {
643 if (
$myConfig->getConfigParam(
'blUseStock') &&
644 $myConfig->getConfigParam(
'blPsBasketReservationEnabled')
647 ->getBasketReservations()
648 ->commitArticleReservation(
649 $this->oxorderarticles__oxartid->value,
650 $this->oxorderarticles__oxamount->value
673 if ($this->oxorderarticles__oxwrapid->value) {
674 $oWrapping =
oxNew(
'oxwrapping');
675 if ($oWrapping->load($this->oxorderarticles__oxwrapid->value)) {
690 return (
bool ) $this->oxorderarticles__oxisbundle->value;
702 $oCurrency = $this->
getConfig()->getCurrencyObject($oOrder->oxorder__oxcurrency->value);
704 return $oLang->formatCurrency($this->oxorderarticles__oxbrutprice->value, $oCurrency);
716 $oCurrency = $this->
getConfig()->getCurrencyObject($oOrder->oxorder__oxcurrency->value);
718 return $oLang->formatCurrency($this->oxorderarticles__oxbprice->value, $oCurrency);
730 $oCurrency = $this->
getConfig()->getCurrencyObject($oOrder->oxorder__oxcurrency->value);
732 return $oLang->formatCurrency($this->oxorderarticles__oxnprice->value, $oCurrency);
742 if ($this->oxorderarticles__oxorderid->value) {
744 if (isset($this->_aOrderCache[$this->oxorderarticles__oxorderid->value])) {
746 return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value];
749 $oOrder =
oxNew(
'oxOrder');
750 if ($oOrder->load($this->oxorderarticles__oxorderid->value)) {
751 return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value] = $oOrder;
767 $iInsertTime = time();
768 $now = date(
'Y-m-d H:i:s', $iInsertTime);
769 $this->oxorderarticles__oxtimestamp =
new oxField($now);
782 $this->_oArticle = $oArticle;
792 if ($this->_oArticle === null) {
793 $oArticle =
oxNew(
'oxArticle');
794 $oArticle->load($this->oxorderarticles__oxartid->value);
795 $this->_oArticle = $oArticle;
809 if ($oArticle->oxarticles__oxisdownloadable->value) {
812 $sOrderId = $this->oxorderarticles__oxorderid->value;
813 $sOrderArticleId = $this->
getId();
814 $sShopId = $oConfig->getShopId();
816 $oUser = $oConfig->getUser();
818 $oFiles = $oArticle->getArticleFiles(
true);
821 foreach ($oFiles as $oFile) {
822 $oOrderFile =
oxNew(
'oxOrderFile');
823 $oOrderFile->setOrderId($sOrderId);
824 $oOrderFile->setOrderArticleId($sOrderArticleId);
825 $oOrderFile->setShopId($sShopId);
826 $iMaxDownloadCount = (!empty($oUser) && !$oUser->hasAccount()) ? $oFile->getMaxUnregisteredDownloadsCount() : $oFile->getMaxDownloadsCount();
827 $oOrderFile->setFile(
828 $oFile->oxfiles__oxfilename->value,
830 $iMaxDownloadCount * $this->oxorderarticles__oxamount->value,
831 $oFile->getLinkExpirationTime(),
832 $oFile->getDownloadExpirationTime()
850 $oCurrency = $this->
getConfig()->getCurrencyObject($oOrder->oxorder__oxcurrency->value);
852 return $oLang->formatCurrency($this->oxorderarticles__oxnetprice->value, $oCurrency);