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.

825 line
20KB

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