You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

796 lines
19KB

  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. }