22 $this->
getConfig()->setConfigParam(
'bl_perfLoadPrice',
true);
24 $oArticle =
oxNew(
'oxArticle');
25 $oArticle->enablePriceLoad();
27 $this->_aViewData[
'edit'] = $oArticle;
30 $sVoxId = $this->
getConfig()->getRequestParameter(
"voxid");
31 $sOxParentId = $this->
getConfig()->getRequestParameter(
"oxparentid");
34 if (isset($sVoxId) && $sVoxId ==
"-1" && isset($sOxParentId) && $sOxParentId && $sOxParentId !=
"-1") {
35 $oParentArticle =
oxNew(
"oxArticle");
36 $oParentArticle->load($sOxParentId);
37 $this->_aViewData[
"parentarticle"] = $oParentArticle;
38 $this->_aViewData[
"oxparentid"] = $sOxParentId;
40 $this->_aViewData[
"oxid"] = $sOxId =
"-1";
43 if ($sOxId && $sOxId !=
"-1") {
46 $oArticle->loadInLang($this->_iEditLang, $sOxId);
50 $oOtherLang = $oArticle->getAvailableInLangs();
51 if (!isset($oOtherLang[$this->_iEditLang])) {
53 $oArticle->loadInLang(key($oOtherLang), $sOxId);
57 if ($oArticle->oxarticles__oxparentid->value) {
58 $oParentArticle =
oxNew(
"oxArticle");
59 $oParentArticle->load($oArticle->oxarticles__oxparentid->value);
60 $this->_aViewData[
"parentarticle"] = $oParentArticle;
61 $this->_aViewData[
"oxparentid"] = $oArticle->oxarticles__oxparentid->value;
62 $this->_aViewData[
"issubvariant"] = 1;
69 $oArticleTagList =
oxNew(
"oxArticleTagList");
70 $oArticleTagList->loadInLang($this->_iEditLang, $oArticle->getId());
71 $oArticle->tags = $oArticleTagList->get();
75 $this->_aViewData[
"posslang"] =
$aLang;
78 foreach ($oOtherLang as $id => $language) {
79 $oLang =
new stdClass();
80 $oLang->sLangDesc = $language;
82 $this->_aViewData[
"otherlang"][$id] = clone $oLang;
90 "oxarticles__oxlongdesc",
93 $this->_aViewData[
"blUseTimeCheck"] = $this->
getConfig()->getConfigParam(
'blUseTimeCheck');
95 return "article_main.tpl";
108 $sEditObjectValue =
'';
110 $oDescField = $oObject->getLongDescription();
115 return $sEditObjectValue;
127 $aParams = $oConfig->getRequestParameter(
"editval");
133 if (isset($aParams[
'oxarticles__oxvat']) && $aParams[
'oxarticles__oxvat'] ===
'') {
134 $aParams[
'oxarticles__oxvat'] = null;
138 $soxparentId = $oConfig->getRequestParameter(
"oxparentid");
139 if (isset($soxparentId) && $soxparentId && $soxparentId !=
"-1") {
140 $aParams[
'oxarticles__oxparentid'] = $soxparentId;
142 unset($aParams[
'oxarticles__oxparentid']);
145 $oArticle =
oxNew(
"oxarticle");
146 $oArticle->setLanguage($this->_iEditLang);
148 if ($soxId !=
"-1") {
149 $oArticle->loadInLang($this->_iEditLang, $soxId);
151 $aParams[
'oxarticles__oxid'] = null;
152 $aParams[
'oxarticles__oxissearch'] = 1;
153 $aParams[
'oxarticles__oxstockflag'] = 1;
154 if (empty($aParams[
'oxarticles__oxstock'])) {
155 $aParams[
'oxarticles__oxstock'] = 0;
161 if (!isset($aParams[
'oxarticles__oxactive'])) {
162 $aParams[
'oxarticles__oxactive'] = 0;
167 if (isset($aParams[
'oxarticles__oxartnum']) && strlen($aParams[
'oxarticles__oxartnum']) > 0 &&
168 $oConfig->getConfigParam(
'blWarnOnSameArtNums') &&
169 $oArticle->oxarticles__oxartnum->value != $aParams[
'oxarticles__oxartnum']
171 $sSelect =
"select oxid from " . getViewName(
'oxarticles');
172 $sSelect .=
" where oxartnum = '" . $aParams[
'oxarticles__oxartnum'] .
"'";
173 $sSelect .=
" and oxid != '" . $aParams[
'oxarticles__oxid'] .
"'";
174 if ($oArticle->assignRecord($sSelect)) {
175 $this->_aViewData[
"errorsavingatricle"] = 1;
181 $sOxIdField =
'oxarticles__oxid';
182 $sPriceField =
'oxarticles__oxprice';
183 $sActiveField =
'oxarticles__oxactive';
184 $sVendorField =
'oxarticles__oxvendorid';
185 $sManufacturerField =
'oxarticles__oxmanufacturerid';
186 if (isset($aParams[$sPriceField]) && $aParams[$sPriceField] != $oArticle->$sPriceField->value) {
187 $this->
resetCounter(
"priceCatArticle", $oArticle->$sPriceField->value);
190 $aResetIds = array();
191 if (isset($aParams[$sActiveField]) && $aParams[$sActiveField] != $oArticle->$sActiveField->value) {
196 $aResetIds[
'vendor'][$oArticle->$sVendorField->value] = 1;
197 $aResetIds[
'manufacturer'][$oArticle->$sManufacturerField->value] = 1;
201 if (isset($aParams[$sVendorField]) && $aParams[$sVendorField] != $oArticle->$sVendorField->value) {
202 $aResetIds[
'vendor'][$aParams[$sVendorField]] = 1;
203 $aResetIds[
'vendor'][$oArticle->$sVendorField->value] = 1;
207 if (isset($aParams[$sManufacturerField]) &&
208 $aParams[$sManufacturerField] != $oArticle->$sManufacturerField->value) {
210 $aResetIds[
'manufacturer'][$aParams[$sManufacturerField]] = 1;
211 $aResetIds[
'manufacturer'][$oArticle->$sManufacturerField->value] = 1;
217 $oArticle->setLanguage(0);
220 if (isset($aParams[
'oxarticles__oxtitle'])) {
221 $aParams[
'oxarticles__oxtitle'] = trim($aParams[
'oxarticles__oxtitle']);
224 $oArticle->assign($aParams);
225 $oArticle->setArticleLongDesc($this->
_processLongDesc($aParams[
'oxarticles__oxlongdesc']));
226 $oArticle->setLanguage($this->_iEditLang);
231 if ($soxId ==
"-1") {
232 $sFastCat = $oConfig->getRequestParameter(
"art_category");
233 if ($sFastCat !=
"-1") {
239 if (isset($aParams[
'tags'])) {
240 $sTags = $aParams[
'tags'];
242 $sTags = $oArticle->oxarticles__oxsearchkeys->value;
244 $aInvalidTags = $this->
_setTags($sTags, $oArticle->getId());
245 if (!empty($aInvalidTags)) {
246 $this->_aViewData[
"invalid_tags"] = implode(
', ', $aInvalidTags);
264 $sValue = str_replace(
' ',
' ', $sValue);
265 $sValue = str_replace(
'&',
'&', $sValue);
266 $sValue = str_replace(
'"',
'"', $sValue);
267 $sValue = str_replace(
'&lang=',
'&lang=', $sValue);
268 $sValue = str_replace(
'<p> </p>',
'', $sValue);
269 $sValue = str_replace(
'<p> </p>',
'', $sValue);
282 $sQ =
"select oxcatnid from oxobject2category where oxobjectid = " . $oDb->quote($sArticleId);
283 $oRs = $oDb->execute($sQ);
284 if ($oRs !==
false && $oRs->recordCount() > 0) {
302 $oArticleTagList =
oxNew(
'oxarticletaglist');
303 $oArticleTagList->loadInLang($this->_iEditLang, $sArticleId);
304 $oArticleTagList->set($sTags);
305 $oArticleTagList->save();
307 return $oArticleTagList->get()->getInvalidTags();
320 $oNew =
oxNew(
"oxbase");
321 $oNew->init(
"oxobject2category");
322 $oNew->oxobject2category__oxtime =
new oxField(0);
323 $oNew->oxobject2category__oxobjectid =
new oxField($sOXID);
324 $oNew->oxobject2category__oxcatnid =
new oxField($sCatID);
339 public function copyArticle($sOldId = null, $sNewId = null, $sParentId = null)
346 $oArticle =
oxNew(
'oxbase');
347 $oArticle->init(
'oxarticles');
348 if ($oArticle->load($sOldId)) {
350 if (
$myConfig->getConfigParam(
'blDisableDublArtOnCopy')) {
351 $oArticle->oxarticles__oxactive->setValue(0);
352 $oArticle->oxarticles__oxactivefrom->setValue(0);
353 $oArticle->oxarticles__oxactiveto->setValue(0);
358 $oArticle->oxarticles__oxparentid->setValue($sParentId);
362 $iNow = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
363 $oArticle->oxarticles__oxinsert =
new oxField($iNow);
366 $oArticle->oxarticles__oxrating =
new oxField(0);
367 $oArticle->oxarticles__oxratingcnt =
new oxField(0);
369 $oArticle->setId($sNewId);
397 $aResetIds[
'vendor'][$oArticle->oxarticles__oxvendorid->value] = 1;
398 $aResetIds[
'manufacturer'][$oArticle->oxarticles__oxmanufacturerid->value] = 1;
407 $sQ =
"select oxid from oxarticles where oxparentid = " . $oDb->quote($sOldId);
408 $oRs = $oDb->execute($sQ);
409 if ($oRs !==
false && $oRs->recordCount() > 0) {
411 $this->
copyArticle($oRs->fields[0], $myUtilsObject->generateUid(), $sNewId);
423 $sArtNumField =
'oxarticles__oxartnum';
424 if (
$myConfig->getConfigParam(
'blWarnOnSameArtNums') &&
425 $oArticle->$sArtNumField->value && $sFncParameter ==
'copyArticle'
427 $sSelect =
"select oxid from " . $oArticle->getCoreTableName() .
428 " where oxartnum = " . $oDb->quote($oArticle->$sArtNumField->value) .
429 " and oxid != " . $oDb->quote($sNewId);
431 if ($oArticle->assignRecord($sSelect)) {
432 $this->_aViewData[
"errorsavingatricle"] = 1;
450 $sO2CView = getViewName(
'oxobject2category');
451 $sQ =
"select oxcatnid, oxtime from {$sO2CView} where oxobjectid = " . $oDb->quote($sOldId);
452 $oRs = $oDb->execute($sQ);
453 if ($oRs !==
false && $oRs->recordCount() > 0) {
455 $sUid = $myUtilsObject->generateUid();
456 $sCatId = $oRs->fields[0];
457 $sTime = $oRs->fields[1];
460 $sSql =
"insert into oxobject2category (oxid, oxobjectid, oxcatnid, oxtime) " .
461 "VALUES (" . $oDb->quote($sUid) .
", " . $oDb->quote($sNewId) .
", " .
462 $oDb->quote($sCatId) .
", " . $oDb->quote($sTime) .
") ";
463 $oDb->execute($sSql);
484 $sQ =
"select oxid from oxobject2attribute where oxobjectid = " . $oDb->quote($sOldId);
485 $oRs = $oDb->execute($sQ);
486 if ($oRs !==
false && $oRs->recordCount() > 0) {
489 $oAttr =
oxNew(
"oxbase");
490 $oAttr->init(
"oxobject2attribute");
491 $oAttr->load($oRs->fields[0]);
492 $oAttr->setId($myUtilsObject->generateUID());
493 $oAttr->oxobject2attribute__oxobjectid->setValue($sNewId);
511 $sQ =
"SELECT * FROM `oxfiles` WHERE `oxartid` = " . $oDb->quote($sOldId);
512 $oRs = $oDb->execute($sQ);
513 if ($oRs !==
false && $oRs->recordCount() > 0) {
516 $oFile =
oxNew(
"oxfile");
517 $oFile->setId($myUtilsObject->generateUID());
518 $oFile->oxfiles__oxartid =
new oxField($sNewId);
519 $oFile->oxfiles__oxfilename =
new oxField($oRs->fields[
'OXFILENAME']);
520 $oFile->oxfiles__oxfilesize =
new oxField($oRs->fields[
'OXFILESIZE']);
521 $oFile->oxfiles__oxstorehash =
new oxField($oRs->fields[
'OXSTOREHASH']);
522 $oFile->oxfiles__oxpurchasedonly =
new oxField($oRs->fields[
'OXPURCHASEDONLY']);
540 $sQ =
"select oxselnid from oxobject2selectlist where oxobjectid = " . $oDb->quote($sOldId);
541 $oRs = $oDb->execute($sQ);
542 if ($oRs !==
false && $oRs->recordCount() > 0) {
544 $sUid = $myUtilsObject->generateUID();
545 $sId = $oRs->fields[0];
546 $sSql =
"insert into oxobject2selectlist (oxid, oxobjectid, oxselnid) " .
547 "VALUES (" . $oDb->quote($sUid) .
", " . $oDb->quote($sNewId) .
", " . $oDb->quote($sId) .
") ";
548 $oDb->execute($sSql);
565 $sQ =
"select oxobjectid from oxobject2article where oxarticlenid = " . $oDb->quote($sOldId);
566 $oRs = $oDb->execute($sQ);
567 if ($oRs !==
false && $oRs->recordCount() > 0) {
569 $sUid = $myUtilsObject->generateUID();
570 $sId = $oRs->fields[0];
571 $sSql =
"insert into oxobject2article (oxid, oxobjectid, oxarticlenid) " .
572 "VALUES (" . $oDb->quote($sUid) .
", " . $oDb->quote($sId) .
", " . $oDb->quote($sNewId) .
" ) ";
573 $oDb->execute($sSql);
590 $sQ =
"select oxobjectid from oxaccessoire2article where oxarticlenid= " . $oDb->quote($sOldId);
591 $oRs = $oDb->execute($sQ);
592 if ($oRs !==
false && $oRs->recordCount() > 0) {
594 $sUId = $myUtilsObject->generateUid();
595 $sId = $oRs->fields[0];
596 $sSql =
"insert into oxaccessoire2article (oxid, oxobjectid, oxarticlenid) " .
597 "VALUES (" . $oDb->quote($sUId) .
", " . $oDb->quote($sId) .
", " . $oDb->quote($sNewId) .
") ";
598 $oDb->execute($sSql);
612 $sShopId = $this->
getConfig()->getShopId();
613 $oPriceList =
oxNew(
"oxlist");
614 $oPriceList->init(
"oxbase",
"oxprice2article");
615 $sQ =
"select * from oxprice2article where oxartid = '{$sOldId}' and oxshopid = '{$sShopId}' " .
616 "and (oxamount > 0 or oxamountto > 0) order by oxamount ";
617 $oPriceList->selectString($sQ);
618 if ($oPriceList->count()) {
619 foreach ($oPriceList as $oItem) {
620 $oItem->oxprice2article__oxid->setValue($oItem->setId());
621 $oItem->oxprice2article__oxartid->setValue($sNewId);
635 $oExt =
oxNew(
"oxbase");
636 $oExt->init(
"oxartextends");
637 $oExt->load($sOldId);
638 $oExt->setId($sNewId);
672 $aJumpList = array();
674 $sOxIdField =
'oxarticles__oxid';
675 if (isset($oParentArticle)) {
676 $aJumpList[] = array($oParentArticle->$sOxIdField->value, $this->_getTitle($oParentArticle));
678 $oParentVariants = $oParentArticle->getAdminVariants($sEditLanguageParameter);
679 if ($oParentVariants->count()) {
680 foreach ($oParentVariants as $oVar) {
681 $aJumpList[] = array($oVar->$sOxIdField->value,
" - " . $this->_getTitle($oVar));
682 if ($oVar->$sOxIdField->value == $oArticle->$sOxIdField->value) {
683 $oVariants = $oArticle->getAdminVariants($sEditLanguageParameter);
684 if ($oVariants->count()) {
685 foreach ($oVariants as $oVVar) {
686 $aJumpList[] = array($oVVar->$sOxIdField->value,
" -- " . $this->_getTitle($oVVar));
693 $aJumpList[] = array($oArticle->$sOxIdField->value, $this->_getTitle($oArticle));
695 $oVariants = $oArticle->getAdminVariants(
oxRegistry::getConfig()->getRequestParameter(
"editlanguage"));
696 if ($oVariants && $oVariants->count()) {
697 foreach ($oVariants as $oVar) {
698 $aJumpList[] = array($oVar->$sOxIdField->value,
" - " . $this->_getTitle($oVar));
702 if (count($aJumpList) > 1) {
703 $this->_aViewData[
"thisvariantlist"] = $aJumpList;
716 $sTitle = $oObj->oxarticles__oxtitle->value;
717 if (!strlen($sTitle)) {
718 $sTitle = $oObj->oxarticles__oxvarselect->value;
731 $oCatTree =
oxNew(
"oxCategoryList");
732 $oCatTree->loadList();
744 $oVendorlist =
oxNew(
"oxvendorlist");
745 $oVendorlist->loadVendorList();
757 $oManufacturerList =
oxNew(
"oxmanufacturerlist");
758 $oManufacturerList->loadManufacturerList();
760 return $oManufacturerList;