Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

785 linhas
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 $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. }