您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ProductFamilyModel.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Product;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
  8. use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyTrait;
  9. use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
  10. use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
  11. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  12. use Lc\SovBundle\Model\File\FileInterface;
  13. /**
  14. * @ORM\MappedSuperclass()
  15. */
  16. abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, ProductFamilyInterface, FilterSectionInterface
  17. {
  18. use ProductPropertyTrait;
  19. const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure';
  20. const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family';
  21. const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product';
  22. const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure';
  23. const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity';
  24. const WARNING_MESSAGE_TYPE_SUCCESS = 'success';
  25. const WARNING_MESSAGE_TYPE_ERROR = 'error';
  26. const WARNING_MESSAGE_TYPE_WARNING = 'warning';
  27. const WARNING_MESSAGE_TYPE_INFO = 'info';
  28. const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple';
  29. const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple';
  30. const BEHAVIOR_PRICE_BY_PIECE = 'by-piece';
  31. const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit';
  32. const QUALITY_LABEL_AB = 'ab';
  33. const QUALITY_LABEL_NP = 'nature-progres';
  34. const QUALITY_LABEL_HVE = 'hve';
  35. const QUALITY_LABEL_TVVR = 'tvvr';
  36. const QUALITY_LABEL_AOC = 'aoc';
  37. const QUALITY_LABEL_AOP = 'aop';
  38. const QUALITY_LABEL_IGP = 'igp';
  39. static $organicLabels = [
  40. self::QUALITY_LABEL_AB,
  41. self::QUALITY_LABEL_NP,
  42. self::QUALITY_LABEL_HVE,
  43. self::QUALITY_LABEL_TVVR
  44. ];
  45. static $geographicLabels = [
  46. self::QUALITY_LABEL_AOC,
  47. self::QUALITY_LABEL_AOP,
  48. self::QUALITY_LABEL_IGP,
  49. ];
  50. const TYPE_EXPIRATION_DATE_DLC = 'dlc';
  51. const TYPE_EXPIRATION_DATE_DDM = 'ddm';
  52. const TYPE_EXPIRATION_DATE_DLUO = 'dluo';
  53. const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family';
  54. const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product';
  55. // @TODO : Champ hydraté par ProductFamilyBuilder ?
  56. protected $reductionCatalog;
  57. /**
  58. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies")
  59. */
  60. protected $productCategories;
  61. /**
  62. * @ORM\Column(type="boolean")
  63. */
  64. protected $activeProducts;
  65. /**
  66. * @ORM\Column(type="string", length=255, nullable=true)
  67. */
  68. protected $productsType;
  69. /**
  70. * @ORM\Column(type="boolean", nullable=true)
  71. */
  72. protected $productsQuantityAsTitle;
  73. /**
  74. * @ORM\Column(type="string", length=255, nullable=true)
  75. */
  76. protected $quantityLabel;
  77. /**
  78. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"})
  79. * @ORM\OrderBy({"position" = "ASC"})
  80. */
  81. protected $products;
  82. /**
  83. * @ORM\Column(type="text", nullable=true)
  84. */
  85. protected $subtitle;
  86. /**
  87. * @ORM\Column(type="text", nullable=true)
  88. */
  89. protected $warningMessage;
  90. /**
  91. * @ORM\Column(type="string", length=255, nullable=true)
  92. */
  93. protected $warningMessageType;
  94. /**
  95. * @ORM\Column(type="text", nullable=true)
  96. */
  97. protected $note;
  98. /**
  99. * @ORM\Column(type="string", length=31, nullable=true)
  100. */
  101. protected $behaviorOutOfStock;
  102. /**
  103. * @ORM\Column(type="string", length=31)
  104. */
  105. protected $behaviorCountStock;
  106. /**
  107. * @ORM\Column(type="string", length=255)
  108. */
  109. protected $behaviorStockCycle;
  110. /**
  111. * @ORM\Column(type="string", length=255)
  112. */
  113. protected $behaviorDisplaySale;
  114. /**
  115. * @ORM\Column(type="string", length=255, nullable=true)
  116. */
  117. protected $exportTitle;
  118. /**
  119. * @ORM\Column(type="text", nullable=true)
  120. */
  121. protected $exportNote;
  122. /**
  123. * @ORM\Column(type="date", nullable=true)
  124. */
  125. protected $propertyNoveltyExpirationDate;
  126. /**
  127. * @ORM\Column(type="string", length=255, nullable=true)
  128. */
  129. protected $propertyOrganicLabel;
  130. /**
  131. * @ORM\Column(type="text", nullable=true)
  132. */
  133. protected $propertyAllergens;
  134. /**
  135. * @ORM\Column(type="text", nullable=true)
  136. */
  137. protected $propertyComposition;
  138. /**
  139. * @ORM\Column(type="text", nullable=true)
  140. */
  141. protected $propertyFragrances;
  142. /**
  143. * @ORM\Column(type="text", nullable=true)
  144. */
  145. protected $propertyPackaging;
  146. /**
  147. * @ORM\Column(type="text", nullable=true)
  148. */
  149. protected $propertyCharacteristics;
  150. /**
  151. * @ORM\Column(type="text", nullable=true)
  152. */
  153. protected $propertyWeight;
  154. /**
  155. * @ORM\Column(type="text", nullable=true)
  156. */
  157. protected $propertyQuantity;
  158. /**
  159. * @ORM\Column(type="text", nullable=true)
  160. */
  161. protected $propertyFeature;
  162. /**
  163. * @ORM\Column(type="text", nullable=true)
  164. */
  165. protected $propertyVariety;
  166. /**
  167. * @ORM\Column(type="text", nullable=true)
  168. */
  169. protected $propertyAlcoholLevel;
  170. /**
  171. * @ORM\Column(type="string", length=255, nullable=true)
  172. */
  173. protected $behaviorExpirationDate;
  174. /**
  175. * @ORM\Column(type="string", length=255, nullable=true)
  176. */
  177. protected $typeExpirationDate;
  178. /**
  179. * @ORM\Column(type="string", length=32, nullable=true)
  180. */
  181. protected $behaviorAddToCart;
  182. /**
  183. * @ORM\Column(type="string", length=31)
  184. */
  185. protected $behaviorPrice;
  186. /**
  187. * @ORM\Column(type="boolean")
  188. */
  189. protected $saleStatus;
  190. /**
  191. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="productFamily", cascade={"persist"})
  192. */
  193. protected $productFamilySectionProperties;
  194. /**
  195. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
  196. */
  197. protected $image;
  198. /**
  199. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\QualityLabelInterface", fetch="EAGER")
  200. */
  201. protected $qualityLabels;
  202. public function __construct()
  203. {
  204. $this->productCategories = new ArrayCollection();
  205. $this->products = new ArrayCollection();
  206. $this->qualityLabels = new ArrayCollection();
  207. }
  208. public function __toString()
  209. {
  210. return $this->getTitle();
  211. }
  212. public function getActiveProducts(): ?bool
  213. {
  214. return $this->activeProducts;
  215. }
  216. public function setActiveProducts(bool $activeProducts): self
  217. {
  218. $this->activeProducts = $activeProducts;
  219. return $this;
  220. }
  221. public function getProductsQuantityAsTitle(): ?bool
  222. {
  223. return $this->productsQuantityAsTitle;
  224. }
  225. public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle): self
  226. {
  227. $this->productsQuantityAsTitle = $productsQuantityAsTitle;
  228. return $this;
  229. }
  230. public function getProductsType(): ?string
  231. {
  232. return $this->productsType;
  233. }
  234. public function setProductsType(?string $productsType): self
  235. {
  236. $this->productsType = $productsType;
  237. return $this;
  238. }
  239. public function getQuantityLabel(): ?string
  240. {
  241. return $this->quantityLabel;
  242. }
  243. public function setQuantityLabel(?string $quantityLabel): self
  244. {
  245. $this->quantityLabel = $quantityLabel;
  246. return $this;
  247. }
  248. /**
  249. * @return Collection|ProductInterface[]
  250. */
  251. public function getProducts(): Collection
  252. {
  253. return $this->products;
  254. }
  255. public function addProduct(ProductInterface $product): self
  256. {
  257. if (!$this->products->contains($product)) {
  258. $this->products[] = $product;
  259. $product->setProductFamily($this);
  260. }
  261. return $this;
  262. }
  263. public function removeProduct(ProductInterface $product): self
  264. {
  265. if ($this->products->contains($product)) {
  266. $this->products->removeElement($product);
  267. // set the owning side to null (unless already changed)
  268. if ($product->getProductFamily() === $this) {
  269. $product->setProductFamily(null);
  270. }
  271. }
  272. return $this;
  273. }
  274. public function getReductionCatalog(): ?ReductionCatalogInterface
  275. {
  276. return $this->reductionCatalog;
  277. }
  278. public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog): self
  279. {
  280. $this->reductionCatalog = $reductionCatalog;
  281. return $this;
  282. }
  283. /**
  284. * @return Collection|ProductCategoryInterface[]
  285. */
  286. public function getProductCategories(): Collection
  287. {
  288. return $this->productCategories;
  289. }
  290. public function initProductCategories()
  291. {
  292. $this->productCategories = new ArrayCollection();
  293. }
  294. public function addProductCategory(ProductCategoryInterface $productCategory): self
  295. {
  296. if (!$this->productCategories->contains($productCategory)) {
  297. $this->productCategories[] = $productCategory;
  298. }
  299. return $this;
  300. }
  301. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  302. {
  303. if ($this->productCategories->contains($productCategory)) {
  304. $this->productCategories->removeElement($productCategory);
  305. }
  306. return $this;
  307. }
  308. public function getSubtitle(): ?string
  309. {
  310. return $this->subtitle;
  311. }
  312. public function setSubtitle(?string $subtitle): self
  313. {
  314. $this->subtitle = $subtitle;
  315. return $this;
  316. }
  317. public function getWarningMessage(): ?string
  318. {
  319. return $this->warningMessage;
  320. }
  321. public function setWarningMessage(?string $warningMessage): self
  322. {
  323. $this->warningMessage = $warningMessage;
  324. return $this;
  325. }
  326. public function getWarningMessageType(): ?string
  327. {
  328. return $this->warningMessageType;
  329. }
  330. public function setWarningMessageType(?string $warningMessageType): self
  331. {
  332. $this->warningMessageType = $warningMessageType;
  333. return $this;
  334. }
  335. public function getNote(): ?string
  336. {
  337. return $this->note;
  338. }
  339. public function setNote(?string $note): self
  340. {
  341. $this->note = $note;
  342. return $this;
  343. }
  344. public function getBehaviorOutOfStock(): ?string
  345. {
  346. return $this->behaviorOutOfStock;
  347. }
  348. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  349. {
  350. $this->behaviorOutOfStock = $behaviorOutOfStock;
  351. return $this;
  352. }
  353. public function getBehaviorCountStock(): ?string
  354. {
  355. return $this->behaviorCountStock;
  356. }
  357. public function setBehaviorCountStock(string $behaviorCountStock): self
  358. {
  359. $this->behaviorCountStock = $behaviorCountStock;
  360. return $this;
  361. }
  362. public function getExportTitle(): ?string
  363. {
  364. return $this->exportTitle;
  365. }
  366. public function setExportTitle(?string $exportTitle): self
  367. {
  368. $this->exportTitle = $exportTitle;
  369. return $this;
  370. }
  371. public function getExportNote(): ?string
  372. {
  373. return $this->exportNote;
  374. }
  375. public function setExportNote(?string $exportNote): self
  376. {
  377. $this->exportNote = $exportNote;
  378. return $this;
  379. }
  380. public function getBehaviorStockCycle(): ?string
  381. {
  382. return $this->behaviorStockCycle;
  383. }
  384. public function setBehaviorStockCycle(string $behaviorStockCycle): self
  385. {
  386. $this->behaviorStockCycle = $behaviorStockCycle;
  387. return $this;
  388. }
  389. public function getBehaviorDisplaySale(): ?string
  390. {
  391. return $this->behaviorDisplaySale;
  392. }
  393. public function setBehaviorDisplaySale(string $behaviorDisplaySale): self
  394. {
  395. $this->behaviorDisplaySale = $behaviorDisplaySale;
  396. return $this;
  397. }
  398. public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
  399. {
  400. return $this->propertyNoveltyExpirationDate;
  401. }
  402. public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate): self
  403. {
  404. $this->propertyNoveltyExpirationDate = $propertyNoveltyExpirationDate;
  405. return $this;
  406. }
  407. public function getPropertyOrganicLabel(): ?string
  408. {
  409. return $this->propertyOrganicLabel;
  410. }
  411. public function setPropertyOrganicLabel(?string $propertyOrganicLabel): self
  412. {
  413. $this->propertyOrganicLabel = $propertyOrganicLabel;
  414. return $this;
  415. }
  416. public function getPropertyAllergens(): ?string
  417. {
  418. return $this->propertyAllergens;
  419. }
  420. public function setPropertyAllergens(?string $propertyAllergens): self
  421. {
  422. $this->propertyAllergens = $propertyAllergens;
  423. return $this;
  424. }
  425. public function getPropertyComposition(): ?string
  426. {
  427. return $this->propertyComposition;
  428. }
  429. public function setPropertyComposition(?string $propertyComposition): self
  430. {
  431. $this->propertyComposition = $propertyComposition;
  432. return $this;
  433. }
  434. public function getPropertyFragrances(): ?string
  435. {
  436. return $this->propertyFragrances;
  437. }
  438. public function setPropertyFragrances(?string $propertyFragrances): self
  439. {
  440. $this->propertyFragrances = $propertyFragrances;
  441. return $this;
  442. }
  443. public function getBehaviorExpirationDate(): ?string
  444. {
  445. return $this->behaviorExpirationDate;
  446. }
  447. public function setBehaviorExpirationDate(?string $behaviorExpirationDate): self
  448. {
  449. $this->behaviorExpirationDate = $behaviorExpirationDate;
  450. return $this;
  451. }
  452. public function getTypeExpirationDate(): ?string
  453. {
  454. return $this->typeExpirationDate;
  455. }
  456. public function setTypeExpirationDate(?string $typeExpirationDate): self
  457. {
  458. $this->typeExpirationDate = $typeExpirationDate;
  459. return $this;
  460. }
  461. public function getPropertyWeight(): ?string
  462. {
  463. return $this->propertyWeight;
  464. }
  465. public function setPropertyWeight(?string $propertyWeight): self
  466. {
  467. $this->propertyWeight = $propertyWeight;
  468. return $this;
  469. }
  470. public function getPropertyQuantity(): ?string
  471. {
  472. return $this->propertyQuantity;
  473. }
  474. public function setPropertyQuantity(?string $propertyQuantity): self
  475. {
  476. $this->propertyQuantity = $propertyQuantity;
  477. return $this;
  478. }
  479. public function getPropertyVariety(): ?string
  480. {
  481. return $this->propertyVariety;
  482. }
  483. public function setPropertyVariety(?string $propertyVariety): self
  484. {
  485. $this->propertyVariety = $propertyVariety;
  486. return $this;
  487. }
  488. public function getPropertyFeature(): ?string
  489. {
  490. return $this->propertyFeature;
  491. }
  492. public function setPropertyFeature(?string $propertyFeature): self
  493. {
  494. $this->propertyFeature = $propertyFeature;
  495. return $this;
  496. }
  497. public function getPropertyAlcoholLevel(): ?string
  498. {
  499. return $this->propertyAlcoholLevel;
  500. }
  501. public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
  502. {
  503. $this->propertyAlcoholLevel = $propertyAlcoholLevel;
  504. return $this;
  505. }
  506. public function getPropertyPackaging(): ?string
  507. {
  508. return $this->propertyPackaging;
  509. }
  510. public function setPropertyPackaging(?string $propertyPackaging): self
  511. {
  512. $this->propertyPackaging = $propertyPackaging;
  513. return $this;
  514. }
  515. public function getPropertyCharacteristics(): ?string
  516. {
  517. return $this->propertyCharacteristics;
  518. }
  519. public function setPropertyCharacteristics(?string $propertyCharacteristics): self
  520. {
  521. $this->propertyCharacteristics = $propertyCharacteristics;
  522. return $this;
  523. }
  524. public function getBehaviorAddToCart(): ?string
  525. {
  526. return $this->behaviorAddToCart;
  527. }
  528. public function setBehaviorAddToCart(?string $behaviorAddToCart): self
  529. {
  530. $this->behaviorAddToCart = $behaviorAddToCart;
  531. return $this;
  532. }
  533. public function getBehaviorPrice(): ?string
  534. {
  535. return $this->behaviorPrice;
  536. }
  537. public function setBehaviorPrice(?string $behaviorPrice): self
  538. {
  539. $this->behaviorPrice = $behaviorPrice;
  540. return $this;
  541. }
  542. public function getSaleStatus(): ?bool
  543. {
  544. return $this->saleStatus;
  545. }
  546. public function setSaleStatus(bool $saleStatus): self
  547. {
  548. $this->saleStatus = $saleStatus;
  549. return $this;
  550. }
  551. public function getImage(): ?FileInterface
  552. {
  553. return $this->image;
  554. }
  555. public function setImage(?FileInterface $image): self
  556. {
  557. $this->image = $image;
  558. return $this;
  559. }
  560. /**
  561. * @return Collection|ProductFamilySectionPropertyInterface[]
  562. */
  563. public function getProductFamilySectionProperties(): Collection
  564. {
  565. return $this->productFamilySectionProperties;
  566. }
  567. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  568. {
  569. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  570. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  571. $productFamilySectionProperty->setProductFamily($this);
  572. }
  573. return $this;
  574. }
  575. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  576. {
  577. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  578. // set the owning side to null (unless already changed)
  579. if ($productFamilySectionProperty->getProductFamily() === $this) {
  580. $productFamilySectionProperty->setProductFamily(null);
  581. }
  582. }
  583. return $this;
  584. }
  585. /**
  586. * @return Collection|QualityLabelInterface[]
  587. */
  588. public function getQualityLabels(): Collection
  589. {
  590. return $this->qualityLabels;
  591. }
  592. public function addQualityLabel(QualityLabelInterface $qualityLabel): self
  593. {
  594. if (!$this->qualityLabels->contains($qualityLabel)) {
  595. $this->qualityLabels[] = $qualityLabel;
  596. }
  597. return $this;
  598. }
  599. public function removeQualityLabel(QualityLabelInterface $qualityLabel): self
  600. {
  601. $this->qualityLabels->removeElement($qualityLabel);
  602. return $this;
  603. }
  604. }