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.

739 lines
18KB

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