Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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