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.

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