1: <?php
2:
3: namespace Thelia\Model\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \DateTime;
9: use \Exception;
10: use \PDO;
11: use \Persistent;
12: use \Propel;
13: use \PropelCollection;
14: use \PropelDateTime;
15: use \PropelException;
16: use \PropelObjectCollection;
17: use \PropelPDO;
18: use Thelia\Model\Accessory;
19: use Thelia\Model\AccessoryQuery;
20: use Thelia\Model\ContentAssoc;
21: use Thelia\Model\ContentAssocQuery;
22: use Thelia\Model\Document;
23: use Thelia\Model\DocumentQuery;
24: use Thelia\Model\FeatureProd;
25: use Thelia\Model\FeatureProdQuery;
26: use Thelia\Model\Image;
27: use Thelia\Model\ImageQuery;
28: use Thelia\Model\Product;
29: use Thelia\Model\ProductCategory;
30: use Thelia\Model\ProductCategoryQuery;
31: use Thelia\Model\ProductI18n;
32: use Thelia\Model\ProductI18nQuery;
33: use Thelia\Model\ProductPeer;
34: use Thelia\Model\ProductQuery;
35: use Thelia\Model\ProductVersion;
36: use Thelia\Model\ProductVersionPeer;
37: use Thelia\Model\ProductVersionQuery;
38: use Thelia\Model\Rewriting;
39: use Thelia\Model\RewritingQuery;
40: use Thelia\Model\Stock;
41: use Thelia\Model\StockQuery;
42: use Thelia\Model\TaxRule;
43: use Thelia\Model\TaxRuleQuery;
44:
45: 46: 47: 48: 49: 50: 51:
52: abstract class BaseProduct extends BaseObject implements Persistent
53: {
54: 55: 56:
57: const PEER = 'Thelia\\Model\\ProductPeer';
58:
59: 60: 61: 62: 63: 64:
65: protected static $peer;
66:
67: 68: 69: 70:
71: protected $startCopy = false;
72:
73: 74: 75: 76:
77: protected $id;
78:
79: 80: 81: 82:
83: protected $tax_rule_id;
84:
85: 86: 87: 88:
89: protected $ref;
90:
91: 92: 93: 94:
95: protected $price;
96:
97: 98: 99: 100:
101: protected $price2;
102:
103: 104: 105: 106:
107: protected $ecotax;
108:
109: 110: 111: 112: 113:
114: protected $newness;
115:
116: 117: 118: 119: 120:
121: protected $promo;
122:
123: 124: 125: 126: 127:
128: protected $stock;
129:
130: 131: 132: 133: 134:
135: protected $visible;
136:
137: 138: 139: 140:
141: protected $weight;
142:
143: 144: 145: 146:
147: protected $position;
148:
149: 150: 151: 152:
153: protected $created_at;
154:
155: 156: 157: 158:
159: protected $updated_at;
160:
161: 162: 163: 164: 165:
166: protected $version;
167:
168: 169: 170: 171:
172: protected $version_created_at;
173:
174: 175: 176: 177:
178: protected $version_created_by;
179:
180: 181: 182:
183: protected $aTaxRule;
184:
185: 186: 187:
188: protected $collProductCategorys;
189: protected $collProductCategorysPartial;
190:
191: 192: 193:
194: protected $collFeatureProds;
195: protected $collFeatureProdsPartial;
196:
197: 198: 199:
200: protected $collStocks;
201: protected $collStocksPartial;
202:
203: 204: 205:
206: protected $collContentAssocs;
207: protected $collContentAssocsPartial;
208:
209: 210: 211:
212: protected $collImages;
213: protected $collImagesPartial;
214:
215: 216: 217:
218: protected $collDocuments;
219: protected $collDocumentsPartial;
220:
221: 222: 223:
224: protected $collAccessorysRelatedByProductId;
225: protected $collAccessorysRelatedByProductIdPartial;
226:
227: 228: 229:
230: protected $collAccessorysRelatedByAccessory;
231: protected $collAccessorysRelatedByAccessoryPartial;
232:
233: 234: 235:
236: protected $collRewritings;
237: protected $collRewritingsPartial;
238:
239: 240: 241:
242: protected $collProductI18ns;
243: protected $collProductI18nsPartial;
244:
245: 246: 247:
248: protected $collProductVersions;
249: protected $collProductVersionsPartial;
250:
251: 252: 253: 254: 255:
256: protected $alreadyInSave = false;
257:
258: 259: 260: 261: 262:
263: protected $alreadyInValidation = false;
264:
265:
266:
267: 268: 269: 270:
271: protected $currentLocale = 'en_EN';
272:
273: 274: 275: 276:
277: protected $currentTranslations;
278:
279:
280:
281:
282: 283: 284:
285: protected $enforceVersion = false;
286:
287: 288: 289: 290:
291: protected $productCategorysScheduledForDeletion = null;
292:
293: 294: 295: 296:
297: protected $featureProdsScheduledForDeletion = null;
298:
299: 300: 301: 302:
303: protected $stocksScheduledForDeletion = null;
304:
305: 306: 307: 308:
309: protected $contentAssocsScheduledForDeletion = null;
310:
311: 312: 313: 314:
315: protected $imagesScheduledForDeletion = null;
316:
317: 318: 319: 320:
321: protected $documentsScheduledForDeletion = null;
322:
323: 324: 325: 326:
327: protected $accessorysRelatedByProductIdScheduledForDeletion = null;
328:
329: 330: 331: 332:
333: protected $accessorysRelatedByAccessoryScheduledForDeletion = null;
334:
335: 336: 337: 338:
339: protected $rewritingsScheduledForDeletion = null;
340:
341: 342: 343: 344:
345: protected $productI18nsScheduledForDeletion = null;
346:
347: 348: 349: 350:
351: protected $productVersionsScheduledForDeletion = null;
352:
353: 354: 355: 356: 357: 358:
359: public function applyDefaultValues()
360: {
361: $this->newness = 0;
362: $this->promo = 0;
363: $this->stock = 0;
364: $this->visible = 0;
365: $this->version = 0;
366: }
367:
368: 369: 370: 371:
372: public function __construct()
373: {
374: parent::__construct();
375: $this->applyDefaultValues();
376: }
377:
378: 379: 380: 381: 382:
383: public function getId()
384: {
385: return $this->id;
386: }
387:
388: 389: 390: 391: 392:
393: public function getTaxRuleId()
394: {
395: return $this->tax_rule_id;
396: }
397:
398: 399: 400: 401: 402:
403: public function getRef()
404: {
405: return $this->ref;
406: }
407:
408: 409: 410: 411: 412:
413: public function getPrice()
414: {
415: return $this->price;
416: }
417:
418: 419: 420: 421: 422:
423: public function getPrice2()
424: {
425: return $this->price2;
426: }
427:
428: 429: 430: 431: 432:
433: public function getEcotax()
434: {
435: return $this->ecotax;
436: }
437:
438: 439: 440: 441: 442:
443: public function getNewness()
444: {
445: return $this->newness;
446: }
447:
448: 449: 450: 451: 452:
453: public function getPromo()
454: {
455: return $this->promo;
456: }
457:
458: 459: 460: 461: 462:
463: public function getStock()
464: {
465: return $this->stock;
466: }
467:
468: 469: 470: 471: 472:
473: public function getVisible()
474: {
475: return $this->visible;
476: }
477:
478: 479: 480: 481: 482:
483: public function getWeight()
484: {
485: return $this->weight;
486: }
487:
488: 489: 490: 491: 492:
493: public function getPosition()
494: {
495: return $this->position;
496: }
497:
498: 499: 500: 501: 502: 503: 504: 505: 506:
507: public function getCreatedAt($format = 'Y-m-d H:i:s')
508: {
509: if ($this->created_at === null) {
510: return null;
511: }
512:
513: if ($this->created_at === '0000-00-00 00:00:00') {
514:
515:
516: return null;
517: } else {
518: try {
519: $dt = new DateTime($this->created_at);
520: } catch (Exception $x) {
521: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
522: }
523: }
524:
525: if ($format === null) {
526:
527: return $dt;
528: } elseif (strpos($format, '%') !== false) {
529: return strftime($format, $dt->format('U'));
530: } else {
531: return $dt->format($format);
532: }
533: }
534:
535: 536: 537: 538: 539: 540: 541: 542: 543:
544: public function getUpdatedAt($format = 'Y-m-d H:i:s')
545: {
546: if ($this->updated_at === null) {
547: return null;
548: }
549:
550: if ($this->updated_at === '0000-00-00 00:00:00') {
551:
552:
553: return null;
554: } else {
555: try {
556: $dt = new DateTime($this->updated_at);
557: } catch (Exception $x) {
558: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
559: }
560: }
561:
562: if ($format === null) {
563:
564: return $dt;
565: } elseif (strpos($format, '%') !== false) {
566: return strftime($format, $dt->format('U'));
567: } else {
568: return $dt->format($format);
569: }
570: }
571:
572: 573: 574: 575: 576:
577: public function getVersion()
578: {
579: return $this->version;
580: }
581:
582: 583: 584: 585: 586: 587: 588: 589: 590:
591: public function getVersionCreatedAt($format = 'Y-m-d H:i:s')
592: {
593: if ($this->version_created_at === null) {
594: return null;
595: }
596:
597: if ($this->version_created_at === '0000-00-00 00:00:00') {
598:
599:
600: return null;
601: } else {
602: try {
603: $dt = new DateTime($this->version_created_at);
604: } catch (Exception $x) {
605: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->version_created_at, true), $x);
606: }
607: }
608:
609: if ($format === null) {
610:
611: return $dt;
612: } elseif (strpos($format, '%') !== false) {
613: return strftime($format, $dt->format('U'));
614: } else {
615: return $dt->format($format);
616: }
617: }
618:
619: 620: 621: 622: 623:
624: public function getVersionCreatedBy()
625: {
626: return $this->version_created_by;
627: }
628:
629: 630: 631: 632: 633: 634:
635: public function setId($v)
636: {
637: if ($v !== null) {
638: $v = (int) $v;
639: }
640:
641: if ($this->id !== $v) {
642: $this->id = $v;
643: $this->modifiedColumns[] = ProductPeer::ID;
644: }
645:
646:
647: return $this;
648: }
649:
650: 651: 652: 653: 654: 655:
656: public function setTaxRuleId($v)
657: {
658: if ($v !== null) {
659: $v = (int) $v;
660: }
661:
662: if ($this->tax_rule_id !== $v) {
663: $this->tax_rule_id = $v;
664: $this->modifiedColumns[] = ProductPeer::TAX_RULE_ID;
665: }
666:
667: if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
668: $this->aTaxRule = null;
669: }
670:
671:
672: return $this;
673: }
674:
675: 676: 677: 678: 679: 680:
681: public function setRef($v)
682: {
683: if ($v !== null) {
684: $v = (string) $v;
685: }
686:
687: if ($this->ref !== $v) {
688: $this->ref = $v;
689: $this->modifiedColumns[] = ProductPeer::REF;
690: }
691:
692:
693: return $this;
694: }
695:
696: 697: 698: 699: 700: 701:
702: public function setPrice($v)
703: {
704: if ($v !== null) {
705: $v = (double) $v;
706: }
707:
708: if ($this->price !== $v) {
709: $this->price = $v;
710: $this->modifiedColumns[] = ProductPeer::PRICE;
711: }
712:
713:
714: return $this;
715: }
716:
717: 718: 719: 720: 721: 722:
723: public function setPrice2($v)
724: {
725: if ($v !== null) {
726: $v = (double) $v;
727: }
728:
729: if ($this->price2 !== $v) {
730: $this->price2 = $v;
731: $this->modifiedColumns[] = ProductPeer::PRICE2;
732: }
733:
734:
735: return $this;
736: }
737:
738: 739: 740: 741: 742: 743:
744: public function setEcotax($v)
745: {
746: if ($v !== null) {
747: $v = (double) $v;
748: }
749:
750: if ($this->ecotax !== $v) {
751: $this->ecotax = $v;
752: $this->modifiedColumns[] = ProductPeer::ECOTAX;
753: }
754:
755:
756: return $this;
757: }
758:
759: 760: 761: 762: 763: 764:
765: public function setNewness($v)
766: {
767: if ($v !== null) {
768: $v = (int) $v;
769: }
770:
771: if ($this->newness !== $v) {
772: $this->newness = $v;
773: $this->modifiedColumns[] = ProductPeer::NEWNESS;
774: }
775:
776:
777: return $this;
778: }
779:
780: 781: 782: 783: 784: 785:
786: public function setPromo($v)
787: {
788: if ($v !== null) {
789: $v = (int) $v;
790: }
791:
792: if ($this->promo !== $v) {
793: $this->promo = $v;
794: $this->modifiedColumns[] = ProductPeer::PROMO;
795: }
796:
797:
798: return $this;
799: }
800:
801: 802: 803: 804: 805: 806:
807: public function setStock($v)
808: {
809: if ($v !== null) {
810: $v = (int) $v;
811: }
812:
813: if ($this->stock !== $v) {
814: $this->stock = $v;
815: $this->modifiedColumns[] = ProductPeer::STOCK;
816: }
817:
818:
819: return $this;
820: }
821:
822: 823: 824: 825: 826: 827:
828: public function setVisible($v)
829: {
830: if ($v !== null) {
831: $v = (int) $v;
832: }
833:
834: if ($this->visible !== $v) {
835: $this->visible = $v;
836: $this->modifiedColumns[] = ProductPeer::VISIBLE;
837: }
838:
839:
840: return $this;
841: }
842:
843: 844: 845: 846: 847: 848:
849: public function setWeight($v)
850: {
851: if ($v !== null) {
852: $v = (double) $v;
853: }
854:
855: if ($this->weight !== $v) {
856: $this->weight = $v;
857: $this->modifiedColumns[] = ProductPeer::WEIGHT;
858: }
859:
860:
861: return $this;
862: }
863:
864: 865: 866: 867: 868: 869:
870: public function setPosition($v)
871: {
872: if ($v !== null) {
873: $v = (int) $v;
874: }
875:
876: if ($this->position !== $v) {
877: $this->position = $v;
878: $this->modifiedColumns[] = ProductPeer::POSITION;
879: }
880:
881:
882: return $this;
883: }
884:
885: 886: 887: 888: 889: 890: 891:
892: public function setCreatedAt($v)
893: {
894: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
895: if ($this->created_at !== null || $dt !== null) {
896: $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
897: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
898: if ($currentDateAsString !== $newDateAsString) {
899: $this->created_at = $newDateAsString;
900: $this->modifiedColumns[] = ProductPeer::CREATED_AT;
901: }
902: }
903:
904:
905: return $this;
906: }
907:
908: 909: 910: 911: 912: 913: 914:
915: public function setUpdatedAt($v)
916: {
917: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
918: if ($this->updated_at !== null || $dt !== null) {
919: $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
920: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
921: if ($currentDateAsString !== $newDateAsString) {
922: $this->updated_at = $newDateAsString;
923: $this->modifiedColumns[] = ProductPeer::UPDATED_AT;
924: }
925: }
926:
927:
928: return $this;
929: }
930:
931: 932: 933: 934: 935: 936:
937: public function setVersion($v)
938: {
939: if ($v !== null) {
940: $v = (int) $v;
941: }
942:
943: if ($this->version !== $v) {
944: $this->version = $v;
945: $this->modifiedColumns[] = ProductPeer::VERSION;
946: }
947:
948:
949: return $this;
950: }
951:
952: 953: 954: 955: 956: 957: 958:
959: public function setVersionCreatedAt($v)
960: {
961: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
962: if ($this->version_created_at !== null || $dt !== null) {
963: $currentDateAsString = ($this->version_created_at !== null && $tmpDt = new DateTime($this->version_created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
964: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
965: if ($currentDateAsString !== $newDateAsString) {
966: $this->version_created_at = $newDateAsString;
967: $this->modifiedColumns[] = ProductPeer::VERSION_CREATED_AT;
968: }
969: }
970:
971:
972: return $this;
973: }
974:
975: 976: 977: 978: 979: 980:
981: public function setVersionCreatedBy($v)
982: {
983: if ($v !== null) {
984: $v = (string) $v;
985: }
986:
987: if ($this->version_created_by !== $v) {
988: $this->version_created_by = $v;
989: $this->modifiedColumns[] = ProductPeer::VERSION_CREATED_BY;
990: }
991:
992:
993: return $this;
994: }
995:
996: 997: 998: 999: 1000: 1001: 1002: 1003:
1004: public function hasOnlyDefaultValues()
1005: {
1006: if ($this->newness !== 0) {
1007: return false;
1008: }
1009:
1010: if ($this->promo !== 0) {
1011: return false;
1012: }
1013:
1014: if ($this->stock !== 0) {
1015: return false;
1016: }
1017:
1018: if ($this->visible !== 0) {
1019: return false;
1020: }
1021:
1022: if ($this->version !== 0) {
1023: return false;
1024: }
1025:
1026:
1027: return true;
1028: }
1029:
1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043:
1044: public function hydrate($row, $startcol = 0, $rehydrate = false)
1045: {
1046: try {
1047:
1048: $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
1049: $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
1050: $this->ref = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
1051: $this->price = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null;
1052: $this->price2 = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null;
1053: $this->ecotax = ($row[$startcol + 5] !== null) ? (double) $row[$startcol + 5] : null;
1054: $this->newness = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
1055: $this->promo = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
1056: $this->stock = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
1057: $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
1058: $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null;
1059: $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
1060: $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
1061: $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null;
1062: $this->version = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
1063: $this->version_created_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null;
1064: $this->version_created_by = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null;
1065: $this->resetModified();
1066:
1067: $this->setNew(false);
1068:
1069: if ($rehydrate) {
1070: $this->ensureConsistency();
1071: }
1072:
1073: return $startcol + 17;
1074:
1075: } catch (Exception $e) {
1076: throw new PropelException("Error populating Product object", $e);
1077: }
1078: }
1079:
1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092:
1093: public function ensureConsistency()
1094: {
1095:
1096: if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
1097: $this->aTaxRule = null;
1098: }
1099: }
1100:
1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110:
1111: public function reload($deep = false, PropelPDO $con = null)
1112: {
1113: if ($this->isDeleted()) {
1114: throw new PropelException("Cannot reload a deleted object.");
1115: }
1116:
1117: if ($this->isNew()) {
1118: throw new PropelException("Cannot reload an unsaved object.");
1119: }
1120:
1121: if ($con === null) {
1122: $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
1123: }
1124:
1125:
1126:
1127:
1128: $stmt = ProductPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
1129: $row = $stmt->fetch(PDO::FETCH_NUM);
1130: $stmt->closeCursor();
1131: if (!$row) {
1132: throw new PropelException('Cannot find matching row in the database to reload object values.');
1133: }
1134: $this->hydrate($row, 0, true);
1135:
1136: if ($deep) {
1137:
1138: $this->aTaxRule = null;
1139: $this->collProductCategorys = null;
1140:
1141: $this->collFeatureProds = null;
1142:
1143: $this->collStocks = null;
1144:
1145: $this->collContentAssocs = null;
1146:
1147: $this->collImages = null;
1148:
1149: $this->collDocuments = null;
1150:
1151: $this->collAccessorysRelatedByProductId = null;
1152:
1153: $this->collAccessorysRelatedByAccessory = null;
1154:
1155: $this->collRewritings = null;
1156:
1157: $this->collProductI18ns = null;
1158:
1159: $this->collProductVersions = null;
1160:
1161: }
1162: }
1163:
1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173:
1174: public function delete(PropelPDO $con = null)
1175: {
1176: if ($this->isDeleted()) {
1177: throw new PropelException("This object has already been deleted.");
1178: }
1179:
1180: if ($con === null) {
1181: $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1182: }
1183:
1184: $con->beginTransaction();
1185: try {
1186: $deleteQuery = ProductQuery::create()
1187: ->filterByPrimaryKey($this->getPrimaryKey());
1188: $ret = $this->preDelete($con);
1189: if ($ret) {
1190: $deleteQuery->delete($con);
1191: $this->postDelete($con);
1192: $con->commit();
1193: $this->setDeleted(true);
1194: } else {
1195: $con->commit();
1196: }
1197: } catch (Exception $e) {
1198: $con->rollBack();
1199: throw $e;
1200: }
1201: }
1202:
1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216:
1217: public function save(PropelPDO $con = null)
1218: {
1219: if ($this->isDeleted()) {
1220: throw new PropelException("You cannot save an object that has been deleted.");
1221: }
1222:
1223: if ($con === null) {
1224: $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
1225: }
1226:
1227: $con->beginTransaction();
1228: $isInsert = $this->isNew();
1229: try {
1230: $ret = $this->preSave($con);
1231:
1232: if ($this->isVersioningNecessary()) {
1233: $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
1234: if (!$this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) {
1235: $this->setVersionCreatedAt(time());
1236: }
1237: $createVersion = true;
1238: }
1239: if ($isInsert) {
1240: $ret = $ret && $this->preInsert($con);
1241:
1242: if (!$this->isColumnModified(ProductPeer::CREATED_AT)) {
1243: $this->setCreatedAt(time());
1244: }
1245: if (!$this->isColumnModified(ProductPeer::UPDATED_AT)) {
1246: $this->setUpdatedAt(time());
1247: }
1248: } else {
1249: $ret = $ret && $this->preUpdate($con);
1250:
1251: if ($this->isModified() && !$this->isColumnModified(ProductPeer::UPDATED_AT)) {
1252: $this->setUpdatedAt(time());
1253: }
1254: }
1255: if ($ret) {
1256: $affectedRows = $this->doSave($con);
1257: if ($isInsert) {
1258: $this->postInsert($con);
1259: } else {
1260: $this->postUpdate($con);
1261: }
1262: $this->postSave($con);
1263:
1264: if (isset($createVersion)) {
1265: $this->addVersion($con);
1266: }
1267: ProductPeer::addInstanceToPool($this);
1268: } else {
1269: $affectedRows = 0;
1270: }
1271: $con->commit();
1272:
1273: return $affectedRows;
1274: } catch (Exception $e) {
1275: $con->rollBack();
1276: throw $e;
1277: }
1278: }
1279:
1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290:
1291: protected function doSave(PropelPDO $con)
1292: {
1293: $affectedRows = 0;
1294: if (!$this->alreadyInSave) {
1295: $this->alreadyInSave = true;
1296:
1297:
1298:
1299:
1300:
1301:
1302: if ($this->aTaxRule !== null) {
1303: if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
1304: $affectedRows += $this->aTaxRule->save($con);
1305: }
1306: $this->setTaxRule($this->aTaxRule);
1307: }
1308:
1309: if ($this->isNew() || $this->isModified()) {
1310:
1311: if ($this->isNew()) {
1312: $this->doInsert($con);
1313: } else {
1314: $this->doUpdate($con);
1315: }
1316: $affectedRows += 1;
1317: $this->resetModified();
1318: }
1319:
1320: if ($this->productCategorysScheduledForDeletion !== null) {
1321: if (!$this->productCategorysScheduledForDeletion->isEmpty()) {
1322: ProductCategoryQuery::create()
1323: ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false))
1324: ->delete($con);
1325: $this->productCategorysScheduledForDeletion = null;
1326: }
1327: }
1328:
1329: if ($this->collProductCategorys !== null) {
1330: foreach ($this->collProductCategorys as $referrerFK) {
1331: if (!$referrerFK->isDeleted()) {
1332: $affectedRows += $referrerFK->save($con);
1333: }
1334: }
1335: }
1336:
1337: if ($this->featureProdsScheduledForDeletion !== null) {
1338: if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
1339: FeatureProdQuery::create()
1340: ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
1341: ->delete($con);
1342: $this->featureProdsScheduledForDeletion = null;
1343: }
1344: }
1345:
1346: if ($this->collFeatureProds !== null) {
1347: foreach ($this->collFeatureProds as $referrerFK) {
1348: if (!$referrerFK->isDeleted()) {
1349: $affectedRows += $referrerFK->save($con);
1350: }
1351: }
1352: }
1353:
1354: if ($this->stocksScheduledForDeletion !== null) {
1355: if (!$this->stocksScheduledForDeletion->isEmpty()) {
1356: StockQuery::create()
1357: ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false))
1358: ->delete($con);
1359: $this->stocksScheduledForDeletion = null;
1360: }
1361: }
1362:
1363: if ($this->collStocks !== null) {
1364: foreach ($this->collStocks as $referrerFK) {
1365: if (!$referrerFK->isDeleted()) {
1366: $affectedRows += $referrerFK->save($con);
1367: }
1368: }
1369: }
1370:
1371: if ($this->contentAssocsScheduledForDeletion !== null) {
1372: if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
1373: foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) {
1374:
1375: $contentAssoc->save($con);
1376: }
1377: $this->contentAssocsScheduledForDeletion = null;
1378: }
1379: }
1380:
1381: if ($this->collContentAssocs !== null) {
1382: foreach ($this->collContentAssocs as $referrerFK) {
1383: if (!$referrerFK->isDeleted()) {
1384: $affectedRows += $referrerFK->save($con);
1385: }
1386: }
1387: }
1388:
1389: if ($this->imagesScheduledForDeletion !== null) {
1390: if (!$this->imagesScheduledForDeletion->isEmpty()) {
1391: foreach ($this->imagesScheduledForDeletion as $image) {
1392:
1393: $image->save($con);
1394: }
1395: $this->imagesScheduledForDeletion = null;
1396: }
1397: }
1398:
1399: if ($this->collImages !== null) {
1400: foreach ($this->collImages as $referrerFK) {
1401: if (!$referrerFK->isDeleted()) {
1402: $affectedRows += $referrerFK->save($con);
1403: }
1404: }
1405: }
1406:
1407: if ($this->documentsScheduledForDeletion !== null) {
1408: if (!$this->documentsScheduledForDeletion->isEmpty()) {
1409: foreach ($this->documentsScheduledForDeletion as $document) {
1410:
1411: $document->save($con);
1412: }
1413: $this->documentsScheduledForDeletion = null;
1414: }
1415: }
1416:
1417: if ($this->collDocuments !== null) {
1418: foreach ($this->collDocuments as $referrerFK) {
1419: if (!$referrerFK->isDeleted()) {
1420: $affectedRows += $referrerFK->save($con);
1421: }
1422: }
1423: }
1424:
1425: if ($this->accessorysRelatedByProductIdScheduledForDeletion !== null) {
1426: if (!$this->accessorysRelatedByProductIdScheduledForDeletion->isEmpty()) {
1427: AccessoryQuery::create()
1428: ->filterByPrimaryKeys($this->accessorysRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false))
1429: ->delete($con);
1430: $this->accessorysRelatedByProductIdScheduledForDeletion = null;
1431: }
1432: }
1433:
1434: if ($this->collAccessorysRelatedByProductId !== null) {
1435: foreach ($this->collAccessorysRelatedByProductId as $referrerFK) {
1436: if (!$referrerFK->isDeleted()) {
1437: $affectedRows += $referrerFK->save($con);
1438: }
1439: }
1440: }
1441:
1442: if ($this->accessorysRelatedByAccessoryScheduledForDeletion !== null) {
1443: if (!$this->accessorysRelatedByAccessoryScheduledForDeletion->isEmpty()) {
1444: AccessoryQuery::create()
1445: ->filterByPrimaryKeys($this->accessorysRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false))
1446: ->delete($con);
1447: $this->accessorysRelatedByAccessoryScheduledForDeletion = null;
1448: }
1449: }
1450:
1451: if ($this->collAccessorysRelatedByAccessory !== null) {
1452: foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) {
1453: if (!$referrerFK->isDeleted()) {
1454: $affectedRows += $referrerFK->save($con);
1455: }
1456: }
1457: }
1458:
1459: if ($this->rewritingsScheduledForDeletion !== null) {
1460: if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
1461: foreach ($this->rewritingsScheduledForDeletion as $rewriting) {
1462:
1463: $rewriting->save($con);
1464: }
1465: $this->rewritingsScheduledForDeletion = null;
1466: }
1467: }
1468:
1469: if ($this->collRewritings !== null) {
1470: foreach ($this->collRewritings as $referrerFK) {
1471: if (!$referrerFK->isDeleted()) {
1472: $affectedRows += $referrerFK->save($con);
1473: }
1474: }
1475: }
1476:
1477: if ($this->productI18nsScheduledForDeletion !== null) {
1478: if (!$this->productI18nsScheduledForDeletion->isEmpty()) {
1479: ProductI18nQuery::create()
1480: ->filterByPrimaryKeys($this->productI18nsScheduledForDeletion->getPrimaryKeys(false))
1481: ->delete($con);
1482: $this->productI18nsScheduledForDeletion = null;
1483: }
1484: }
1485:
1486: if ($this->collProductI18ns !== null) {
1487: foreach ($this->collProductI18ns as $referrerFK) {
1488: if (!$referrerFK->isDeleted()) {
1489: $affectedRows += $referrerFK->save($con);
1490: }
1491: }
1492: }
1493:
1494: if ($this->productVersionsScheduledForDeletion !== null) {
1495: if (!$this->productVersionsScheduledForDeletion->isEmpty()) {
1496: ProductVersionQuery::create()
1497: ->filterByPrimaryKeys($this->productVersionsScheduledForDeletion->getPrimaryKeys(false))
1498: ->delete($con);
1499: $this->productVersionsScheduledForDeletion = null;
1500: }
1501: }
1502:
1503: if ($this->collProductVersions !== null) {
1504: foreach ($this->collProductVersions as $referrerFK) {
1505: if (!$referrerFK->isDeleted()) {
1506: $affectedRows += $referrerFK->save($con);
1507: }
1508: }
1509: }
1510:
1511: $this->alreadyInSave = false;
1512:
1513: }
1514:
1515: return $affectedRows;
1516: }
1517:
1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525:
1526: protected function doInsert(PropelPDO $con)
1527: {
1528: $modifiedColumns = array();
1529: $index = 0;
1530:
1531: $this->modifiedColumns[] = ProductPeer::ID;
1532: if (null !== $this->id) {
1533: throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPeer::ID . ')');
1534: }
1535:
1536:
1537: if ($this->isColumnModified(ProductPeer::ID)) {
1538: $modifiedColumns[':p' . $index++] = '`ID`';
1539: }
1540: if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) {
1541: $modifiedColumns[':p' . $index++] = '`TAX_RULE_ID`';
1542: }
1543: if ($this->isColumnModified(ProductPeer::REF)) {
1544: $modifiedColumns[':p' . $index++] = '`REF`';
1545: }
1546: if ($this->isColumnModified(ProductPeer::PRICE)) {
1547: $modifiedColumns[':p' . $index++] = '`PRICE`';
1548: }
1549: if ($this->isColumnModified(ProductPeer::PRICE2)) {
1550: $modifiedColumns[':p' . $index++] = '`PRICE2`';
1551: }
1552: if ($this->isColumnModified(ProductPeer::ECOTAX)) {
1553: $modifiedColumns[':p' . $index++] = '`ECOTAX`';
1554: }
1555: if ($this->isColumnModified(ProductPeer::NEWNESS)) {
1556: $modifiedColumns[':p' . $index++] = '`NEWNESS`';
1557: }
1558: if ($this->isColumnModified(ProductPeer::PROMO)) {
1559: $modifiedColumns[':p' . $index++] = '`PROMO`';
1560: }
1561: if ($this->isColumnModified(ProductPeer::STOCK)) {
1562: $modifiedColumns[':p' . $index++] = '`STOCK`';
1563: }
1564: if ($this->isColumnModified(ProductPeer::VISIBLE)) {
1565: $modifiedColumns[':p' . $index++] = '`VISIBLE`';
1566: }
1567: if ($this->isColumnModified(ProductPeer::WEIGHT)) {
1568: $modifiedColumns[':p' . $index++] = '`WEIGHT`';
1569: }
1570: if ($this->isColumnModified(ProductPeer::POSITION)) {
1571: $modifiedColumns[':p' . $index++] = '`POSITION`';
1572: }
1573: if ($this->isColumnModified(ProductPeer::CREATED_AT)) {
1574: $modifiedColumns[':p' . $index++] = '`CREATED_AT`';
1575: }
1576: if ($this->isColumnModified(ProductPeer::UPDATED_AT)) {
1577: $modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
1578: }
1579: if ($this->isColumnModified(ProductPeer::VERSION)) {
1580: $modifiedColumns[':p' . $index++] = '`VERSION`';
1581: }
1582: if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) {
1583: $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
1584: }
1585: if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) {
1586: $modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
1587: }
1588:
1589: $sql = sprintf(
1590: 'INSERT INTO `product` (%s) VALUES (%s)',
1591: implode(', ', $modifiedColumns),
1592: implode(', ', array_keys($modifiedColumns))
1593: );
1594:
1595: try {
1596: $stmt = $con->prepare($sql);
1597: foreach ($modifiedColumns as $identifier => $columnName) {
1598: switch ($columnName) {
1599: case '`ID`':
1600: $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1601: break;
1602: case '`TAX_RULE_ID`':
1603: $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
1604: break;
1605: case '`REF`':
1606: $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
1607: break;
1608: case '`PRICE`':
1609: $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
1610: break;
1611: case '`PRICE2`':
1612: $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR);
1613: break;
1614: case '`ECOTAX`':
1615: $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR);
1616: break;
1617: case '`NEWNESS`':
1618: $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT);
1619: break;
1620: case '`PROMO`':
1621: $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT);
1622: break;
1623: case '`STOCK`':
1624: $stmt->bindValue($identifier, $this->stock, PDO::PARAM_INT);
1625: break;
1626: case '`VISIBLE`':
1627: $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
1628: break;
1629: case '`WEIGHT`':
1630: $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
1631: break;
1632: case '`POSITION`':
1633: $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1634: break;
1635: case '`CREATED_AT`':
1636: $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
1637: break;
1638: case '`UPDATED_AT`':
1639: $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
1640: break;
1641: case '`VERSION`':
1642: $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
1643: break;
1644: case '`VERSION_CREATED_AT`':
1645: $stmt->bindValue($identifier, $this->version_created_at, PDO::PARAM_STR);
1646: break;
1647: case '`VERSION_CREATED_BY`':
1648: $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
1649: break;
1650: }
1651: }
1652: $stmt->execute();
1653: } catch (Exception $e) {
1654: Propel::log($e->getMessage(), Propel::LOG_ERR);
1655: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1656: }
1657:
1658: try {
1659: $pk = $con->lastInsertId();
1660: } catch (Exception $e) {
1661: throw new PropelException('Unable to get autoincrement id.', $e);
1662: }
1663: $this->setId($pk);
1664:
1665: $this->setNew(false);
1666: }
1667:
1668: 1669: 1670: 1671: 1672: 1673: 1674:
1675: protected function doUpdate(PropelPDO $con)
1676: {
1677: $selectCriteria = $this->buildPkeyCriteria();
1678: $valuesCriteria = $this->buildCriteria();
1679: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1680: }
1681:
1682: 1683: 1684: 1685:
1686: protected $validationFailures = array();
1687:
1688: 1689: 1690: 1691: 1692: 1693: 1694:
1695: public function getValidationFailures()
1696: {
1697: return $this->validationFailures;
1698: }
1699:
1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710:
1711: public function validate($columns = null)
1712: {
1713: $res = $this->doValidate($columns);
1714: if ($res === true) {
1715: $this->validationFailures = array();
1716:
1717: return true;
1718: } else {
1719: $this->validationFailures = $res;
1720:
1721: return false;
1722: }
1723: }
1724:
1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734:
1735: protected function doValidate($columns = null)
1736: {
1737: if (!$this->alreadyInValidation) {
1738: $this->alreadyInValidation = true;
1739: $retval = null;
1740:
1741: $failureMap = array();
1742:
1743:
1744:
1745:
1746:
1747:
1748:
1749: if ($this->aTaxRule !== null) {
1750: if (!$this->aTaxRule->validate($columns)) {
1751: $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
1752: }
1753: }
1754:
1755:
1756: if (($retval = ProductPeer::doValidate($this, $columns)) !== true) {
1757: $failureMap = array_merge($failureMap, $retval);
1758: }
1759:
1760:
1761: if ($this->collProductCategorys !== null) {
1762: foreach ($this->collProductCategorys as $referrerFK) {
1763: if (!$referrerFK->validate($columns)) {
1764: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1765: }
1766: }
1767: }
1768:
1769: if ($this->collFeatureProds !== null) {
1770: foreach ($this->collFeatureProds as $referrerFK) {
1771: if (!$referrerFK->validate($columns)) {
1772: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1773: }
1774: }
1775: }
1776:
1777: if ($this->collStocks !== null) {
1778: foreach ($this->collStocks as $referrerFK) {
1779: if (!$referrerFK->validate($columns)) {
1780: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1781: }
1782: }
1783: }
1784:
1785: if ($this->collContentAssocs !== null) {
1786: foreach ($this->collContentAssocs as $referrerFK) {
1787: if (!$referrerFK->validate($columns)) {
1788: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1789: }
1790: }
1791: }
1792:
1793: if ($this->collImages !== null) {
1794: foreach ($this->collImages as $referrerFK) {
1795: if (!$referrerFK->validate($columns)) {
1796: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1797: }
1798: }
1799: }
1800:
1801: if ($this->collDocuments !== null) {
1802: foreach ($this->collDocuments as $referrerFK) {
1803: if (!$referrerFK->validate($columns)) {
1804: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1805: }
1806: }
1807: }
1808:
1809: if ($this->collAccessorysRelatedByProductId !== null) {
1810: foreach ($this->collAccessorysRelatedByProductId as $referrerFK) {
1811: if (!$referrerFK->validate($columns)) {
1812: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1813: }
1814: }
1815: }
1816:
1817: if ($this->collAccessorysRelatedByAccessory !== null) {
1818: foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) {
1819: if (!$referrerFK->validate($columns)) {
1820: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1821: }
1822: }
1823: }
1824:
1825: if ($this->collRewritings !== null) {
1826: foreach ($this->collRewritings as $referrerFK) {
1827: if (!$referrerFK->validate($columns)) {
1828: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1829: }
1830: }
1831: }
1832:
1833: if ($this->collProductI18ns !== null) {
1834: foreach ($this->collProductI18ns as $referrerFK) {
1835: if (!$referrerFK->validate($columns)) {
1836: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1837: }
1838: }
1839: }
1840:
1841: if ($this->collProductVersions !== null) {
1842: foreach ($this->collProductVersions as $referrerFK) {
1843: if (!$referrerFK->validate($columns)) {
1844: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1845: }
1846: }
1847: }
1848:
1849:
1850: $this->alreadyInValidation = false;
1851: }
1852:
1853: return (!empty($failureMap) ? $failureMap : true);
1854: }
1855:
1856: 1857: 1858: 1859: 1860: 1861: 1862: 1863: 1864: 1865:
1866: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1867: {
1868: $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1869: $field = $this->getByPosition($pos);
1870:
1871: return $field;
1872: }
1873:
1874: 1875: 1876: 1877: 1878: 1879: 1880:
1881: public function getByPosition($pos)
1882: {
1883: switch ($pos) {
1884: case 0:
1885: return $this->getId();
1886: break;
1887: case 1:
1888: return $this->getTaxRuleId();
1889: break;
1890: case 2:
1891: return $this->getRef();
1892: break;
1893: case 3:
1894: return $this->getPrice();
1895: break;
1896: case 4:
1897: return $this->getPrice2();
1898: break;
1899: case 5:
1900: return $this->getEcotax();
1901: break;
1902: case 6:
1903: return $this->getNewness();
1904: break;
1905: case 7:
1906: return $this->getPromo();
1907: break;
1908: case 8:
1909: return $this->getStock();
1910: break;
1911: case 9:
1912: return $this->getVisible();
1913: break;
1914: case 10:
1915: return $this->getWeight();
1916: break;
1917: case 11:
1918: return $this->getPosition();
1919: break;
1920: case 12:
1921: return $this->getCreatedAt();
1922: break;
1923: case 13:
1924: return $this->getUpdatedAt();
1925: break;
1926: case 14:
1927: return $this->getVersion();
1928: break;
1929: case 15:
1930: return $this->getVersionCreatedAt();
1931: break;
1932: case 16:
1933: return $this->getVersionCreatedBy();
1934: break;
1935: default:
1936: return null;
1937: break;
1938: }
1939: }
1940:
1941: 1942: 1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950: 1951: 1952: 1953: 1954: 1955:
1956: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1957: {
1958: if (isset($alreadyDumpedObjects['Product'][$this->getPrimaryKey()])) {
1959: return '*RECURSION*';
1960: }
1961: $alreadyDumpedObjects['Product'][$this->getPrimaryKey()] = true;
1962: $keys = ProductPeer::getFieldNames($keyType);
1963: $result = array(
1964: $keys[0] => $this->getId(),
1965: $keys[1] => $this->getTaxRuleId(),
1966: $keys[2] => $this->getRef(),
1967: $keys[3] => $this->getPrice(),
1968: $keys[4] => $this->getPrice2(),
1969: $keys[5] => $this->getEcotax(),
1970: $keys[6] => $this->getNewness(),
1971: $keys[7] => $this->getPromo(),
1972: $keys[8] => $this->getStock(),
1973: $keys[9] => $this->getVisible(),
1974: $keys[10] => $this->getWeight(),
1975: $keys[11] => $this->getPosition(),
1976: $keys[12] => $this->getCreatedAt(),
1977: $keys[13] => $this->getUpdatedAt(),
1978: $keys[14] => $this->getVersion(),
1979: $keys[15] => $this->getVersionCreatedAt(),
1980: $keys[16] => $this->getVersionCreatedBy(),
1981: );
1982: if ($includeForeignObjects) {
1983: if (null !== $this->aTaxRule) {
1984: $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
1985: }
1986: if (null !== $this->collProductCategorys) {
1987: $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1988: }
1989: if (null !== $this->collFeatureProds) {
1990: $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1991: }
1992: if (null !== $this->collStocks) {
1993: $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1994: }
1995: if (null !== $this->collContentAssocs) {
1996: $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1997: }
1998: if (null !== $this->collImages) {
1999: $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2000: }
2001: if (null !== $this->collDocuments) {
2002: $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2003: }
2004: if (null !== $this->collAccessorysRelatedByProductId) {
2005: $result['AccessorysRelatedByProductId'] = $this->collAccessorysRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2006: }
2007: if (null !== $this->collAccessorysRelatedByAccessory) {
2008: $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2009: }
2010: if (null !== $this->collRewritings) {
2011: $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2012: }
2013: if (null !== $this->collProductI18ns) {
2014: $result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2015: }
2016: if (null !== $this->collProductVersions) {
2017: $result['ProductVersions'] = $this->collProductVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
2018: }
2019: }
2020:
2021: return $result;
2022: }
2023:
2024: 2025: 2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034:
2035: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
2036: {
2037: $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
2038:
2039: $this->setByPosition($pos, $value);
2040: }
2041:
2042: 2043: 2044: 2045: 2046: 2047: 2048: 2049:
2050: public function setByPosition($pos, $value)
2051: {
2052: switch ($pos) {
2053: case 0:
2054: $this->setId($value);
2055: break;
2056: case 1:
2057: $this->setTaxRuleId($value);
2058: break;
2059: case 2:
2060: $this->setRef($value);
2061: break;
2062: case 3:
2063: $this->setPrice($value);
2064: break;
2065: case 4:
2066: $this->setPrice2($value);
2067: break;
2068: case 5:
2069: $this->setEcotax($value);
2070: break;
2071: case 6:
2072: $this->setNewness($value);
2073: break;
2074: case 7:
2075: $this->setPromo($value);
2076: break;
2077: case 8:
2078: $this->setStock($value);
2079: break;
2080: case 9:
2081: $this->setVisible($value);
2082: break;
2083: case 10:
2084: $this->setWeight($value);
2085: break;
2086: case 11:
2087: $this->setPosition($value);
2088: break;
2089: case 12:
2090: $this->setCreatedAt($value);
2091: break;
2092: case 13:
2093: $this->setUpdatedAt($value);
2094: break;
2095: case 14:
2096: $this->setVersion($value);
2097: break;
2098: case 15:
2099: $this->setVersionCreatedAt($value);
2100: break;
2101: case 16:
2102: $this->setVersionCreatedBy($value);
2103: break;
2104: }
2105: }
2106:
2107: 2108: 2109: 2110: 2111: 2112: 2113: 2114: 2115: 2116: 2117: 2118: 2119: 2120: 2121: 2122: 2123:
2124: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
2125: {
2126: $keys = ProductPeer::getFieldNames($keyType);
2127:
2128: if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
2129: if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
2130: if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
2131: if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
2132: if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]);
2133: if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]);
2134: if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]);
2135: if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]);
2136: if (array_key_exists($keys[8], $arr)) $this->setStock($arr[$keys[8]]);
2137: if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
2138: if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
2139: if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
2140: if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
2141: if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
2142: if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
2143: if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
2144: if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
2145: }
2146:
2147: 2148: 2149: 2150: 2151:
2152: public function buildCriteria()
2153: {
2154: $criteria = new Criteria(ProductPeer::DATABASE_NAME);
2155:
2156: if ($this->isColumnModified(ProductPeer::ID)) $criteria->add(ProductPeer::ID, $this->id);
2157: if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) $criteria->add(ProductPeer::TAX_RULE_ID, $this->tax_rule_id);
2158: if ($this->isColumnModified(ProductPeer::REF)) $criteria->add(ProductPeer::REF, $this->ref);
2159: if ($this->isColumnModified(ProductPeer::PRICE)) $criteria->add(ProductPeer::PRICE, $this->price);
2160: if ($this->isColumnModified(ProductPeer::PRICE2)) $criteria->add(ProductPeer::PRICE2, $this->price2);
2161: if ($this->isColumnModified(ProductPeer::ECOTAX)) $criteria->add(ProductPeer::ECOTAX, $this->ecotax);
2162: if ($this->isColumnModified(ProductPeer::NEWNESS)) $criteria->add(ProductPeer::NEWNESS, $this->newness);
2163: if ($this->isColumnModified(ProductPeer::PROMO)) $criteria->add(ProductPeer::PROMO, $this->promo);
2164: if ($this->isColumnModified(ProductPeer::STOCK)) $criteria->add(ProductPeer::STOCK, $this->stock);
2165: if ($this->isColumnModified(ProductPeer::VISIBLE)) $criteria->add(ProductPeer::VISIBLE, $this->visible);
2166: if ($this->isColumnModified(ProductPeer::WEIGHT)) $criteria->add(ProductPeer::WEIGHT, $this->weight);
2167: if ($this->isColumnModified(ProductPeer::POSITION)) $criteria->add(ProductPeer::POSITION, $this->position);
2168: if ($this->isColumnModified(ProductPeer::CREATED_AT)) $criteria->add(ProductPeer::CREATED_AT, $this->created_at);
2169: if ($this->isColumnModified(ProductPeer::UPDATED_AT)) $criteria->add(ProductPeer::UPDATED_AT, $this->updated_at);
2170: if ($this->isColumnModified(ProductPeer::VERSION)) $criteria->add(ProductPeer::VERSION, $this->version);
2171: if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) $criteria->add(ProductPeer::VERSION_CREATED_AT, $this->version_created_at);
2172: if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) $criteria->add(ProductPeer::VERSION_CREATED_BY, $this->version_created_by);
2173:
2174: return $criteria;
2175: }
2176:
2177: 2178: 2179: 2180: 2181: 2182: 2183: 2184:
2185: public function buildPkeyCriteria()
2186: {
2187: $criteria = new Criteria(ProductPeer::DATABASE_NAME);
2188: $criteria->add(ProductPeer::ID, $this->id);
2189:
2190: return $criteria;
2191: }
2192:
2193: 2194: 2195: 2196:
2197: public function getPrimaryKey()
2198: {
2199: return $this->getId();
2200: }
2201:
2202: 2203: 2204: 2205: 2206: 2207:
2208: public function setPrimaryKey($key)
2209: {
2210: $this->setId($key);
2211: }
2212:
2213: 2214: 2215: 2216:
2217: public function isPrimaryKeyNull()
2218: {
2219:
2220: return null === $this->getId();
2221: }
2222:
2223: 2224: 2225: 2226: 2227: 2228: 2229: 2230: 2231: 2232: 2233:
2234: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
2235: {
2236: $copyObj->setTaxRuleId($this->getTaxRuleId());
2237: $copyObj->setRef($this->getRef());
2238: $copyObj->setPrice($this->getPrice());
2239: $copyObj->setPrice2($this->getPrice2());
2240: $copyObj->setEcotax($this->getEcotax());
2241: $copyObj->setNewness($this->getNewness());
2242: $copyObj->setPromo($this->getPromo());
2243: $copyObj->setStock($this->getStock());
2244: $copyObj->setVisible($this->getVisible());
2245: $copyObj->setWeight($this->getWeight());
2246: $copyObj->setPosition($this->getPosition());
2247: $copyObj->setCreatedAt($this->getCreatedAt());
2248: $copyObj->setUpdatedAt($this->getUpdatedAt());
2249: $copyObj->setVersion($this->getVersion());
2250: $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
2251: $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
2252:
2253: if ($deepCopy && !$this->startCopy) {
2254:
2255:
2256: $copyObj->setNew(false);
2257:
2258: $this->startCopy = true;
2259:
2260: foreach ($this->getProductCategorys() as $relObj) {
2261: if ($relObj !== $this) {
2262: $copyObj->addProductCategory($relObj->copy($deepCopy));
2263: }
2264: }
2265:
2266: foreach ($this->getFeatureProds() as $relObj) {
2267: if ($relObj !== $this) {
2268: $copyObj->addFeatureProd($relObj->copy($deepCopy));
2269: }
2270: }
2271:
2272: foreach ($this->getStocks() as $relObj) {
2273: if ($relObj !== $this) {
2274: $copyObj->addStock($relObj->copy($deepCopy));
2275: }
2276: }
2277:
2278: foreach ($this->getContentAssocs() as $relObj) {
2279: if ($relObj !== $this) {
2280: $copyObj->addContentAssoc($relObj->copy($deepCopy));
2281: }
2282: }
2283:
2284: foreach ($this->getImages() as $relObj) {
2285: if ($relObj !== $this) {
2286: $copyObj->addImage($relObj->copy($deepCopy));
2287: }
2288: }
2289:
2290: foreach ($this->getDocuments() as $relObj) {
2291: if ($relObj !== $this) {
2292: $copyObj->addDocument($relObj->copy($deepCopy));
2293: }
2294: }
2295:
2296: foreach ($this->getAccessorysRelatedByProductId() as $relObj) {
2297: if ($relObj !== $this) {
2298: $copyObj->addAccessoryRelatedByProductId($relObj->copy($deepCopy));
2299: }
2300: }
2301:
2302: foreach ($this->getAccessorysRelatedByAccessory() as $relObj) {
2303: if ($relObj !== $this) {
2304: $copyObj->addAccessoryRelatedByAccessory($relObj->copy($deepCopy));
2305: }
2306: }
2307:
2308: foreach ($this->getRewritings() as $relObj) {
2309: if ($relObj !== $this) {
2310: $copyObj->addRewriting($relObj->copy($deepCopy));
2311: }
2312: }
2313:
2314: foreach ($this->getProductI18ns() as $relObj) {
2315: if ($relObj !== $this) {
2316: $copyObj->addProductI18n($relObj->copy($deepCopy));
2317: }
2318: }
2319:
2320: foreach ($this->getProductVersions() as $relObj) {
2321: if ($relObj !== $this) {
2322: $copyObj->addProductVersion($relObj->copy($deepCopy));
2323: }
2324: }
2325:
2326:
2327: $this->startCopy = false;
2328: }
2329:
2330: if ($makeNew) {
2331: $copyObj->setNew(true);
2332: $copyObj->setId(NULL);
2333: }
2334: }
2335:
2336: 2337: 2338: 2339: 2340: 2341: 2342: 2343: 2344: 2345: 2346: 2347:
2348: public function copy($deepCopy = false)
2349: {
2350:
2351: $clazz = get_class($this);
2352: $copyObj = new $clazz();
2353: $this->copyInto($copyObj, $deepCopy);
2354:
2355: return $copyObj;
2356: }
2357:
2358: 2359: 2360: 2361: 2362: 2363: 2364: 2365: 2366:
2367: public function getPeer()
2368: {
2369: if (self::$peer === null) {
2370: self::$peer = new ProductPeer();
2371: }
2372:
2373: return self::$peer;
2374: }
2375:
2376: 2377: 2378: 2379: 2380: 2381: 2382:
2383: public function setTaxRule(TaxRule $v = null)
2384: {
2385: if ($v === null) {
2386: $this->setTaxRuleId(NULL);
2387: } else {
2388: $this->setTaxRuleId($v->getId());
2389: }
2390:
2391: $this->aTaxRule = $v;
2392:
2393:
2394:
2395: if ($v !== null) {
2396: $v->addProduct($this);
2397: }
2398:
2399:
2400: return $this;
2401: }
2402:
2403:
2404: 2405: 2406: 2407: 2408: 2409: 2410:
2411: public function getTaxRule(PropelPDO $con = null)
2412: {
2413: if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
2414: $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con);
2415: 2416: 2417: 2418: 2419: 2420: 2421:
2422: }
2423:
2424: return $this->aTaxRule;
2425: }
2426:
2427:
2428: 2429: 2430: 2431: 2432: 2433: 2434: 2435:
2436: public function initRelation($relationName)
2437: {
2438: if ('ProductCategory' == $relationName) {
2439: $this->initProductCategorys();
2440: }
2441: if ('FeatureProd' == $relationName) {
2442: $this->initFeatureProds();
2443: }
2444: if ('Stock' == $relationName) {
2445: $this->initStocks();
2446: }
2447: if ('ContentAssoc' == $relationName) {
2448: $this->initContentAssocs();
2449: }
2450: if ('Image' == $relationName) {
2451: $this->initImages();
2452: }
2453: if ('Document' == $relationName) {
2454: $this->initDocuments();
2455: }
2456: if ('AccessoryRelatedByProductId' == $relationName) {
2457: $this->initAccessorysRelatedByProductId();
2458: }
2459: if ('AccessoryRelatedByAccessory' == $relationName) {
2460: $this->initAccessorysRelatedByAccessory();
2461: }
2462: if ('Rewriting' == $relationName) {
2463: $this->initRewritings();
2464: }
2465: if ('ProductI18n' == $relationName) {
2466: $this->initProductI18ns();
2467: }
2468: if ('ProductVersion' == $relationName) {
2469: $this->initProductVersions();
2470: }
2471: }
2472:
2473: 2474: 2475: 2476: 2477: 2478: 2479: 2480: 2481:
2482: public function clearProductCategorys()
2483: {
2484: $this->collProductCategorys = null;
2485: $this->collProductCategorysPartial = null;
2486: }
2487:
2488: 2489: 2490: 2491: 2492:
2493: public function resetPartialProductCategorys($v = true)
2494: {
2495: $this->collProductCategorysPartial = $v;
2496: }
2497:
2498: 2499: 2500: 2501: 2502: 2503: 2504: 2505: 2506: 2507: 2508: 2509:
2510: public function initProductCategorys($overrideExisting = true)
2511: {
2512: if (null !== $this->collProductCategorys && !$overrideExisting) {
2513: return;
2514: }
2515: $this->collProductCategorys = new PropelObjectCollection();
2516: $this->collProductCategorys->setModel('ProductCategory');
2517: }
2518:
2519: 2520: 2521: 2522: 2523: 2524: 2525: 2526: 2527: 2528: 2529: 2530: 2531: 2532:
2533: public function getProductCategorys($criteria = null, PropelPDO $con = null)
2534: {
2535: $partial = $this->collProductCategorysPartial && !$this->isNew();
2536: if (null === $this->collProductCategorys || null !== $criteria || $partial) {
2537: if ($this->isNew() && null === $this->collProductCategorys) {
2538:
2539: $this->initProductCategorys();
2540: } else {
2541: $collProductCategorys = ProductCategoryQuery::create(null, $criteria)
2542: ->filterByProduct($this)
2543: ->find($con);
2544: if (null !== $criteria) {
2545: if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) {
2546: $this->initProductCategorys(false);
2547:
2548: foreach($collProductCategorys as $obj) {
2549: if (false == $this->collProductCategorys->contains($obj)) {
2550: $this->collProductCategorys->append($obj);
2551: }
2552: }
2553:
2554: $this->collProductCategorysPartial = true;
2555: }
2556:
2557: return $collProductCategorys;
2558: }
2559:
2560: if($partial && $this->collProductCategorys) {
2561: foreach($this->collProductCategorys as $obj) {
2562: if($obj->isNew()) {
2563: $collProductCategorys[] = $obj;
2564: }
2565: }
2566: }
2567:
2568: $this->collProductCategorys = $collProductCategorys;
2569: $this->collProductCategorysPartial = false;
2570: }
2571: }
2572:
2573: return $this->collProductCategorys;
2574: }
2575:
2576: 2577: 2578: 2579: 2580: 2581: 2582: 2583: 2584:
2585: public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null)
2586: {
2587: $this->productCategorysScheduledForDeletion = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys);
2588:
2589: foreach ($this->productCategorysScheduledForDeletion as $productCategoryRemoved) {
2590: $productCategoryRemoved->setProduct(null);
2591: }
2592:
2593: $this->collProductCategorys = null;
2594: foreach ($productCategorys as $productCategory) {
2595: $this->addProductCategory($productCategory);
2596: }
2597:
2598: $this->collProductCategorys = $productCategorys;
2599: $this->collProductCategorysPartial = false;
2600: }
2601:
2602: 2603: 2604: 2605: 2606: 2607: 2608: 2609: 2610:
2611: public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2612: {
2613: $partial = $this->collProductCategorysPartial && !$this->isNew();
2614: if (null === $this->collProductCategorys || null !== $criteria || $partial) {
2615: if ($this->isNew() && null === $this->collProductCategorys) {
2616: return 0;
2617: } else {
2618: if($partial && !$criteria) {
2619: return count($this->getProductCategorys());
2620: }
2621: $query = ProductCategoryQuery::create(null, $criteria);
2622: if ($distinct) {
2623: $query->distinct();
2624: }
2625:
2626: return $query
2627: ->filterByProduct($this)
2628: ->count($con);
2629: }
2630: } else {
2631: return count($this->collProductCategorys);
2632: }
2633: }
2634:
2635: 2636: 2637: 2638: 2639: 2640: 2641:
2642: public function addProductCategory(ProductCategory $l)
2643: {
2644: if ($this->collProductCategorys === null) {
2645: $this->initProductCategorys();
2646: $this->collProductCategorysPartial = true;
2647: }
2648: if (!$this->collProductCategorys->contains($l)) {
2649: $this->doAddProductCategory($l);
2650: }
2651:
2652: return $this;
2653: }
2654:
2655: 2656: 2657:
2658: protected function doAddProductCategory($productCategory)
2659: {
2660: $this->collProductCategorys[]= $productCategory;
2661: $productCategory->setProduct($this);
2662: }
2663:
2664: 2665: 2666:
2667: public function removeProductCategory($productCategory)
2668: {
2669: if ($this->getProductCategorys()->contains($productCategory)) {
2670: $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory));
2671: if (null === $this->productCategorysScheduledForDeletion) {
2672: $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys;
2673: $this->productCategorysScheduledForDeletion->clear();
2674: }
2675: $this->productCategorysScheduledForDeletion[]= $productCategory;
2676: $productCategory->setProduct(null);
2677: }
2678: }
2679:
2680:
2681: 2682: 2683: 2684: 2685: 2686: 2687: 2688: 2689: 2690: 2691: 2692: 2693: 2694: 2695: 2696:
2697: public function getProductCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2698: {
2699: $query = ProductCategoryQuery::create(null, $criteria);
2700: $query->joinWith('Category', $join_behavior);
2701:
2702: return $this->getProductCategorys($query, $con);
2703: }
2704:
2705: 2706: 2707: 2708: 2709: 2710: 2711: 2712: 2713:
2714: public function clearFeatureProds()
2715: {
2716: $this->collFeatureProds = null;
2717: $this->collFeatureProdsPartial = null;
2718: }
2719:
2720: 2721: 2722: 2723: 2724:
2725: public function resetPartialFeatureProds($v = true)
2726: {
2727: $this->collFeatureProdsPartial = $v;
2728: }
2729:
2730: 2731: 2732: 2733: 2734: 2735: 2736: 2737: 2738: 2739: 2740: 2741:
2742: public function initFeatureProds($overrideExisting = true)
2743: {
2744: if (null !== $this->collFeatureProds && !$overrideExisting) {
2745: return;
2746: }
2747: $this->collFeatureProds = new PropelObjectCollection();
2748: $this->collFeatureProds->setModel('FeatureProd');
2749: }
2750:
2751: 2752: 2753: 2754: 2755: 2756: 2757: 2758: 2759: 2760: 2761: 2762: 2763: 2764:
2765: public function getFeatureProds($criteria = null, PropelPDO $con = null)
2766: {
2767: $partial = $this->collFeatureProdsPartial && !$this->isNew();
2768: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
2769: if ($this->isNew() && null === $this->collFeatureProds) {
2770:
2771: $this->initFeatureProds();
2772: } else {
2773: $collFeatureProds = FeatureProdQuery::create(null, $criteria)
2774: ->filterByProduct($this)
2775: ->find($con);
2776: if (null !== $criteria) {
2777: if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
2778: $this->initFeatureProds(false);
2779:
2780: foreach($collFeatureProds as $obj) {
2781: if (false == $this->collFeatureProds->contains($obj)) {
2782: $this->collFeatureProds->append($obj);
2783: }
2784: }
2785:
2786: $this->collFeatureProdsPartial = true;
2787: }
2788:
2789: return $collFeatureProds;
2790: }
2791:
2792: if($partial && $this->collFeatureProds) {
2793: foreach($this->collFeatureProds as $obj) {
2794: if($obj->isNew()) {
2795: $collFeatureProds[] = $obj;
2796: }
2797: }
2798: }
2799:
2800: $this->collFeatureProds = $collFeatureProds;
2801: $this->collFeatureProdsPartial = false;
2802: }
2803: }
2804:
2805: return $this->collFeatureProds;
2806: }
2807:
2808: 2809: 2810: 2811: 2812: 2813: 2814: 2815: 2816:
2817: public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null)
2818: {
2819: $this->featureProdsScheduledForDeletion = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
2820:
2821: foreach ($this->featureProdsScheduledForDeletion as $featureProdRemoved) {
2822: $featureProdRemoved->setProduct(null);
2823: }
2824:
2825: $this->collFeatureProds = null;
2826: foreach ($featureProds as $featureProd) {
2827: $this->addFeatureProd($featureProd);
2828: }
2829:
2830: $this->collFeatureProds = $featureProds;
2831: $this->collFeatureProdsPartial = false;
2832: }
2833:
2834: 2835: 2836: 2837: 2838: 2839: 2840: 2841: 2842:
2843: public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2844: {
2845: $partial = $this->collFeatureProdsPartial && !$this->isNew();
2846: if (null === $this->collFeatureProds || null !== $criteria || $partial) {
2847: if ($this->isNew() && null === $this->collFeatureProds) {
2848: return 0;
2849: } else {
2850: if($partial && !$criteria) {
2851: return count($this->getFeatureProds());
2852: }
2853: $query = FeatureProdQuery::create(null, $criteria);
2854: if ($distinct) {
2855: $query->distinct();
2856: }
2857:
2858: return $query
2859: ->filterByProduct($this)
2860: ->count($con);
2861: }
2862: } else {
2863: return count($this->collFeatureProds);
2864: }
2865: }
2866:
2867: 2868: 2869: 2870: 2871: 2872: 2873:
2874: public function addFeatureProd(FeatureProd $l)
2875: {
2876: if ($this->collFeatureProds === null) {
2877: $this->initFeatureProds();
2878: $this->collFeatureProdsPartial = true;
2879: }
2880: if (!$this->collFeatureProds->contains($l)) {
2881: $this->doAddFeatureProd($l);
2882: }
2883:
2884: return $this;
2885: }
2886:
2887: 2888: 2889:
2890: protected function doAddFeatureProd($featureProd)
2891: {
2892: $this->collFeatureProds[]= $featureProd;
2893: $featureProd->setProduct($this);
2894: }
2895:
2896: 2897: 2898:
2899: public function removeFeatureProd($featureProd)
2900: {
2901: if ($this->getFeatureProds()->contains($featureProd)) {
2902: $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
2903: if (null === $this->featureProdsScheduledForDeletion) {
2904: $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
2905: $this->featureProdsScheduledForDeletion->clear();
2906: }
2907: $this->featureProdsScheduledForDeletion[]= $featureProd;
2908: $featureProd->setProduct(null);
2909: }
2910: }
2911:
2912:
2913: 2914: 2915: 2916: 2917: 2918: 2919: 2920: 2921: 2922: 2923: 2924: 2925: 2926: 2927: 2928:
2929: public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2930: {
2931: $query = FeatureProdQuery::create(null, $criteria);
2932: $query->joinWith('Feature', $join_behavior);
2933:
2934: return $this->getFeatureProds($query, $con);
2935: }
2936:
2937:
2938: 2939: 2940: 2941: 2942: 2943: 2944: 2945: 2946: 2947: 2948: 2949: 2950: 2951: 2952: 2953:
2954: public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2955: {
2956: $query = FeatureProdQuery::create(null, $criteria);
2957: $query->joinWith('FeatureAv', $join_behavior);
2958:
2959: return $this->getFeatureProds($query, $con);
2960: }
2961:
2962: 2963: 2964: 2965: 2966: 2967: 2968: 2969: 2970:
2971: public function clearStocks()
2972: {
2973: $this->collStocks = null;
2974: $this->collStocksPartial = null;
2975: }
2976:
2977: 2978: 2979: 2980: 2981:
2982: public function resetPartialStocks($v = true)
2983: {
2984: $this->collStocksPartial = $v;
2985: }
2986:
2987: 2988: 2989: 2990: 2991: 2992: 2993: 2994: 2995: 2996: 2997: 2998:
2999: public function initStocks($overrideExisting = true)
3000: {
3001: if (null !== $this->collStocks && !$overrideExisting) {
3002: return;
3003: }
3004: $this->collStocks = new PropelObjectCollection();
3005: $this->collStocks->setModel('Stock');
3006: }
3007:
3008: 3009: 3010: 3011: 3012: 3013: 3014: 3015: 3016: 3017: 3018: 3019: 3020: 3021:
3022: public function getStocks($criteria = null, PropelPDO $con = null)
3023: {
3024: $partial = $this->collStocksPartial && !$this->isNew();
3025: if (null === $this->collStocks || null !== $criteria || $partial) {
3026: if ($this->isNew() && null === $this->collStocks) {
3027:
3028: $this->initStocks();
3029: } else {
3030: $collStocks = StockQuery::create(null, $criteria)
3031: ->filterByProduct($this)
3032: ->find($con);
3033: if (null !== $criteria) {
3034: if (false !== $this->collStocksPartial && count($collStocks)) {
3035: $this->initStocks(false);
3036:
3037: foreach($collStocks as $obj) {
3038: if (false == $this->collStocks->contains($obj)) {
3039: $this->collStocks->append($obj);
3040: }
3041: }
3042:
3043: $this->collStocksPartial = true;
3044: }
3045:
3046: return $collStocks;
3047: }
3048:
3049: if($partial && $this->collStocks) {
3050: foreach($this->collStocks as $obj) {
3051: if($obj->isNew()) {
3052: $collStocks[] = $obj;
3053: }
3054: }
3055: }
3056:
3057: $this->collStocks = $collStocks;
3058: $this->collStocksPartial = false;
3059: }
3060: }
3061:
3062: return $this->collStocks;
3063: }
3064:
3065: 3066: 3067: 3068: 3069: 3070: 3071: 3072: 3073:
3074: public function setStocks(PropelCollection $stocks, PropelPDO $con = null)
3075: {
3076: $this->stocksScheduledForDeletion = $this->getStocks(new Criteria(), $con)->diff($stocks);
3077:
3078: foreach ($this->stocksScheduledForDeletion as $stockRemoved) {
3079: $stockRemoved->setProduct(null);
3080: }
3081:
3082: $this->collStocks = null;
3083: foreach ($stocks as $stock) {
3084: $this->addStock($stock);
3085: }
3086:
3087: $this->collStocks = $stocks;
3088: $this->collStocksPartial = false;
3089: }
3090:
3091: 3092: 3093: 3094: 3095: 3096: 3097: 3098: 3099:
3100: public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3101: {
3102: $partial = $this->collStocksPartial && !$this->isNew();
3103: if (null === $this->collStocks || null !== $criteria || $partial) {
3104: if ($this->isNew() && null === $this->collStocks) {
3105: return 0;
3106: } else {
3107: if($partial && !$criteria) {
3108: return count($this->getStocks());
3109: }
3110: $query = StockQuery::create(null, $criteria);
3111: if ($distinct) {
3112: $query->distinct();
3113: }
3114:
3115: return $query
3116: ->filterByProduct($this)
3117: ->count($con);
3118: }
3119: } else {
3120: return count($this->collStocks);
3121: }
3122: }
3123:
3124: 3125: 3126: 3127: 3128: 3129: 3130:
3131: public function addStock(Stock $l)
3132: {
3133: if ($this->collStocks === null) {
3134: $this->initStocks();
3135: $this->collStocksPartial = true;
3136: }
3137: if (!$this->collStocks->contains($l)) {
3138: $this->doAddStock($l);
3139: }
3140:
3141: return $this;
3142: }
3143:
3144: 3145: 3146:
3147: protected function doAddStock($stock)
3148: {
3149: $this->collStocks[]= $stock;
3150: $stock->setProduct($this);
3151: }
3152:
3153: 3154: 3155:
3156: public function removeStock($stock)
3157: {
3158: if ($this->getStocks()->contains($stock)) {
3159: $this->collStocks->remove($this->collStocks->search($stock));
3160: if (null === $this->stocksScheduledForDeletion) {
3161: $this->stocksScheduledForDeletion = clone $this->collStocks;
3162: $this->stocksScheduledForDeletion->clear();
3163: }
3164: $this->stocksScheduledForDeletion[]= $stock;
3165: $stock->setProduct(null);
3166: }
3167: }
3168:
3169:
3170: 3171: 3172: 3173: 3174: 3175: 3176: 3177: 3178: 3179: 3180: 3181: 3182: 3183: 3184: 3185:
3186: public function getStocksJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3187: {
3188: $query = StockQuery::create(null, $criteria);
3189: $query->joinWith('Combination', $join_behavior);
3190:
3191: return $this->getStocks($query, $con);
3192: }
3193:
3194: 3195: 3196: 3197: 3198: 3199: 3200: 3201: 3202:
3203: public function clearContentAssocs()
3204: {
3205: $this->collContentAssocs = null;
3206: $this->collContentAssocsPartial = null;
3207: }
3208:
3209: 3210: 3211: 3212: 3213:
3214: public function resetPartialContentAssocs($v = true)
3215: {
3216: $this->collContentAssocsPartial = $v;
3217: }
3218:
3219: 3220: 3221: 3222: 3223: 3224: 3225: 3226: 3227: 3228: 3229: 3230:
3231: public function initContentAssocs($overrideExisting = true)
3232: {
3233: if (null !== $this->collContentAssocs && !$overrideExisting) {
3234: return;
3235: }
3236: $this->collContentAssocs = new PropelObjectCollection();
3237: $this->collContentAssocs->setModel('ContentAssoc');
3238: }
3239:
3240: 3241: 3242: 3243: 3244: 3245: 3246: 3247: 3248: 3249: 3250: 3251: 3252: 3253:
3254: public function getContentAssocs($criteria = null, PropelPDO $con = null)
3255: {
3256: $partial = $this->collContentAssocsPartial && !$this->isNew();
3257: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
3258: if ($this->isNew() && null === $this->collContentAssocs) {
3259:
3260: $this->initContentAssocs();
3261: } else {
3262: $collContentAssocs = ContentAssocQuery::create(null, $criteria)
3263: ->filterByProduct($this)
3264: ->find($con);
3265: if (null !== $criteria) {
3266: if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
3267: $this->initContentAssocs(false);
3268:
3269: foreach($collContentAssocs as $obj) {
3270: if (false == $this->collContentAssocs->contains($obj)) {
3271: $this->collContentAssocs->append($obj);
3272: }
3273: }
3274:
3275: $this->collContentAssocsPartial = true;
3276: }
3277:
3278: return $collContentAssocs;
3279: }
3280:
3281: if($partial && $this->collContentAssocs) {
3282: foreach($this->collContentAssocs as $obj) {
3283: if($obj->isNew()) {
3284: $collContentAssocs[] = $obj;
3285: }
3286: }
3287: }
3288:
3289: $this->collContentAssocs = $collContentAssocs;
3290: $this->collContentAssocsPartial = false;
3291: }
3292: }
3293:
3294: return $this->collContentAssocs;
3295: }
3296:
3297: 3298: 3299: 3300: 3301: 3302: 3303: 3304: 3305:
3306: public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null)
3307: {
3308: $this->contentAssocsScheduledForDeletion = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
3309:
3310: foreach ($this->contentAssocsScheduledForDeletion as $contentAssocRemoved) {
3311: $contentAssocRemoved->setProduct(null);
3312: }
3313:
3314: $this->collContentAssocs = null;
3315: foreach ($contentAssocs as $contentAssoc) {
3316: $this->addContentAssoc($contentAssoc);
3317: }
3318:
3319: $this->collContentAssocs = $contentAssocs;
3320: $this->collContentAssocsPartial = false;
3321: }
3322:
3323: 3324: 3325: 3326: 3327: 3328: 3329: 3330: 3331:
3332: public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3333: {
3334: $partial = $this->collContentAssocsPartial && !$this->isNew();
3335: if (null === $this->collContentAssocs || null !== $criteria || $partial) {
3336: if ($this->isNew() && null === $this->collContentAssocs) {
3337: return 0;
3338: } else {
3339: if($partial && !$criteria) {
3340: return count($this->getContentAssocs());
3341: }
3342: $query = ContentAssocQuery::create(null, $criteria);
3343: if ($distinct) {
3344: $query->distinct();
3345: }
3346:
3347: return $query
3348: ->filterByProduct($this)
3349: ->count($con);
3350: }
3351: } else {
3352: return count($this->collContentAssocs);
3353: }
3354: }
3355:
3356: 3357: 3358: 3359: 3360: 3361: 3362:
3363: public function addContentAssoc(ContentAssoc $l)
3364: {
3365: if ($this->collContentAssocs === null) {
3366: $this->initContentAssocs();
3367: $this->collContentAssocsPartial = true;
3368: }
3369: if (!$this->collContentAssocs->contains($l)) {
3370: $this->doAddContentAssoc($l);
3371: }
3372:
3373: return $this;
3374: }
3375:
3376: 3377: 3378:
3379: protected function doAddContentAssoc($contentAssoc)
3380: {
3381: $this->collContentAssocs[]= $contentAssoc;
3382: $contentAssoc->setProduct($this);
3383: }
3384:
3385: 3386: 3387:
3388: public function removeContentAssoc($contentAssoc)
3389: {
3390: if ($this->getContentAssocs()->contains($contentAssoc)) {
3391: $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
3392: if (null === $this->contentAssocsScheduledForDeletion) {
3393: $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
3394: $this->contentAssocsScheduledForDeletion->clear();
3395: }
3396: $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
3397: $contentAssoc->setProduct(null);
3398: }
3399: }
3400:
3401:
3402: 3403: 3404: 3405: 3406: 3407: 3408: 3409: 3410: 3411: 3412: 3413: 3414: 3415: 3416: 3417:
3418: public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3419: {
3420: $query = ContentAssocQuery::create(null, $criteria);
3421: $query->joinWith('Category', $join_behavior);
3422:
3423: return $this->getContentAssocs($query, $con);
3424: }
3425:
3426:
3427: 3428: 3429: 3430: 3431: 3432: 3433: 3434: 3435: 3436: 3437: 3438: 3439: 3440: 3441: 3442:
3443: public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3444: {
3445: $query = ContentAssocQuery::create(null, $criteria);
3446: $query->joinWith('Content', $join_behavior);
3447:
3448: return $this->getContentAssocs($query, $con);
3449: }
3450:
3451: 3452: 3453: 3454: 3455: 3456: 3457: 3458: 3459:
3460: public function clearImages()
3461: {
3462: $this->collImages = null;
3463: $this->collImagesPartial = null;
3464: }
3465:
3466: 3467: 3468: 3469: 3470:
3471: public function resetPartialImages($v = true)
3472: {
3473: $this->collImagesPartial = $v;
3474: }
3475:
3476: 3477: 3478: 3479: 3480: 3481: 3482: 3483: 3484: 3485: 3486: 3487:
3488: public function initImages($overrideExisting = true)
3489: {
3490: if (null !== $this->collImages && !$overrideExisting) {
3491: return;
3492: }
3493: $this->collImages = new PropelObjectCollection();
3494: $this->collImages->setModel('Image');
3495: }
3496:
3497: 3498: 3499: 3500: 3501: 3502: 3503: 3504: 3505: 3506: 3507: 3508: 3509: 3510:
3511: public function getImages($criteria = null, PropelPDO $con = null)
3512: {
3513: $partial = $this->collImagesPartial && !$this->isNew();
3514: if (null === $this->collImages || null !== $criteria || $partial) {
3515: if ($this->isNew() && null === $this->collImages) {
3516:
3517: $this->initImages();
3518: } else {
3519: $collImages = ImageQuery::create(null, $criteria)
3520: ->filterByProduct($this)
3521: ->find($con);
3522: if (null !== $criteria) {
3523: if (false !== $this->collImagesPartial && count($collImages)) {
3524: $this->initImages(false);
3525:
3526: foreach($collImages as $obj) {
3527: if (false == $this->collImages->contains($obj)) {
3528: $this->collImages->append($obj);
3529: }
3530: }
3531:
3532: $this->collImagesPartial = true;
3533: }
3534:
3535: return $collImages;
3536: }
3537:
3538: if($partial && $this->collImages) {
3539: foreach($this->collImages as $obj) {
3540: if($obj->isNew()) {
3541: $collImages[] = $obj;
3542: }
3543: }
3544: }
3545:
3546: $this->collImages = $collImages;
3547: $this->collImagesPartial = false;
3548: }
3549: }
3550:
3551: return $this->collImages;
3552: }
3553:
3554: 3555: 3556: 3557: 3558: 3559: 3560: 3561: 3562:
3563: public function setImages(PropelCollection $images, PropelPDO $con = null)
3564: {
3565: $this->imagesScheduledForDeletion = $this->getImages(new Criteria(), $con)->diff($images);
3566:
3567: foreach ($this->imagesScheduledForDeletion as $imageRemoved) {
3568: $imageRemoved->setProduct(null);
3569: }
3570:
3571: $this->collImages = null;
3572: foreach ($images as $image) {
3573: $this->addImage($image);
3574: }
3575:
3576: $this->collImages = $images;
3577: $this->collImagesPartial = false;
3578: }
3579:
3580: 3581: 3582: 3583: 3584: 3585: 3586: 3587: 3588:
3589: public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3590: {
3591: $partial = $this->collImagesPartial && !$this->isNew();
3592: if (null === $this->collImages || null !== $criteria || $partial) {
3593: if ($this->isNew() && null === $this->collImages) {
3594: return 0;
3595: } else {
3596: if($partial && !$criteria) {
3597: return count($this->getImages());
3598: }
3599: $query = ImageQuery::create(null, $criteria);
3600: if ($distinct) {
3601: $query->distinct();
3602: }
3603:
3604: return $query
3605: ->filterByProduct($this)
3606: ->count($con);
3607: }
3608: } else {
3609: return count($this->collImages);
3610: }
3611: }
3612:
3613: 3614: 3615: 3616: 3617: 3618: 3619:
3620: public function addImage(Image $l)
3621: {
3622: if ($this->collImages === null) {
3623: $this->initImages();
3624: $this->collImagesPartial = true;
3625: }
3626: if (!$this->collImages->contains($l)) {
3627: $this->doAddImage($l);
3628: }
3629:
3630: return $this;
3631: }
3632:
3633: 3634: 3635:
3636: protected function doAddImage($image)
3637: {
3638: $this->collImages[]= $image;
3639: $image->setProduct($this);
3640: }
3641:
3642: 3643: 3644:
3645: public function removeImage($image)
3646: {
3647: if ($this->getImages()->contains($image)) {
3648: $this->collImages->remove($this->collImages->search($image));
3649: if (null === $this->imagesScheduledForDeletion) {
3650: $this->imagesScheduledForDeletion = clone $this->collImages;
3651: $this->imagesScheduledForDeletion->clear();
3652: }
3653: $this->imagesScheduledForDeletion[]= $image;
3654: $image->setProduct(null);
3655: }
3656: }
3657:
3658:
3659: 3660: 3661: 3662: 3663: 3664: 3665: 3666: 3667: 3668: 3669: 3670: 3671: 3672: 3673: 3674:
3675: public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3676: {
3677: $query = ImageQuery::create(null, $criteria);
3678: $query->joinWith('Category', $join_behavior);
3679:
3680: return $this->getImages($query, $con);
3681: }
3682:
3683:
3684: 3685: 3686: 3687: 3688: 3689: 3690: 3691: 3692: 3693: 3694: 3695: 3696: 3697: 3698: 3699:
3700: public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3701: {
3702: $query = ImageQuery::create(null, $criteria);
3703: $query->joinWith('Content', $join_behavior);
3704:
3705: return $this->getImages($query, $con);
3706: }
3707:
3708:
3709: 3710: 3711: 3712: 3713: 3714: 3715: 3716: 3717: 3718: 3719: 3720: 3721: 3722: 3723: 3724:
3725: public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3726: {
3727: $query = ImageQuery::create(null, $criteria);
3728: $query->joinWith('Folder', $join_behavior);
3729:
3730: return $this->getImages($query, $con);
3731: }
3732:
3733: 3734: 3735: 3736: 3737: 3738: 3739: 3740: 3741:
3742: public function clearDocuments()
3743: {
3744: $this->collDocuments = null;
3745: $this->collDocumentsPartial = null;
3746: }
3747:
3748: 3749: 3750: 3751: 3752:
3753: public function resetPartialDocuments($v = true)
3754: {
3755: $this->collDocumentsPartial = $v;
3756: }
3757:
3758: 3759: 3760: 3761: 3762: 3763: 3764: 3765: 3766: 3767: 3768: 3769:
3770: public function initDocuments($overrideExisting = true)
3771: {
3772: if (null !== $this->collDocuments && !$overrideExisting) {
3773: return;
3774: }
3775: $this->collDocuments = new PropelObjectCollection();
3776: $this->collDocuments->setModel('Document');
3777: }
3778:
3779: 3780: 3781: 3782: 3783: 3784: 3785: 3786: 3787: 3788: 3789: 3790: 3791: 3792:
3793: public function getDocuments($criteria = null, PropelPDO $con = null)
3794: {
3795: $partial = $this->collDocumentsPartial && !$this->isNew();
3796: if (null === $this->collDocuments || null !== $criteria || $partial) {
3797: if ($this->isNew() && null === $this->collDocuments) {
3798:
3799: $this->initDocuments();
3800: } else {
3801: $collDocuments = DocumentQuery::create(null, $criteria)
3802: ->filterByProduct($this)
3803: ->find($con);
3804: if (null !== $criteria) {
3805: if (false !== $this->collDocumentsPartial && count($collDocuments)) {
3806: $this->initDocuments(false);
3807:
3808: foreach($collDocuments as $obj) {
3809: if (false == $this->collDocuments->contains($obj)) {
3810: $this->collDocuments->append($obj);
3811: }
3812: }
3813:
3814: $this->collDocumentsPartial = true;
3815: }
3816:
3817: return $collDocuments;
3818: }
3819:
3820: if($partial && $this->collDocuments) {
3821: foreach($this->collDocuments as $obj) {
3822: if($obj->isNew()) {
3823: $collDocuments[] = $obj;
3824: }
3825: }
3826: }
3827:
3828: $this->collDocuments = $collDocuments;
3829: $this->collDocumentsPartial = false;
3830: }
3831: }
3832:
3833: return $this->collDocuments;
3834: }
3835:
3836: 3837: 3838: 3839: 3840: 3841: 3842: 3843: 3844:
3845: public function setDocuments(PropelCollection $documents, PropelPDO $con = null)
3846: {
3847: $this->documentsScheduledForDeletion = $this->getDocuments(new Criteria(), $con)->diff($documents);
3848:
3849: foreach ($this->documentsScheduledForDeletion as $documentRemoved) {
3850: $documentRemoved->setProduct(null);
3851: }
3852:
3853: $this->collDocuments = null;
3854: foreach ($documents as $document) {
3855: $this->addDocument($document);
3856: }
3857:
3858: $this->collDocuments = $documents;
3859: $this->collDocumentsPartial = false;
3860: }
3861:
3862: 3863: 3864: 3865: 3866: 3867: 3868: 3869: 3870:
3871: public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3872: {
3873: $partial = $this->collDocumentsPartial && !$this->isNew();
3874: if (null === $this->collDocuments || null !== $criteria || $partial) {
3875: if ($this->isNew() && null === $this->collDocuments) {
3876: return 0;
3877: } else {
3878: if($partial && !$criteria) {
3879: return count($this->getDocuments());
3880: }
3881: $query = DocumentQuery::create(null, $criteria);
3882: if ($distinct) {
3883: $query->distinct();
3884: }
3885:
3886: return $query
3887: ->filterByProduct($this)
3888: ->count($con);
3889: }
3890: } else {
3891: return count($this->collDocuments);
3892: }
3893: }
3894:
3895: 3896: 3897: 3898: 3899: 3900: 3901:
3902: public function addDocument(Document $l)
3903: {
3904: if ($this->collDocuments === null) {
3905: $this->initDocuments();
3906: $this->collDocumentsPartial = true;
3907: }
3908: if (!$this->collDocuments->contains($l)) {
3909: $this->doAddDocument($l);
3910: }
3911:
3912: return $this;
3913: }
3914:
3915: 3916: 3917:
3918: protected function doAddDocument($document)
3919: {
3920: $this->collDocuments[]= $document;
3921: $document->setProduct($this);
3922: }
3923:
3924: 3925: 3926:
3927: public function removeDocument($document)
3928: {
3929: if ($this->getDocuments()->contains($document)) {
3930: $this->collDocuments->remove($this->collDocuments->search($document));
3931: if (null === $this->documentsScheduledForDeletion) {
3932: $this->documentsScheduledForDeletion = clone $this->collDocuments;
3933: $this->documentsScheduledForDeletion->clear();
3934: }
3935: $this->documentsScheduledForDeletion[]= $document;
3936: $document->setProduct(null);
3937: }
3938: }
3939:
3940:
3941: 3942: 3943: 3944: 3945: 3946: 3947: 3948: 3949: 3950: 3951: 3952: 3953: 3954: 3955: 3956:
3957: public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3958: {
3959: $query = DocumentQuery::create(null, $criteria);
3960: $query->joinWith('Category', $join_behavior);
3961:
3962: return $this->getDocuments($query, $con);
3963: }
3964:
3965:
3966: 3967: 3968: 3969: 3970: 3971: 3972: 3973: 3974: 3975: 3976: 3977: 3978: 3979: 3980: 3981:
3982: public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3983: {
3984: $query = DocumentQuery::create(null, $criteria);
3985: $query->joinWith('Content', $join_behavior);
3986:
3987: return $this->getDocuments($query, $con);
3988: }
3989:
3990:
3991: 3992: 3993: 3994: 3995: 3996: 3997: 3998: 3999: 4000: 4001: 4002: 4003: 4004: 4005: 4006:
4007: public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
4008: {
4009: $query = DocumentQuery::create(null, $criteria);
4010: $query->joinWith('Folder', $join_behavior);
4011:
4012: return $this->getDocuments($query, $con);
4013: }
4014:
4015: 4016: 4017: 4018: 4019: 4020: 4021: 4022: 4023:
4024: public function clearAccessorysRelatedByProductId()
4025: {
4026: $this->collAccessorysRelatedByProductId = null;
4027: $this->collAccessorysRelatedByProductIdPartial = null;
4028: }
4029:
4030: 4031: 4032: 4033: 4034:
4035: public function resetPartialAccessorysRelatedByProductId($v = true)
4036: {
4037: $this->collAccessorysRelatedByProductIdPartial = $v;
4038: }
4039:
4040: 4041: 4042: 4043: 4044: 4045: 4046: 4047: 4048: 4049: 4050: 4051:
4052: public function initAccessorysRelatedByProductId($overrideExisting = true)
4053: {
4054: if (null !== $this->collAccessorysRelatedByProductId && !$overrideExisting) {
4055: return;
4056: }
4057: $this->collAccessorysRelatedByProductId = new PropelObjectCollection();
4058: $this->collAccessorysRelatedByProductId->setModel('Accessory');
4059: }
4060:
4061: 4062: 4063: 4064: 4065: 4066: 4067: 4068: 4069: 4070: 4071: 4072: 4073: 4074:
4075: public function getAccessorysRelatedByProductId($criteria = null, PropelPDO $con = null)
4076: {
4077: $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew();
4078: if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) {
4079: if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) {
4080:
4081: $this->initAccessorysRelatedByProductId();
4082: } else {
4083: $collAccessorysRelatedByProductId = AccessoryQuery::create(null, $criteria)
4084: ->filterByProductRelatedByProductId($this)
4085: ->find($con);
4086: if (null !== $criteria) {
4087: if (false !== $this->collAccessorysRelatedByProductIdPartial && count($collAccessorysRelatedByProductId)) {
4088: $this->initAccessorysRelatedByProductId(false);
4089:
4090: foreach($collAccessorysRelatedByProductId as $obj) {
4091: if (false == $this->collAccessorysRelatedByProductId->contains($obj)) {
4092: $this->collAccessorysRelatedByProductId->append($obj);
4093: }
4094: }
4095:
4096: $this->collAccessorysRelatedByProductIdPartial = true;
4097: }
4098:
4099: return $collAccessorysRelatedByProductId;
4100: }
4101:
4102: if($partial && $this->collAccessorysRelatedByProductId) {
4103: foreach($this->collAccessorysRelatedByProductId as $obj) {
4104: if($obj->isNew()) {
4105: $collAccessorysRelatedByProductId[] = $obj;
4106: }
4107: }
4108: }
4109:
4110: $this->collAccessorysRelatedByProductId = $collAccessorysRelatedByProductId;
4111: $this->collAccessorysRelatedByProductIdPartial = false;
4112: }
4113: }
4114:
4115: return $this->collAccessorysRelatedByProductId;
4116: }
4117:
4118: 4119: 4120: 4121: 4122: 4123: 4124: 4125: 4126:
4127: public function setAccessorysRelatedByProductId(PropelCollection $accessorysRelatedByProductId, PropelPDO $con = null)
4128: {
4129: $this->accessorysRelatedByProductIdScheduledForDeletion = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId);
4130:
4131: foreach ($this->accessorysRelatedByProductIdScheduledForDeletion as $accessoryRelatedByProductIdRemoved) {
4132: $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null);
4133: }
4134:
4135: $this->collAccessorysRelatedByProductId = null;
4136: foreach ($accessorysRelatedByProductId as $accessoryRelatedByProductId) {
4137: $this->addAccessoryRelatedByProductId($accessoryRelatedByProductId);
4138: }
4139:
4140: $this->collAccessorysRelatedByProductId = $accessorysRelatedByProductId;
4141: $this->collAccessorysRelatedByProductIdPartial = false;
4142: }
4143:
4144: 4145: 4146: 4147: 4148: 4149: 4150: 4151: 4152:
4153: public function countAccessorysRelatedByProductId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4154: {
4155: $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew();
4156: if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) {
4157: if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) {
4158: return 0;
4159: } else {
4160: if($partial && !$criteria) {
4161: return count($this->getAccessorysRelatedByProductId());
4162: }
4163: $query = AccessoryQuery::create(null, $criteria);
4164: if ($distinct) {
4165: $query->distinct();
4166: }
4167:
4168: return $query
4169: ->filterByProductRelatedByProductId($this)
4170: ->count($con);
4171: }
4172: } else {
4173: return count($this->collAccessorysRelatedByProductId);
4174: }
4175: }
4176:
4177: 4178: 4179: 4180: 4181: 4182: 4183:
4184: public function addAccessoryRelatedByProductId(Accessory $l)
4185: {
4186: if ($this->collAccessorysRelatedByProductId === null) {
4187: $this->initAccessorysRelatedByProductId();
4188: $this->collAccessorysRelatedByProductIdPartial = true;
4189: }
4190: if (!$this->collAccessorysRelatedByProductId->contains($l)) {
4191: $this->doAddAccessoryRelatedByProductId($l);
4192: }
4193:
4194: return $this;
4195: }
4196:
4197: 4198: 4199:
4200: protected function doAddAccessoryRelatedByProductId($accessoryRelatedByProductId)
4201: {
4202: $this->collAccessorysRelatedByProductId[]= $accessoryRelatedByProductId;
4203: $accessoryRelatedByProductId->setProductRelatedByProductId($this);
4204: }
4205:
4206: 4207: 4208:
4209: public function removeAccessoryRelatedByProductId($accessoryRelatedByProductId)
4210: {
4211: if ($this->getAccessorysRelatedByProductId()->contains($accessoryRelatedByProductId)) {
4212: $this->collAccessorysRelatedByProductId->remove($this->collAccessorysRelatedByProductId->search($accessoryRelatedByProductId));
4213: if (null === $this->accessorysRelatedByProductIdScheduledForDeletion) {
4214: $this->accessorysRelatedByProductIdScheduledForDeletion = clone $this->collAccessorysRelatedByProductId;
4215: $this->accessorysRelatedByProductIdScheduledForDeletion->clear();
4216: }
4217: $this->accessorysRelatedByProductIdScheduledForDeletion[]= $accessoryRelatedByProductId;
4218: $accessoryRelatedByProductId->setProductRelatedByProductId(null);
4219: }
4220: }
4221:
4222: 4223: 4224: 4225: 4226: 4227: 4228: 4229: 4230:
4231: public function clearAccessorysRelatedByAccessory()
4232: {
4233: $this->collAccessorysRelatedByAccessory = null;
4234: $this->collAccessorysRelatedByAccessoryPartial = null;
4235: }
4236:
4237: 4238: 4239: 4240: 4241:
4242: public function resetPartialAccessorysRelatedByAccessory($v = true)
4243: {
4244: $this->collAccessorysRelatedByAccessoryPartial = $v;
4245: }
4246:
4247: 4248: 4249: 4250: 4251: 4252: 4253: 4254: 4255: 4256: 4257: 4258:
4259: public function initAccessorysRelatedByAccessory($overrideExisting = true)
4260: {
4261: if (null !== $this->collAccessorysRelatedByAccessory && !$overrideExisting) {
4262: return;
4263: }
4264: $this->collAccessorysRelatedByAccessory = new PropelObjectCollection();
4265: $this->collAccessorysRelatedByAccessory->setModel('Accessory');
4266: }
4267:
4268: 4269: 4270: 4271: 4272: 4273: 4274: 4275: 4276: 4277: 4278: 4279: 4280: 4281:
4282: public function getAccessorysRelatedByAccessory($criteria = null, PropelPDO $con = null)
4283: {
4284: $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew();
4285: if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) {
4286: if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) {
4287:
4288: $this->initAccessorysRelatedByAccessory();
4289: } else {
4290: $collAccessorysRelatedByAccessory = AccessoryQuery::create(null, $criteria)
4291: ->filterByProductRelatedByAccessory($this)
4292: ->find($con);
4293: if (null !== $criteria) {
4294: if (false !== $this->collAccessorysRelatedByAccessoryPartial && count($collAccessorysRelatedByAccessory)) {
4295: $this->initAccessorysRelatedByAccessory(false);
4296:
4297: foreach($collAccessorysRelatedByAccessory as $obj) {
4298: if (false == $this->collAccessorysRelatedByAccessory->contains($obj)) {
4299: $this->collAccessorysRelatedByAccessory->append($obj);
4300: }
4301: }
4302:
4303: $this->collAccessorysRelatedByAccessoryPartial = true;
4304: }
4305:
4306: return $collAccessorysRelatedByAccessory;
4307: }
4308:
4309: if($partial && $this->collAccessorysRelatedByAccessory) {
4310: foreach($this->collAccessorysRelatedByAccessory as $obj) {
4311: if($obj->isNew()) {
4312: $collAccessorysRelatedByAccessory[] = $obj;
4313: }
4314: }
4315: }
4316:
4317: $this->collAccessorysRelatedByAccessory = $collAccessorysRelatedByAccessory;
4318: $this->collAccessorysRelatedByAccessoryPartial = false;
4319: }
4320: }
4321:
4322: return $this->collAccessorysRelatedByAccessory;
4323: }
4324:
4325: 4326: 4327: 4328: 4329: 4330: 4331: 4332: 4333:
4334: public function setAccessorysRelatedByAccessory(PropelCollection $accessorysRelatedByAccessory, PropelPDO $con = null)
4335: {
4336: $this->accessorysRelatedByAccessoryScheduledForDeletion = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory);
4337:
4338: foreach ($this->accessorysRelatedByAccessoryScheduledForDeletion as $accessoryRelatedByAccessoryRemoved) {
4339: $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null);
4340: }
4341:
4342: $this->collAccessorysRelatedByAccessory = null;
4343: foreach ($accessorysRelatedByAccessory as $accessoryRelatedByAccessory) {
4344: $this->addAccessoryRelatedByAccessory($accessoryRelatedByAccessory);
4345: }
4346:
4347: $this->collAccessorysRelatedByAccessory = $accessorysRelatedByAccessory;
4348: $this->collAccessorysRelatedByAccessoryPartial = false;
4349: }
4350:
4351: 4352: 4353: 4354: 4355: 4356: 4357: 4358: 4359:
4360: public function countAccessorysRelatedByAccessory(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4361: {
4362: $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew();
4363: if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) {
4364: if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) {
4365: return 0;
4366: } else {
4367: if($partial && !$criteria) {
4368: return count($this->getAccessorysRelatedByAccessory());
4369: }
4370: $query = AccessoryQuery::create(null, $criteria);
4371: if ($distinct) {
4372: $query->distinct();
4373: }
4374:
4375: return $query
4376: ->filterByProductRelatedByAccessory($this)
4377: ->count($con);
4378: }
4379: } else {
4380: return count($this->collAccessorysRelatedByAccessory);
4381: }
4382: }
4383:
4384: 4385: 4386: 4387: 4388: 4389: 4390:
4391: public function addAccessoryRelatedByAccessory(Accessory $l)
4392: {
4393: if ($this->collAccessorysRelatedByAccessory === null) {
4394: $this->initAccessorysRelatedByAccessory();
4395: $this->collAccessorysRelatedByAccessoryPartial = true;
4396: }
4397: if (!$this->collAccessorysRelatedByAccessory->contains($l)) {
4398: $this->doAddAccessoryRelatedByAccessory($l);
4399: }
4400:
4401: return $this;
4402: }
4403:
4404: 4405: 4406:
4407: protected function doAddAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
4408: {
4409: $this->collAccessorysRelatedByAccessory[]= $accessoryRelatedByAccessory;
4410: $accessoryRelatedByAccessory->setProductRelatedByAccessory($this);
4411: }
4412:
4413: 4414: 4415:
4416: public function removeAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
4417: {
4418: if ($this->getAccessorysRelatedByAccessory()->contains($accessoryRelatedByAccessory)) {
4419: $this->collAccessorysRelatedByAccessory->remove($this->collAccessorysRelatedByAccessory->search($accessoryRelatedByAccessory));
4420: if (null === $this->accessorysRelatedByAccessoryScheduledForDeletion) {
4421: $this->accessorysRelatedByAccessoryScheduledForDeletion = clone $this->collAccessorysRelatedByAccessory;
4422: $this->accessorysRelatedByAccessoryScheduledForDeletion->clear();
4423: }
4424: $this->accessorysRelatedByAccessoryScheduledForDeletion[]= $accessoryRelatedByAccessory;
4425: $accessoryRelatedByAccessory->setProductRelatedByAccessory(null);
4426: }
4427: }
4428:
4429: 4430: 4431: 4432: 4433: 4434: 4435: 4436: 4437:
4438: public function clearRewritings()
4439: {
4440: $this->collRewritings = null;
4441: $this->collRewritingsPartial = null;
4442: }
4443:
4444: 4445: 4446: 4447: 4448:
4449: public function resetPartialRewritings($v = true)
4450: {
4451: $this->collRewritingsPartial = $v;
4452: }
4453:
4454: 4455: 4456: 4457: 4458: 4459: 4460: 4461: 4462: 4463: 4464: 4465:
4466: public function initRewritings($overrideExisting = true)
4467: {
4468: if (null !== $this->collRewritings && !$overrideExisting) {
4469: return;
4470: }
4471: $this->collRewritings = new PropelObjectCollection();
4472: $this->collRewritings->setModel('Rewriting');
4473: }
4474:
4475: 4476: 4477: 4478: 4479: 4480: 4481: 4482: 4483: 4484: 4485: 4486: 4487: 4488:
4489: public function getRewritings($criteria = null, PropelPDO $con = null)
4490: {
4491: $partial = $this->collRewritingsPartial && !$this->isNew();
4492: if (null === $this->collRewritings || null !== $criteria || $partial) {
4493: if ($this->isNew() && null === $this->collRewritings) {
4494:
4495: $this->initRewritings();
4496: } else {
4497: $collRewritings = RewritingQuery::create(null, $criteria)
4498: ->filterByProduct($this)
4499: ->find($con);
4500: if (null !== $criteria) {
4501: if (false !== $this->collRewritingsPartial && count($collRewritings)) {
4502: $this->initRewritings(false);
4503:
4504: foreach($collRewritings as $obj) {
4505: if (false == $this->collRewritings->contains($obj)) {
4506: $this->collRewritings->append($obj);
4507: }
4508: }
4509:
4510: $this->collRewritingsPartial = true;
4511: }
4512:
4513: return $collRewritings;
4514: }
4515:
4516: if($partial && $this->collRewritings) {
4517: foreach($this->collRewritings as $obj) {
4518: if($obj->isNew()) {
4519: $collRewritings[] = $obj;
4520: }
4521: }
4522: }
4523:
4524: $this->collRewritings = $collRewritings;
4525: $this->collRewritingsPartial = false;
4526: }
4527: }
4528:
4529: return $this->collRewritings;
4530: }
4531:
4532: 4533: 4534: 4535: 4536: 4537: 4538: 4539: 4540:
4541: public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null)
4542: {
4543: $this->rewritingsScheduledForDeletion = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
4544:
4545: foreach ($this->rewritingsScheduledForDeletion as $rewritingRemoved) {
4546: $rewritingRemoved->setProduct(null);
4547: }
4548:
4549: $this->collRewritings = null;
4550: foreach ($rewritings as $rewriting) {
4551: $this->addRewriting($rewriting);
4552: }
4553:
4554: $this->collRewritings = $rewritings;
4555: $this->collRewritingsPartial = false;
4556: }
4557:
4558: 4559: 4560: 4561: 4562: 4563: 4564: 4565: 4566:
4567: public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4568: {
4569: $partial = $this->collRewritingsPartial && !$this->isNew();
4570: if (null === $this->collRewritings || null !== $criteria || $partial) {
4571: if ($this->isNew() && null === $this->collRewritings) {
4572: return 0;
4573: } else {
4574: if($partial && !$criteria) {
4575: return count($this->getRewritings());
4576: }
4577: $query = RewritingQuery::create(null, $criteria);
4578: if ($distinct) {
4579: $query->distinct();
4580: }
4581:
4582: return $query
4583: ->filterByProduct($this)
4584: ->count($con);
4585: }
4586: } else {
4587: return count($this->collRewritings);
4588: }
4589: }
4590:
4591: 4592: 4593: 4594: 4595: 4596: 4597:
4598: public function addRewriting(Rewriting $l)
4599: {
4600: if ($this->collRewritings === null) {
4601: $this->initRewritings();
4602: $this->collRewritingsPartial = true;
4603: }
4604: if (!$this->collRewritings->contains($l)) {
4605: $this->doAddRewriting($l);
4606: }
4607:
4608: return $this;
4609: }
4610:
4611: 4612: 4613:
4614: protected function doAddRewriting($rewriting)
4615: {
4616: $this->collRewritings[]= $rewriting;
4617: $rewriting->setProduct($this);
4618: }
4619:
4620: 4621: 4622:
4623: public function removeRewriting($rewriting)
4624: {
4625: if ($this->getRewritings()->contains($rewriting)) {
4626: $this->collRewritings->remove($this->collRewritings->search($rewriting));
4627: if (null === $this->rewritingsScheduledForDeletion) {
4628: $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
4629: $this->rewritingsScheduledForDeletion->clear();
4630: }
4631: $this->rewritingsScheduledForDeletion[]= $rewriting;
4632: $rewriting->setProduct(null);
4633: }
4634: }
4635:
4636:
4637: 4638: 4639: 4640: 4641: 4642: 4643: 4644: 4645: 4646: 4647: 4648: 4649: 4650: 4651: 4652:
4653: public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
4654: {
4655: $query = RewritingQuery::create(null, $criteria);
4656: $query->joinWith('Category', $join_behavior);
4657:
4658: return $this->getRewritings($query, $con);
4659: }
4660:
4661:
4662: 4663: 4664: 4665: 4666: 4667: 4668: 4669: 4670: 4671: 4672: 4673: 4674: 4675: 4676: 4677:
4678: public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
4679: {
4680: $query = RewritingQuery::create(null, $criteria);
4681: $query->joinWith('Folder', $join_behavior);
4682:
4683: return $this->getRewritings($query, $con);
4684: }
4685:
4686:
4687: 4688: 4689: 4690: 4691: 4692: 4693: 4694: 4695: 4696: 4697: 4698: 4699: 4700: 4701: 4702:
4703: public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
4704: {
4705: $query = RewritingQuery::create(null, $criteria);
4706: $query->joinWith('Content', $join_behavior);
4707:
4708: return $this->getRewritings($query, $con);
4709: }
4710:
4711: 4712: 4713: 4714: 4715: 4716: 4717: 4718: 4719:
4720: public function clearProductI18ns()
4721: {
4722: $this->collProductI18ns = null;
4723: $this->collProductI18nsPartial = null;
4724: }
4725:
4726: 4727: 4728: 4729: 4730:
4731: public function resetPartialProductI18ns($v = true)
4732: {
4733: $this->collProductI18nsPartial = $v;
4734: }
4735:
4736: 4737: 4738: 4739: 4740: 4741: 4742: 4743: 4744: 4745: 4746: 4747:
4748: public function initProductI18ns($overrideExisting = true)
4749: {
4750: if (null !== $this->collProductI18ns && !$overrideExisting) {
4751: return;
4752: }
4753: $this->collProductI18ns = new PropelObjectCollection();
4754: $this->collProductI18ns->setModel('ProductI18n');
4755: }
4756:
4757: 4758: 4759: 4760: 4761: 4762: 4763: 4764: 4765: 4766: 4767: 4768: 4769: 4770:
4771: public function getProductI18ns($criteria = null, PropelPDO $con = null)
4772: {
4773: $partial = $this->collProductI18nsPartial && !$this->isNew();
4774: if (null === $this->collProductI18ns || null !== $criteria || $partial) {
4775: if ($this->isNew() && null === $this->collProductI18ns) {
4776:
4777: $this->initProductI18ns();
4778: } else {
4779: $collProductI18ns = ProductI18nQuery::create(null, $criteria)
4780: ->filterByProduct($this)
4781: ->find($con);
4782: if (null !== $criteria) {
4783: if (false !== $this->collProductI18nsPartial && count($collProductI18ns)) {
4784: $this->initProductI18ns(false);
4785:
4786: foreach($collProductI18ns as $obj) {
4787: if (false == $this->collProductI18ns->contains($obj)) {
4788: $this->collProductI18ns->append($obj);
4789: }
4790: }
4791:
4792: $this->collProductI18nsPartial = true;
4793: }
4794:
4795: return $collProductI18ns;
4796: }
4797:
4798: if($partial && $this->collProductI18ns) {
4799: foreach($this->collProductI18ns as $obj) {
4800: if($obj->isNew()) {
4801: $collProductI18ns[] = $obj;
4802: }
4803: }
4804: }
4805:
4806: $this->collProductI18ns = $collProductI18ns;
4807: $this->collProductI18nsPartial = false;
4808: }
4809: }
4810:
4811: return $this->collProductI18ns;
4812: }
4813:
4814: 4815: 4816: 4817: 4818: 4819: 4820: 4821: 4822:
4823: public function setProductI18ns(PropelCollection $productI18ns, PropelPDO $con = null)
4824: {
4825: $this->productI18nsScheduledForDeletion = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns);
4826:
4827: foreach ($this->productI18nsScheduledForDeletion as $productI18nRemoved) {
4828: $productI18nRemoved->setProduct(null);
4829: }
4830:
4831: $this->collProductI18ns = null;
4832: foreach ($productI18ns as $productI18n) {
4833: $this->addProductI18n($productI18n);
4834: }
4835:
4836: $this->collProductI18ns = $productI18ns;
4837: $this->collProductI18nsPartial = false;
4838: }
4839:
4840: 4841: 4842: 4843: 4844: 4845: 4846: 4847: 4848:
4849: public function countProductI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4850: {
4851: $partial = $this->collProductI18nsPartial && !$this->isNew();
4852: if (null === $this->collProductI18ns || null !== $criteria || $partial) {
4853: if ($this->isNew() && null === $this->collProductI18ns) {
4854: return 0;
4855: } else {
4856: if($partial && !$criteria) {
4857: return count($this->getProductI18ns());
4858: }
4859: $query = ProductI18nQuery::create(null, $criteria);
4860: if ($distinct) {
4861: $query->distinct();
4862: }
4863:
4864: return $query
4865: ->filterByProduct($this)
4866: ->count($con);
4867: }
4868: } else {
4869: return count($this->collProductI18ns);
4870: }
4871: }
4872:
4873: 4874: 4875: 4876: 4877: 4878: 4879:
4880: public function addProductI18n(ProductI18n $l)
4881: {
4882: if ($l && $locale = $l->getLocale()) {
4883: $this->setLocale($locale);
4884: $this->currentTranslations[$locale] = $l;
4885: }
4886: if ($this->collProductI18ns === null) {
4887: $this->initProductI18ns();
4888: $this->collProductI18nsPartial = true;
4889: }
4890: if (!$this->collProductI18ns->contains($l)) {
4891: $this->doAddProductI18n($l);
4892: }
4893:
4894: return $this;
4895: }
4896:
4897: 4898: 4899:
4900: protected function doAddProductI18n($productI18n)
4901: {
4902: $this->collProductI18ns[]= $productI18n;
4903: $productI18n->setProduct($this);
4904: }
4905:
4906: 4907: 4908:
4909: public function removeProductI18n($productI18n)
4910: {
4911: if ($this->getProductI18ns()->contains($productI18n)) {
4912: $this->collProductI18ns->remove($this->collProductI18ns->search($productI18n));
4913: if (null === $this->productI18nsScheduledForDeletion) {
4914: $this->productI18nsScheduledForDeletion = clone $this->collProductI18ns;
4915: $this->productI18nsScheduledForDeletion->clear();
4916: }
4917: $this->productI18nsScheduledForDeletion[]= $productI18n;
4918: $productI18n->setProduct(null);
4919: }
4920: }
4921:
4922: 4923: 4924: 4925: 4926: 4927: 4928: 4929: 4930:
4931: public function clearProductVersions()
4932: {
4933: $this->collProductVersions = null;
4934: $this->collProductVersionsPartial = null;
4935: }
4936:
4937: 4938: 4939: 4940: 4941:
4942: public function resetPartialProductVersions($v = true)
4943: {
4944: $this->collProductVersionsPartial = $v;
4945: }
4946:
4947: 4948: 4949: 4950: 4951: 4952: 4953: 4954: 4955: 4956: 4957: 4958:
4959: public function initProductVersions($overrideExisting = true)
4960: {
4961: if (null !== $this->collProductVersions && !$overrideExisting) {
4962: return;
4963: }
4964: $this->collProductVersions = new PropelObjectCollection();
4965: $this->collProductVersions->setModel('ProductVersion');
4966: }
4967:
4968: 4969: 4970: 4971: 4972: 4973: 4974: 4975: 4976: 4977: 4978: 4979: 4980: 4981:
4982: public function getProductVersions($criteria = null, PropelPDO $con = null)
4983: {
4984: $partial = $this->collProductVersionsPartial && !$this->isNew();
4985: if (null === $this->collProductVersions || null !== $criteria || $partial) {
4986: if ($this->isNew() && null === $this->collProductVersions) {
4987:
4988: $this->initProductVersions();
4989: } else {
4990: $collProductVersions = ProductVersionQuery::create(null, $criteria)
4991: ->filterByProduct($this)
4992: ->find($con);
4993: if (null !== $criteria) {
4994: if (false !== $this->collProductVersionsPartial && count($collProductVersions)) {
4995: $this->initProductVersions(false);
4996:
4997: foreach($collProductVersions as $obj) {
4998: if (false == $this->collProductVersions->contains($obj)) {
4999: $this->collProductVersions->append($obj);
5000: }
5001: }
5002:
5003: $this->collProductVersionsPartial = true;
5004: }
5005:
5006: return $collProductVersions;
5007: }
5008:
5009: if($partial && $this->collProductVersions) {
5010: foreach($this->collProductVersions as $obj) {
5011: if($obj->isNew()) {
5012: $collProductVersions[] = $obj;
5013: }
5014: }
5015: }
5016:
5017: $this->collProductVersions = $collProductVersions;
5018: $this->collProductVersionsPartial = false;
5019: }
5020: }
5021:
5022: return $this->collProductVersions;
5023: }
5024:
5025: 5026: 5027: 5028: 5029: 5030: 5031: 5032: 5033:
5034: public function setProductVersions(PropelCollection $productVersions, PropelPDO $con = null)
5035: {
5036: $this->productVersionsScheduledForDeletion = $this->getProductVersions(new Criteria(), $con)->diff($productVersions);
5037:
5038: foreach ($this->productVersionsScheduledForDeletion as $productVersionRemoved) {
5039: $productVersionRemoved->setProduct(null);
5040: }
5041:
5042: $this->collProductVersions = null;
5043: foreach ($productVersions as $productVersion) {
5044: $this->addProductVersion($productVersion);
5045: }
5046:
5047: $this->collProductVersions = $productVersions;
5048: $this->collProductVersionsPartial = false;
5049: }
5050:
5051: 5052: 5053: 5054: 5055: 5056: 5057: 5058: 5059:
5060: public function countProductVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
5061: {
5062: $partial = $this->collProductVersionsPartial && !$this->isNew();
5063: if (null === $this->collProductVersions || null !== $criteria || $partial) {
5064: if ($this->isNew() && null === $this->collProductVersions) {
5065: return 0;
5066: } else {
5067: if($partial && !$criteria) {
5068: return count($this->getProductVersions());
5069: }
5070: $query = ProductVersionQuery::create(null, $criteria);
5071: if ($distinct) {
5072: $query->distinct();
5073: }
5074:
5075: return $query
5076: ->filterByProduct($this)
5077: ->count($con);
5078: }
5079: } else {
5080: return count($this->collProductVersions);
5081: }
5082: }
5083:
5084: 5085: 5086: 5087: 5088: 5089: 5090:
5091: public function addProductVersion(ProductVersion $l)
5092: {
5093: if ($this->collProductVersions === null) {
5094: $this->initProductVersions();
5095: $this->collProductVersionsPartial = true;
5096: }
5097: if (!$this->collProductVersions->contains($l)) {
5098: $this->doAddProductVersion($l);
5099: }
5100:
5101: return $this;
5102: }
5103:
5104: 5105: 5106:
5107: protected function doAddProductVersion($productVersion)
5108: {
5109: $this->collProductVersions[]= $productVersion;
5110: $productVersion->setProduct($this);
5111: }
5112:
5113: 5114: 5115:
5116: public function removeProductVersion($productVersion)
5117: {
5118: if ($this->getProductVersions()->contains($productVersion)) {
5119: $this->collProductVersions->remove($this->collProductVersions->search($productVersion));
5120: if (null === $this->productVersionsScheduledForDeletion) {
5121: $this->productVersionsScheduledForDeletion = clone $this->collProductVersions;
5122: $this->productVersionsScheduledForDeletion->clear();
5123: }
5124: $this->productVersionsScheduledForDeletion[]= $productVersion;
5125: $productVersion->setProduct(null);
5126: }
5127: }
5128:
5129: 5130: 5131:
5132: public function clear()
5133: {
5134: $this->id = null;
5135: $this->tax_rule_id = null;
5136: $this->ref = null;
5137: $this->price = null;
5138: $this->price2 = null;
5139: $this->ecotax = null;
5140: $this->newness = null;
5141: $this->promo = null;
5142: $this->stock = null;
5143: $this->visible = null;
5144: $this->weight = null;
5145: $this->position = null;
5146: $this->created_at = null;
5147: $this->updated_at = null;
5148: $this->version = null;
5149: $this->version_created_at = null;
5150: $this->version_created_by = null;
5151: $this->alreadyInSave = false;
5152: $this->alreadyInValidation = false;
5153: $this->clearAllReferences();
5154: $this->applyDefaultValues();
5155: $this->resetModified();
5156: $this->setNew(true);
5157: $this->setDeleted(false);
5158: }
5159:
5160: 5161: 5162: 5163: 5164: 5165: 5166: 5167: 5168:
5169: public function clearAllReferences($deep = false)
5170: {
5171: if ($deep) {
5172: if ($this->collProductCategorys) {
5173: foreach ($this->collProductCategorys as $o) {
5174: $o->clearAllReferences($deep);
5175: }
5176: }
5177: if ($this->collFeatureProds) {
5178: foreach ($this->collFeatureProds as $o) {
5179: $o->clearAllReferences($deep);
5180: }
5181: }
5182: if ($this->collStocks) {
5183: foreach ($this->collStocks as $o) {
5184: $o->clearAllReferences($deep);
5185: }
5186: }
5187: if ($this->collContentAssocs) {
5188: foreach ($this->collContentAssocs as $o) {
5189: $o->clearAllReferences($deep);
5190: }
5191: }
5192: if ($this->collImages) {
5193: foreach ($this->collImages as $o) {
5194: $o->clearAllReferences($deep);
5195: }
5196: }
5197: if ($this->collDocuments) {
5198: foreach ($this->collDocuments as $o) {
5199: $o->clearAllReferences($deep);
5200: }
5201: }
5202: if ($this->collAccessorysRelatedByProductId) {
5203: foreach ($this->collAccessorysRelatedByProductId as $o) {
5204: $o->clearAllReferences($deep);
5205: }
5206: }
5207: if ($this->collAccessorysRelatedByAccessory) {
5208: foreach ($this->collAccessorysRelatedByAccessory as $o) {
5209: $o->clearAllReferences($deep);
5210: }
5211: }
5212: if ($this->collRewritings) {
5213: foreach ($this->collRewritings as $o) {
5214: $o->clearAllReferences($deep);
5215: }
5216: }
5217: if ($this->collProductI18ns) {
5218: foreach ($this->collProductI18ns as $o) {
5219: $o->clearAllReferences($deep);
5220: }
5221: }
5222: if ($this->collProductVersions) {
5223: foreach ($this->collProductVersions as $o) {
5224: $o->clearAllReferences($deep);
5225: }
5226: }
5227: }
5228:
5229:
5230: $this->currentLocale = 'en_EN';
5231: $this->currentTranslations = null;
5232:
5233: if ($this->collProductCategorys instanceof PropelCollection) {
5234: $this->collProductCategorys->clearIterator();
5235: }
5236: $this->collProductCategorys = null;
5237: if ($this->collFeatureProds instanceof PropelCollection) {
5238: $this->collFeatureProds->clearIterator();
5239: }
5240: $this->collFeatureProds = null;
5241: if ($this->collStocks instanceof PropelCollection) {
5242: $this->collStocks->clearIterator();
5243: }
5244: $this->collStocks = null;
5245: if ($this->collContentAssocs instanceof PropelCollection) {
5246: $this->collContentAssocs->clearIterator();
5247: }
5248: $this->collContentAssocs = null;
5249: if ($this->collImages instanceof PropelCollection) {
5250: $this->collImages->clearIterator();
5251: }
5252: $this->collImages = null;
5253: if ($this->collDocuments instanceof PropelCollection) {
5254: $this->collDocuments->clearIterator();
5255: }
5256: $this->collDocuments = null;
5257: if ($this->collAccessorysRelatedByProductId instanceof PropelCollection) {
5258: $this->collAccessorysRelatedByProductId->clearIterator();
5259: }
5260: $this->collAccessorysRelatedByProductId = null;
5261: if ($this->collAccessorysRelatedByAccessory instanceof PropelCollection) {
5262: $this->collAccessorysRelatedByAccessory->clearIterator();
5263: }
5264: $this->collAccessorysRelatedByAccessory = null;
5265: if ($this->collRewritings instanceof PropelCollection) {
5266: $this->collRewritings->clearIterator();
5267: }
5268: $this->collRewritings = null;
5269: if ($this->collProductI18ns instanceof PropelCollection) {
5270: $this->collProductI18ns->clearIterator();
5271: }
5272: $this->collProductI18ns = null;
5273: if ($this->collProductVersions instanceof PropelCollection) {
5274: $this->collProductVersions->clearIterator();
5275: }
5276: $this->collProductVersions = null;
5277: $this->aTaxRule = null;
5278: }
5279:
5280: 5281: 5282: 5283: 5284:
5285: public function __toString()
5286: {
5287: return (string) $this->exportTo(ProductPeer::DEFAULT_STRING_FORMAT);
5288: }
5289:
5290: 5291: 5292: 5293: 5294:
5295: public function isAlreadyInSave()
5296: {
5297: return $this->alreadyInSave;
5298: }
5299:
5300:
5301:
5302: 5303: 5304: 5305: 5306:
5307: public function keepUpdateDateUnchanged()
5308: {
5309: $this->modifiedColumns[] = ProductPeer::UPDATED_AT;
5310:
5311: return $this;
5312: }
5313:
5314:
5315:
5316: 5317: 5318: 5319: 5320: 5321: 5322:
5323: public function setLocale($locale = 'en_EN')
5324: {
5325: $this->currentLocale = $locale;
5326:
5327: return $this;
5328: }
5329:
5330: 5331: 5332: 5333: 5334:
5335: public function getLocale()
5336: {
5337: return $this->currentLocale;
5338: }
5339:
5340: 5341: 5342: 5343: 5344: 5345: 5346:
5347: public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
5348: {
5349: if (!isset($this->currentTranslations[$locale])) {
5350: if (null !== $this->collProductI18ns) {
5351: foreach ($this->collProductI18ns as $translation) {
5352: if ($translation->getLocale() == $locale) {
5353: $this->currentTranslations[$locale] = $translation;
5354:
5355: return $translation;
5356: }
5357: }
5358: }
5359: if ($this->isNew()) {
5360: $translation = new ProductI18n();
5361: $translation->setLocale($locale);
5362: } else {
5363: $translation = ProductI18nQuery::create()
5364: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
5365: ->findOneOrCreate($con);
5366: $this->currentTranslations[$locale] = $translation;
5367: }
5368: $this->addProductI18n($translation);
5369: }
5370:
5371: return $this->currentTranslations[$locale];
5372: }
5373:
5374: 5375: 5376: 5377: 5378: 5379: 5380: 5381:
5382: public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
5383: {
5384: if (!$this->isNew()) {
5385: ProductI18nQuery::create()
5386: ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
5387: ->delete($con);
5388: }
5389: if (isset($this->currentTranslations[$locale])) {
5390: unset($this->currentTranslations[$locale]);
5391: }
5392: foreach ($this->collProductI18ns as $key => $translation) {
5393: if ($translation->getLocale() == $locale) {
5394: unset($this->collProductI18ns[$key]);
5395: break;
5396: }
5397: }
5398:
5399: return $this;
5400: }
5401:
5402: 5403: 5404: 5405: 5406: 5407:
5408: public function getCurrentTranslation(PropelPDO $con = null)
5409: {
5410: return $this->getTranslation($this->getLocale(), $con);
5411: }
5412:
5413:
5414: 5415: 5416: 5417: 5418:
5419: public function getTitle()
5420: {
5421: return $this->getCurrentTranslation()->getTitle();
5422: }
5423:
5424:
5425: 5426: 5427: 5428: 5429: 5430:
5431: public function setTitle($v)
5432: { $this->getCurrentTranslation()->setTitle($v);
5433:
5434: return $this;
5435: }
5436:
5437:
5438: 5439: 5440: 5441: 5442:
5443: public function getDescription()
5444: {
5445: return $this->getCurrentTranslation()->getDescription();
5446: }
5447:
5448:
5449: 5450: 5451: 5452: 5453: 5454:
5455: public function setDescription($v)
5456: { $this->getCurrentTranslation()->setDescription($v);
5457:
5458: return $this;
5459: }
5460:
5461:
5462: 5463: 5464: 5465: 5466:
5467: public function getChapo()
5468: {
5469: return $this->getCurrentTranslation()->getChapo();
5470: }
5471:
5472:
5473: 5474: 5475: 5476: 5477: 5478:
5479: public function setChapo($v)
5480: { $this->getCurrentTranslation()->setChapo($v);
5481:
5482: return $this;
5483: }
5484:
5485:
5486: 5487: 5488: 5489: 5490:
5491: public function getPostscriptum()
5492: {
5493: return $this->getCurrentTranslation()->getPostscriptum();
5494: }
5495:
5496:
5497: 5498: 5499: 5500: 5501: 5502:
5503: public function setPostscriptum($v)
5504: { $this->getCurrentTranslation()->setPostscriptum($v);
5505:
5506: return $this;
5507: }
5508:
5509:
5510:
5511: 5512: 5513: 5514: 5515:
5516: public function enforceVersioning()
5517: {
5518: $this->enforceVersion = true;
5519:
5520: return $this;
5521: }
5522:
5523: 5524: 5525: 5526: 5527: 5528: 5529:
5530: public function isVersioningNecessary($con = null)
5531: {
5532: if ($this->alreadyInSave) {
5533: return false;
5534: }
5535:
5536: if ($this->enforceVersion) {
5537: return true;
5538: }
5539:
5540: if (ProductPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) {
5541: return true;
5542: }
5543:
5544: return false;
5545: }
5546:
5547: 5548: 5549: 5550: 5551: 5552: 5553:
5554: public function addVersion($con = null)
5555: {
5556: $this->enforceVersion = false;
5557:
5558: $version = new ProductVersion();
5559: $version->setId($this->getId());
5560: $version->setTaxRuleId($this->getTaxRuleId());
5561: $version->setRef($this->getRef());
5562: $version->setPrice($this->getPrice());
5563: $version->setPrice2($this->getPrice2());
5564: $version->setEcotax($this->getEcotax());
5565: $version->setNewness($this->getNewness());
5566: $version->setPromo($this->getPromo());
5567: $version->setStock($this->getStock());
5568: $version->setVisible($this->getVisible());
5569: $version->setWeight($this->getWeight());
5570: $version->setPosition($this->getPosition());
5571: $version->setCreatedAt($this->getCreatedAt());
5572: $version->setUpdatedAt($this->getUpdatedAt());
5573: $version->setVersion($this->getVersion());
5574: $version->setVersionCreatedAt($this->getVersionCreatedAt());
5575: $version->setVersionCreatedBy($this->getVersionCreatedBy());
5576: $version->setProduct($this);
5577: $version->save($con);
5578:
5579: return $version;
5580: }
5581:
5582: 5583: 5584: 5585: 5586: 5587: 5588: 5589: 5590:
5591: public function toVersion($versionNumber, $con = null)
5592: {
5593: $version = $this->getOneVersion($versionNumber, $con);
5594: if (!$version) {
5595: throw new PropelException(sprintf('No Product object found with version %d', $version));
5596: }
5597: $this->populateFromVersion($version, $con);
5598:
5599: return $this;
5600: }
5601:
5602: 5603: 5604: 5605: 5606: 5607: 5608: 5609: 5610:
5611: public function populateFromVersion($version, $con = null, &$loadedObjects = array())
5612: {
5613:
5614: $loadedObjects['Product'][$version->getId()][$version->getVersion()] = $this;
5615: $this->setId($version->getId());
5616: $this->setTaxRuleId($version->getTaxRuleId());
5617: $this->setRef($version->getRef());
5618: $this->setPrice($version->getPrice());
5619: $this->setPrice2($version->getPrice2());
5620: $this->setEcotax($version->getEcotax());
5621: $this->setNewness($version->getNewness());
5622: $this->setPromo($version->getPromo());
5623: $this->setStock($version->getStock());
5624: $this->setVisible($version->getVisible());
5625: $this->setWeight($version->getWeight());
5626: $this->setPosition($version->getPosition());
5627: $this->setCreatedAt($version->getCreatedAt());
5628: $this->setUpdatedAt($version->getUpdatedAt());
5629: $this->setVersion($version->getVersion());
5630: $this->setVersionCreatedAt($version->getVersionCreatedAt());
5631: $this->setVersionCreatedBy($version->getVersionCreatedBy());
5632:
5633: return $this;
5634: }
5635:
5636: 5637: 5638: 5639: 5640: 5641: 5642:
5643: public function getLastVersionNumber($con = null)
5644: {
5645: $v = ProductVersionQuery::create()
5646: ->filterByProduct($this)
5647: ->orderByVersion('desc')
5648: ->findOne($con);
5649: if (!$v) {
5650: return 0;
5651: }
5652:
5653: return $v->getVersion();
5654: }
5655:
5656: 5657: 5658: 5659: 5660: 5661: 5662:
5663: public function isLastVersion($con = null)
5664: {
5665: return $this->getLastVersionNumber($con) == $this->getVersion();
5666: }
5667:
5668: 5669: 5670: 5671: 5672: 5673: 5674: 5675:
5676: public function getOneVersion($versionNumber, $con = null)
5677: {
5678: return ProductVersionQuery::create()
5679: ->filterByProduct($this)
5680: ->filterByVersion($versionNumber)
5681: ->findOne($con);
5682: }
5683:
5684: 5685: 5686: 5687: 5688: 5689: 5690:
5691: public function getAllVersions($con = null)
5692: {
5693: $criteria = new Criteria();
5694: $criteria->addAscendingOrderByColumn(ProductVersionPeer::VERSION);
5695:
5696: return $this->getProductVersions($criteria, $con);
5697: }
5698:
5699: 5700: 5701: 5702: 5703: 5704: 5705: 5706: 5707: 5708: 5709: 5710: 5711: 5712: 5713: 5714: 5715:
5716: public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
5717: {
5718: $fromVersion = $this->toArray();
5719: $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
5720:
5721: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
5722: }
5723:
5724: 5725: 5726: 5727: 5728: 5729: 5730: 5731: 5732: 5733: 5734: 5735: 5736: 5737: 5738: 5739: 5740: 5741:
5742: public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
5743: {
5744: $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
5745: $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
5746:
5747: return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
5748: }
5749:
5750: 5751: 5752: 5753: 5754: 5755: 5756: 5757: 5758: 5759: 5760: 5761: 5762: 5763: 5764: 5765: 5766:
5767: protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
5768: {
5769: $fromVersionNumber = $fromVersion['Version'];
5770: $toVersionNumber = $toVersion['Version'];
5771: $ignoredColumns = array_merge(array(
5772: 'Version',
5773: 'VersionCreatedAt',
5774: 'VersionCreatedBy',
5775: ), $ignoredColumns);
5776: $diff = array();
5777: foreach ($fromVersion as $key => $value) {
5778: if (in_array($key, $ignoredColumns)) {
5779: continue;
5780: }
5781: if ($toVersion[$key] != $value) {
5782: switch ($keys) {
5783: case 'versions':
5784: $diff[$fromVersionNumber][$key] = $value;
5785: $diff[$toVersionNumber][$key] = $toVersion[$key];
5786: break;
5787: default:
5788: $diff[$key] = array(
5789: $fromVersionNumber => $value,
5790: $toVersionNumber => $toVersion[$key],
5791: );
5792: break;
5793: }
5794: }
5795: }
5796:
5797: return $diff;
5798: }
5799: 5800: 5801: 5802: 5803: 5804: 5805: 5806: 5807:
5808: public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null)
5809: {
5810: $criteria = ProductVersionQuery::create(null, $criteria);
5811: $criteria->addDescendingOrderByColumn(ProductVersionPeer::VERSION);
5812: $criteria->limit($number);
5813:
5814: return $this->getProductVersions($criteria, $con);
5815: }
5816: }
5817: