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.

791 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->products = new ArrayCollection();
  213. $this->qualityLabels = new ArrayCollection();
  214. }
  215. public function __toString()
  216. {
  217. return $this->getTitle();
  218. }
  219. public function getActiveProducts(): ?bool
  220. {
  221. return $this->activeProducts;
  222. }
  223. public function setActiveProducts(bool $activeProducts): self
  224. {
  225. $this->activeProducts = $activeProducts;
  226. return $this;
  227. }
  228. public function getProductsQuantityAsTitle(): ?bool
  229. {
  230. return $this->productsQuantityAsTitle;
  231. }
  232. public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle): self
  233. {
  234. $this->productsQuantityAsTitle = $productsQuantityAsTitle;
  235. return $this;
  236. }
  237. public function getProductsType(): ?string
  238. {
  239. return $this->productsType;
  240. }
  241. public function setProductsType(?string $productsType): self
  242. {
  243. $this->productsType = $productsType;
  244. return $this;
  245. }
  246. public function getQuantityLabel(): ?string
  247. {
  248. return $this->quantityLabel;
  249. }
  250. public function setQuantityLabel(?string $quantityLabel): self
  251. {
  252. $this->quantityLabel = $quantityLabel;
  253. return $this;
  254. }
  255. /**
  256. * @return Collection|ProductInterface[]
  257. */
  258. public function getProducts(): Collection
  259. {
  260. return $this->products;
  261. }
  262. public function addProduct(ProductInterface $product): self
  263. {
  264. if (!$this->products->contains($product)) {
  265. $this->products[] = $product;
  266. $product->setProductFamily($this);
  267. }
  268. return $this;
  269. }
  270. public function removeProduct(ProductInterface $product): self
  271. {
  272. if ($this->products->contains($product)) {
  273. $this->products->removeElement($product);
  274. // set the owning side to null (unless already changed)
  275. if ($product->getProductFamily() === $this) {
  276. $product->setProductFamily(null);
  277. }
  278. }
  279. return $this;
  280. }
  281. public function getReductionCatalog(): ?ReductionCatalogInterface
  282. {
  283. return $this->reductionCatalog;
  284. }
  285. public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog): self
  286. {
  287. $this->reductionCatalog = $reductionCatalog;
  288. return $this;
  289. }
  290. /**
  291. * @return Collection|ProductCategoryInterface[]
  292. */
  293. public function getProductCategories(): Collection
  294. {
  295. return $this->productCategories;
  296. }
  297. public function initProductCategories()
  298. {
  299. $this->productCategories = new ArrayCollection();
  300. }
  301. public function addProductCategory(ProductCategoryInterface $productCategory): self
  302. {
  303. if (!$this->productCategories->contains($productCategory)) {
  304. $this->productCategories[] = $productCategory;
  305. }
  306. return $this;
  307. }
  308. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  309. {
  310. if ($this->productCategories->contains($productCategory)) {
  311. $this->productCategories->removeElement($productCategory);
  312. }
  313. return $this;
  314. }
  315. public function getSubtitle(): ?string
  316. {
  317. return $this->subtitle;
  318. }
  319. public function setSubtitle(?string $subtitle): self
  320. {
  321. $this->subtitle = $subtitle;
  322. return $this;
  323. }
  324. public function getWarningMessage(): ?string
  325. {
  326. return $this->warningMessage;
  327. }
  328. public function setWarningMessage(?string $warningMessage): self
  329. {
  330. $this->warningMessage = $warningMessage;
  331. return $this;
  332. }
  333. public function getWarningMessageType(): ?string
  334. {
  335. return $this->warningMessageType;
  336. }
  337. public function setWarningMessageType(?string $warningMessageType): self
  338. {
  339. $this->warningMessageType = $warningMessageType;
  340. return $this;
  341. }
  342. public function getNote(): ?string
  343. {
  344. return $this->note;
  345. }
  346. public function setNote(?string $note): self
  347. {
  348. $this->note = $note;
  349. return $this;
  350. }
  351. public function getBehaviorOutOfStock(): ?string
  352. {
  353. return $this->behaviorOutOfStock;
  354. }
  355. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  356. {
  357. $this->behaviorOutOfStock = $behaviorOutOfStock;
  358. return $this;
  359. }
  360. public function getBehaviorCountStock(): ?string
  361. {
  362. return $this->behaviorCountStock;
  363. }
  364. public function setBehaviorCountStock(string $behaviorCountStock): self
  365. {
  366. $this->behaviorCountStock = $behaviorCountStock;
  367. return $this;
  368. }
  369. public function getExportTitle(): ?string
  370. {
  371. return $this->exportTitle;
  372. }
  373. public function setExportTitle(?string $exportTitle): self
  374. {
  375. $this->exportTitle = $exportTitle;
  376. return $this;
  377. }
  378. public function getExportNote(): ?string
  379. {
  380. return $this->exportNote;
  381. }
  382. public function setExportNote(?string $exportNote): self
  383. {
  384. $this->exportNote = $exportNote;
  385. return $this;
  386. }
  387. public function getBehaviorStockCycle(): ?string
  388. {
  389. return $this->behaviorStockCycle;
  390. }
  391. public function setBehaviorStockCycle(string $behaviorStockCycle): self
  392. {
  393. $this->behaviorStockCycle = $behaviorStockCycle;
  394. return $this;
  395. }
  396. public function getBehaviorDisplaySale(): ?string
  397. {
  398. return $this->behaviorDisplaySale;
  399. }
  400. public function setBehaviorDisplaySale(string $behaviorDisplaySale): self
  401. {
  402. $this->behaviorDisplaySale = $behaviorDisplaySale;
  403. return $this;
  404. }
  405. public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
  406. {
  407. return $this->propertyNoveltyExpirationDate;
  408. }
  409. public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate): self
  410. {
  411. $this->propertyNoveltyExpirationDate = $propertyNoveltyExpirationDate;
  412. return $this;
  413. }
  414. public function getPropertyOrganicLabel(): ?string
  415. {
  416. return $this->propertyOrganicLabel;
  417. }
  418. public function setPropertyOrganicLabel(?string $propertyOrganicLabel): self
  419. {
  420. $this->propertyOrganicLabel = $propertyOrganicLabel;
  421. return $this;
  422. }
  423. public function getPropertyAllergens(): ?string
  424. {
  425. return $this->propertyAllergens;
  426. }
  427. public function setPropertyAllergens(?string $propertyAllergens): self
  428. {
  429. $this->propertyAllergens = $propertyAllergens;
  430. return $this;
  431. }
  432. public function getPropertyComposition(): ?string
  433. {
  434. return $this->propertyComposition;
  435. }
  436. public function setPropertyComposition(?string $propertyComposition): self
  437. {
  438. $this->propertyComposition = $propertyComposition;
  439. return $this;
  440. }
  441. public function getPropertyFragrances(): ?string
  442. {
  443. return $this->propertyFragrances;
  444. }
  445. public function setPropertyFragrances(?string $propertyFragrances): self
  446. {
  447. $this->propertyFragrances = $propertyFragrances;
  448. return $this;
  449. }
  450. public function getBehaviorExpirationDate(): ?string
  451. {
  452. return $this->behaviorExpirationDate;
  453. }
  454. public function setBehaviorExpirationDate(?string $behaviorExpirationDate): self
  455. {
  456. $this->behaviorExpirationDate = $behaviorExpirationDate;
  457. return $this;
  458. }
  459. public function getTypeExpirationDate(): ?string
  460. {
  461. return $this->typeExpirationDate;
  462. }
  463. public function setTypeExpirationDate(?string $typeExpirationDate): self
  464. {
  465. $this->typeExpirationDate = $typeExpirationDate;
  466. return $this;
  467. }
  468. public function getPropertyWeight(): ?string
  469. {
  470. return $this->propertyWeight;
  471. }
  472. public function setPropertyWeight(?string $propertyWeight): self
  473. {
  474. $this->propertyWeight = $propertyWeight;
  475. return $this;
  476. }
  477. public function getPropertyQuantity(): ?string
  478. {
  479. return $this->propertyQuantity;
  480. }
  481. public function setPropertyQuantity(?string $propertyQuantity): self
  482. {
  483. $this->propertyQuantity = $propertyQuantity;
  484. return $this;
  485. }
  486. public function getPropertyVariety(): ?string
  487. {
  488. return $this->propertyVariety;
  489. }
  490. public function setPropertyVariety(?string $propertyVariety): self
  491. {
  492. $this->propertyVariety = $propertyVariety;
  493. return $this;
  494. }
  495. public function getPropertyFeature(): ?string
  496. {
  497. return $this->propertyFeature;
  498. }
  499. public function setPropertyFeature(?string $propertyFeature): self
  500. {
  501. $this->propertyFeature = $propertyFeature;
  502. return $this;
  503. }
  504. public function getPropertyAlcoholLevel(): ?string
  505. {
  506. return $this->propertyAlcoholLevel;
  507. }
  508. public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
  509. {
  510. $this->propertyAlcoholLevel = $propertyAlcoholLevel;
  511. return $this;
  512. }
  513. public function getPropertyPackaging(): ?string
  514. {
  515. return $this->propertyPackaging;
  516. }
  517. public function setPropertyPackaging(?string $propertyPackaging): self
  518. {
  519. $this->propertyPackaging = $propertyPackaging;
  520. return $this;
  521. }
  522. public function getPropertyCharacteristics(): ?string
  523. {
  524. return $this->propertyCharacteristics;
  525. }
  526. public function setPropertyCharacteristics(?string $propertyCharacteristics): self
  527. {
  528. $this->propertyCharacteristics = $propertyCharacteristics;
  529. return $this;
  530. }
  531. public function getBehaviorAddToCart(): ?string
  532. {
  533. return $this->behaviorAddToCart;
  534. }
  535. public function setBehaviorAddToCart(?string $behaviorAddToCart): self
  536. {
  537. $this->behaviorAddToCart = $behaviorAddToCart;
  538. return $this;
  539. }
  540. public function getBehaviorPrice(): ?string
  541. {
  542. return $this->behaviorPrice;
  543. }
  544. public function setBehaviorPrice(?string $behaviorPrice): self
  545. {
  546. $this->behaviorPrice = $behaviorPrice;
  547. return $this;
  548. }
  549. public function getSaleStatus(): ?bool
  550. {
  551. return $this->saleStatus;
  552. }
  553. public function setSaleStatus(bool $saleStatus): self
  554. {
  555. $this->saleStatus = $saleStatus;
  556. return $this;
  557. }
  558. public function getImage(): ?FileInterface
  559. {
  560. return $this->image;
  561. }
  562. public function setImage(?FileInterface $image): self
  563. {
  564. $this->image = $image;
  565. return $this;
  566. }
  567. /**
  568. * @return Collection|ProductFamilySectionPropertyInterface[]
  569. */
  570. public function getProductFamilySectionProperties(): Collection
  571. {
  572. return $this->productFamilySectionProperties;
  573. }
  574. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  575. {
  576. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  577. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  578. $productFamilySectionProperty->setProductFamily($this);
  579. }
  580. return $this;
  581. }
  582. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  583. {
  584. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  585. // set the owning side to null (unless already changed)
  586. if ($productFamilySectionProperty->getProductFamily() === $this) {
  587. $productFamilySectionProperty->setProductFamily(null);
  588. }
  589. }
  590. return $this;
  591. }
  592. /**
  593. * @return Collection|QualityLabelInterface[]
  594. */
  595. public function getQualityLabels(): Collection
  596. {
  597. return $this->qualityLabels;
  598. }
  599. public function addQualityLabel(QualityLabelInterface $qualityLabel): self
  600. {
  601. if (!$this->qualityLabels->contains($qualityLabel)) {
  602. $this->qualityLabels[] = $qualityLabel;
  603. }
  604. return $this;
  605. }
  606. public function removeQualityLabel(QualityLabelInterface $qualityLabel): self
  607. {
  608. $this->qualityLabels->removeElement($qualityLabel);
  609. return $this;
  610. }
  611. }