Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ProductFamilyModel.php 19KB

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