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.

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