Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ProductFamilyModel.php 19KB

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