Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

1055 lines
26KB

  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
  21. {
  22. use ProductPropertyTrait;
  23. use BlameableNullableTrait;
  24. const BEHAVIOR_COUNT_STOCK_UNLIMITED = 'unlimited';
  25. const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure';
  26. const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family';
  27. const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product';
  28. public function getBehaviorCountStockChoices(): array
  29. {
  30. return [
  31. self::BEHAVIOR_COUNT_STOCK_BY_MEASURE,
  32. self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT,
  33. self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
  34. self::BEHAVIOR_COUNT_STOCK_UNLIMITED,
  35. ];
  36. }
  37. const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure';
  38. const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity';
  39. public function getBehaviorDisplaySaleChoices(): array
  40. {
  41. return [
  42. self::BEHAVIOR_DISPLAY_SALE_BY_MEASURE,
  43. self::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY,
  44. ];
  45. }
  46. const BEHAVIOR_STOCK_CYCLE_RENEWABLE = 'renewable';
  47. const BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION = 'renewable-with-validation';
  48. const BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE = 'non-renewable';
  49. public function getBehaviorStockCycleChoices(): array
  50. {
  51. return [
  52. self::BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE,
  53. self::BEHAVIOR_STOCK_CYCLE_RENEWABLE,
  54. self::BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION,
  55. ];
  56. }
  57. const WARNING_MESSAGE_TYPE_SUCCESS = 'success';
  58. const WARNING_MESSAGE_TYPE_ERROR = 'error';
  59. const WARNING_MESSAGE_TYPE_WARNING = 'warning';
  60. const WARNING_MESSAGE_TYPE_INFO = 'info';
  61. public function getWaringMessageTypeChoices(): array
  62. {
  63. return [
  64. self::WARNING_MESSAGE_TYPE_ERROR,
  65. self::WARNING_MESSAGE_TYPE_INFO,
  66. self::WARNING_MESSAGE_TYPE_SUCCESS,
  67. self::WARNING_MESSAGE_TYPE_WARNING,
  68. ];
  69. }
  70. const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple';
  71. const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple';
  72. public function getBehaviorAddToCartChoices(): array
  73. {
  74. return [
  75. self::BEHAVIOR_ADD_TO_CART_MULTIPLE,
  76. self::BEHAVIOR_ADD_TO_CART_SIMPLE,
  77. ];
  78. }
  79. const BEHAVIOR_PRICE_BY_PIECE = 'by-piece';
  80. const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit';
  81. public function getBehaviorPriceChoices(): array
  82. {
  83. return [
  84. self::BEHAVIOR_PRICE_BY_PIECE,
  85. self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT,
  86. ];
  87. }
  88. const PROPERTY_ORGANIC_LABEL_AB = 'ab';
  89. const PROPERTY_ORGANIC_LABEL_NP = 'nature-progres';
  90. const PROPERTY_ORGANIC_LABEL_HVE = 'hve';
  91. const PROPERTY_ORGANIC_LABEL_TVVR = 'tvvr';
  92. public function getPropertyOrganicLabelChoices(): array
  93. {
  94. return [
  95. self::PROPERTY_ORGANIC_LABEL_AB,
  96. self::PROPERTY_ORGANIC_LABEL_NP,
  97. self::PROPERTY_ORGANIC_LABEL_HVE,
  98. self::PROPERTY_ORGANIC_LABEL_TVVR,
  99. ];
  100. }
  101. const TYPE_EXPIRATION_DATE_DLC = 'dlc';
  102. const TYPE_EXPIRATION_DATE_DDM = 'ddm';
  103. const TYPE_EXPIRATION_DATE_DLUO = 'dluo';
  104. public function getTypeExpirationDateChoices(): array
  105. {
  106. return [
  107. self::TYPE_EXPIRATION_DATE_DLC,
  108. self::TYPE_EXPIRATION_DATE_DDM,
  109. self::TYPE_EXPIRATION_DATE_DLUO,
  110. ];
  111. }
  112. const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family';
  113. const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product';
  114. public function getBehaviorExpirationDateChoices(): array
  115. {
  116. return [
  117. self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
  118. self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT
  119. ];
  120. }
  121. // @TODO : Champ hydraté par ProductFamilyBuilder ?
  122. protected $reductionCatalog;
  123. /**
  124. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies")
  125. */
  126. protected $productCategories;
  127. /**
  128. * @ORM\Column(type="boolean")
  129. */
  130. protected $activeProducts;
  131. /**
  132. * @ORM\Column(type="string", length=255, nullable=true)
  133. */
  134. protected $productsType;
  135. /**
  136. * @ORM\Column(type="boolean", nullable=true)
  137. */
  138. protected $productsQuantityAsTitle;
  139. /**
  140. * @ORM\Column(type="string", length=255, nullable=true)
  141. */
  142. protected $quantityLabel;
  143. /**
  144. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"})
  145. * @ORM\OrderBy({"position" = "ASC"})
  146. */
  147. protected $products;
  148. /**
  149. * @ORM\Column(type="string", length=255, nullable=true)
  150. */
  151. protected $subtitle;
  152. /**
  153. * @ORM\Column(type="text", nullable=true)
  154. */
  155. protected $warningMessage;
  156. /**
  157. * @ORM\Column(type="string", length=255, nullable=true)
  158. */
  159. protected $warningMessageType;
  160. /**
  161. * @ORM\Column(type="text", nullable=true)
  162. */
  163. protected $note;
  164. /**
  165. * @ORM\Column(type="string", length=31, nullable=true)
  166. */
  167. protected $behaviorOutOfStock;
  168. /**
  169. * @ORM\Column(type="string", length=31)
  170. */
  171. protected $behaviorCountStock;
  172. /**
  173. * @ORM\Column(type="string", length=255)
  174. */
  175. protected $behaviorStockWeek;
  176. /**
  177. * @ORM\Column(type="boolean", nullable=true)
  178. */
  179. protected $availabilityRenewedThisWeek;
  180. /**
  181. * @ORM\Column(type="string", length=255)
  182. */
  183. protected $behaviorDisplaySale;
  184. /**
  185. * @ORM\Column(type="string", length=255, nullable=true)
  186. */
  187. protected $exportTitle;
  188. /**
  189. * @ORM\Column(type="text", nullable=true)
  190. */
  191. protected $exportNote;
  192. /**
  193. * @ORM\Column(type="date", nullable=true)
  194. */
  195. protected $propertyNoveltyExpirationDate;
  196. /**
  197. * @ORM\Column(type="string", length=255, nullable=true)
  198. */
  199. protected $propertyOrganicLabel;
  200. /**
  201. * @ORM\Column(type="text", nullable=true)
  202. */
  203. protected $propertyAllergens;
  204. /**
  205. * @ORM\Column(type="text", nullable=true)
  206. */
  207. protected $propertyComposition;
  208. /**
  209. * @ORM\Column(type="text", nullable=true)
  210. */
  211. protected $propertyFragrances;
  212. /**
  213. * @ORM\Column(type="text", nullable=true)
  214. */
  215. protected $propertyPackaging;
  216. /**
  217. * @ORM\Column(type="text", nullable=true)
  218. */
  219. protected $propertyCharacteristics;
  220. /**
  221. * @ORM\Column(type="text", nullable=true)
  222. */
  223. protected $propertyWeight;
  224. /**
  225. * @ORM\Column(type="text", nullable=true)
  226. */
  227. protected $propertyQuantity;
  228. /**
  229. * @ORM\Column(type="text", nullable=true)
  230. */
  231. protected $propertyFeature;
  232. /**
  233. * @ORM\Column(type="text", nullable=true)
  234. */
  235. protected $propertyVariety;
  236. /**
  237. * @ORM\Column(type="text", nullable=true)
  238. */
  239. protected $propertyAlcoholLevel;
  240. /**
  241. * @ORM\Column(type="string", length=255, nullable=true)
  242. */
  243. protected $behaviorExpirationDate;
  244. /**
  245. * @ORM\Column(type="string", length=255, nullable=true)
  246. */
  247. protected $typeExpirationDate;
  248. /**
  249. * @ORM\Column(type="string", length=32, nullable=true)
  250. */
  251. protected $behaviorAddToCart;
  252. /**
  253. * @ORM\Column(type="string", length=31)
  254. */
  255. protected $behaviorPrice;
  256. /**
  257. * @ORM\Column(type="boolean")
  258. */
  259. protected $saleStatus;
  260. /**
  261. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
  262. * @ORM\JoinColumn(nullable=false)
  263. */
  264. protected $section;
  265. /**
  266. * @ORM\ManyToOne((targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
  267. */
  268. protected $image;
  269. public function __construct()
  270. {
  271. $this->productCategories = new ArrayCollection();
  272. $this->products = new ArrayCollection();
  273. }
  274. public function __toString()
  275. {
  276. return $this->getTitle();
  277. }
  278. public function getSection(): SectionInterface
  279. {
  280. return $this->section;
  281. }
  282. public function setSection(SectionInterface $section): self
  283. {
  284. $this->section = $section;
  285. return $this;
  286. }
  287. //TODO move
  288. public function getAvailableQuantityInherited()
  289. {
  290. $availableQuantity = 0;
  291. switch ($this->getBehaviorCountStock()) {
  292. case self::BEHAVIOR_COUNT_STOCK_BY_MEASURE :
  293. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :
  294. $availableQuantity = $this->getAvailableQuantity();
  295. break;
  296. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
  297. foreach ($this->getProductsOnline() as $product) {
  298. $availableQuantity += $product->getAvailableQuantityInherited();
  299. }
  300. break;
  301. case self::BEHAVIOR_COUNT_STOCK_UNLIMITED :
  302. $availableQuantity = false;
  303. break;
  304. }
  305. return $availableQuantity;
  306. }
  307. //TODO move
  308. public function getTaxRateInherited()
  309. {
  310. if ($this->getTaxRate()) {
  311. return $this->getTaxRate();
  312. } else {
  313. return $this->getSection()->getMerchant()->getTaxRate();
  314. }
  315. }
  316. public function getActiveProducts(): ?bool
  317. {
  318. return $this->activeProducts;
  319. }
  320. public function setActiveProducts(bool $activeProducts): self
  321. {
  322. $this->activeProducts = $activeProducts;
  323. return $this;
  324. }
  325. public function getProductsQuantityAsTitle(): ?bool
  326. {
  327. return $this->productsQuantityAsTitle;
  328. }
  329. public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle): self
  330. {
  331. $this->productsQuantityAsTitle = $productsQuantityAsTitle;
  332. return $this;
  333. }
  334. public function getProductsType(): ?string
  335. {
  336. return $this->productsType;
  337. }
  338. public function setProductsType(?string $productsType): self
  339. {
  340. $this->productsType = $productsType;
  341. return $this;
  342. }
  343. public function getQuantityLabel(): ?string
  344. {
  345. return $this->quantityLabel;
  346. }
  347. public function setQuantityLabel(?string $quantityLabel): self
  348. {
  349. $this->quantityLabel = $quantityLabel;
  350. return $this;
  351. }
  352. /**
  353. * @return Collection|ProductInterface[]
  354. */
  355. public function getProducts(): Collection
  356. {
  357. return $this->products;
  358. }
  359. //TODO move
  360. public function getProductsOnline(): Collection
  361. {
  362. $products = $this->getProducts();
  363. $productsOnlineArray = new ArrayCollection();
  364. foreach ($products as $product) {
  365. if ($product->getStatus() == 1 && $product->getOriginProduct() != true) {
  366. $productsOnlineArray[] = $product;
  367. }
  368. }
  369. return $productsOnlineArray;
  370. }
  371. public function addProduct(ProductInterface $product): self
  372. {
  373. if (!$this->products->contains($product)) {
  374. $this->products[] = $product;
  375. $product->setProductFamily($this);
  376. }
  377. return $this;
  378. }
  379. public function removeProduct(ProductInterface $product): self
  380. {
  381. if ($this->products->contains($product)) {
  382. $this->products->removeElement($product);
  383. // set the owning side to null (unless already changed)
  384. if ($product->getProductFamily() === $this) {
  385. $product->setProductFamily(null);
  386. }
  387. }
  388. return $this;
  389. }
  390. public function getReductionCatalog(): ?ReductionCatalogInterface
  391. {
  392. return $this->reductionCatalog;
  393. }
  394. //TODO move
  395. public function getReductionCatalogInherited(): ?ReductionCatalogInterface
  396. {
  397. return $this->getReductionCatalog();
  398. }
  399. public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog): self
  400. {
  401. $this->reductionCatalog = $reductionCatalog;
  402. return $this;
  403. }
  404. /**
  405. * @return Collection|ProductCategoryInterface[]
  406. */
  407. public function getProductCategories(): Collection
  408. {
  409. return $this->productCategories;
  410. }
  411. public function initProductCategories()
  412. {
  413. $this->productCategories = new ArrayCollection();
  414. }
  415. public function addProductCategory(ProductCategoryInterface $productCategory): self
  416. {
  417. if (!$this->productCategories->contains($productCategory)) {
  418. $this->productCategories[] = $productCategory;
  419. }
  420. return $this;
  421. }
  422. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  423. {
  424. if ($this->productCategories->contains($productCategory)) {
  425. $this->productCategories->removeElement($productCategory);
  426. }
  427. return $this;
  428. }
  429. //TODO move
  430. public function getProductCategoryParent()
  431. {
  432. $productCategories = $this->getProductCategories();
  433. if (count($productCategories) > 0) {
  434. return $productCategories[0]->getParent();
  435. }
  436. return false;
  437. }
  438. //TODO move
  439. public function getProductCategoryChild()
  440. {
  441. $productCategories = $this->getProductCategories();
  442. foreach ($productCategories as $productCategory) {
  443. if ($productCategory->getParent()) {
  444. return $productCategory;
  445. }
  446. }
  447. return false;
  448. }
  449. public function getSubtitle(): ?string
  450. {
  451. return $this->subtitle;
  452. }
  453. public function setSubtitle(?string $subtitle): self
  454. {
  455. $this->subtitle = $subtitle;
  456. return $this;
  457. }
  458. public function getWarningMessage(): ?string
  459. {
  460. return $this->warningMessage;
  461. }
  462. public function setWarningMessage(?string $warningMessage): self
  463. {
  464. $this->warningMessage = $warningMessage;
  465. return $this;
  466. }
  467. public function getWarningMessageType(): ?string
  468. {
  469. return $this->warningMessageType;
  470. }
  471. public function setWarningMessageType(?string $warningMessageType): self
  472. {
  473. $this->warningMessageType = $warningMessageType;
  474. return $this;
  475. }
  476. public function getNote(): ?string
  477. {
  478. return $this->note;
  479. }
  480. public function setNote(?string $note): self
  481. {
  482. $this->note = $note;
  483. return $this;
  484. }
  485. public function getBehaviorOutOfStock(): ?string
  486. {
  487. return $this->behaviorOutOfStock;
  488. }
  489. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  490. {
  491. $this->behaviorOutOfStock = $behaviorOutOfStock;
  492. return $this;
  493. }
  494. public function getBehaviorCountStock(): ?string
  495. {
  496. return $this->behaviorCountStock;
  497. }
  498. public function setBehaviorCountStock(string $behaviorCountStock): self
  499. {
  500. $this->behaviorCountStock = $behaviorCountStock;
  501. return $this;
  502. }
  503. public function getExportTitle(): ?string
  504. {
  505. return $this->exportTitle;
  506. }
  507. public function setExportTitle(?string $exportTitle): self
  508. {
  509. $this->exportTitle = $exportTitle;
  510. return $this;
  511. }
  512. public function getExportNote(): ?string
  513. {
  514. return $this->exportNote;
  515. }
  516. public function setExportNote(?string $exportNote): self
  517. {
  518. $this->exportNote = $exportNote;
  519. return $this;
  520. }
  521. public function getBehaviorStockWeek(): ?string
  522. {
  523. return $this->behaviorStockWeek;
  524. }
  525. public function setBehaviorStockWeek(string $behaviorStockWeek): self
  526. {
  527. $this->behaviorStockWeek = $behaviorStockWeek;
  528. return $this;
  529. }
  530. public function getAvailabilityRenewedThisWeek(): ?bool
  531. {
  532. return $this->availabilityRenewedThisWeek;
  533. }
  534. public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self
  535. {
  536. $this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek;
  537. return $this;
  538. }
  539. public function getBehaviorDisplaySale(): ?string
  540. {
  541. return $this->behaviorDisplaySale;
  542. }
  543. public function setBehaviorDisplaySale(string $behaviorDisplaySale): self
  544. {
  545. $this->behaviorDisplaySale = $behaviorDisplaySale;
  546. return $this;
  547. }
  548. //TODO move
  549. public function isPropertyNoveltyOnline(): ?bool
  550. {
  551. if ($this->getPropertyNoveltyExpirationDate()) {
  552. $now = new \DateTime();
  553. if ($now <= $this->getPropertyNoveltyExpirationDate()) {
  554. return true;
  555. }
  556. }
  557. return false;
  558. }
  559. public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
  560. {
  561. return $this->propertyNoveltyExpirationDate;
  562. }
  563. public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate): self
  564. {
  565. $this->propertyNoveltyExpirationDate = $propertyNoveltyExpirationDate;
  566. return $this;
  567. }
  568. public function getPropertyOrganicLabel(): ?string
  569. {
  570. return $this->propertyOrganicLabel;
  571. }
  572. public function setPropertyOrganicLabel(?string $propertyOrganicLabel): self
  573. {
  574. $this->propertyOrganicLabel = $propertyOrganicLabel;
  575. return $this;
  576. }
  577. public function getPropertyAllergens(): ?string
  578. {
  579. return $this->propertyAllergens;
  580. }
  581. public function setPropertyAllergens(?string $propertyAllergens): self
  582. {
  583. $this->propertyAllergens = $propertyAllergens;
  584. return $this;
  585. }
  586. public function getPropertyComposition(): ?string
  587. {
  588. return $this->propertyComposition;
  589. }
  590. public function setPropertyComposition(?string $propertyComposition): self
  591. {
  592. $this->propertyComposition = $propertyComposition;
  593. return $this;
  594. }
  595. public function getPropertyFragrances(): ?string
  596. {
  597. return $this->propertyFragrances;
  598. }
  599. public function setPropertyFragrances(?string $propertyFragrances): self
  600. {
  601. $this->propertyFragrances = $propertyFragrances;
  602. return $this;
  603. }
  604. //TODO move
  605. public function countProperties(): bool
  606. {
  607. $count = 0;
  608. $count += (int)strlen($this->getPropertyOrganicLabel()) > 0;
  609. $count += (int)strlen($this->getPropertyWeight()) > 0;
  610. $count += (int)strlen($this->getPropertyFragrances()) > 0;
  611. $count += (int)strlen($this->getPropertyComposition()) > 0;
  612. $count += (int)strlen($this->getPropertyAllergens()) > 0;
  613. $count += (int)strlen($this->getPropertyAlcoholLevel()) > 0;
  614. $count += (int)strlen($this->getPropertyCharacteristics()) > 0;
  615. $count += (int)strlen($this->getPropertyFeature()) > 0;
  616. $count += (int)strlen($this->getPropertyPackaging()) > 0;
  617. $count += (int)strlen($this->getPropertyQuantity()) > 0;
  618. $count += (int)strlen($this->getPropertyVariety()) > 0;
  619. $count += (int)($this->getPropertyExpirationDate() != null);
  620. return $count;
  621. }
  622. public function getBehaviorExpirationDate(): ?string
  623. {
  624. return $this->behaviorExpirationDate;
  625. }
  626. public function setBehaviorExpirationDate(?string $behaviorExpirationDate): self
  627. {
  628. $this->behaviorExpirationDate = $behaviorExpirationDate;
  629. return $this;
  630. }
  631. public function getTypeExpirationDate(): ?string
  632. {
  633. return $this->typeExpirationDate;
  634. }
  635. public function setTypeExpirationDate(?string $typeExpirationDate): self
  636. {
  637. $this->typeExpirationDate = $typeExpirationDate;
  638. return $this;
  639. }
  640. public function getPropertyWeight(): ?string
  641. {
  642. return $this->propertyWeight;
  643. }
  644. public function setPropertyWeight(?string $propertyWeight): self
  645. {
  646. $this->propertyWeight = $propertyWeight;
  647. return $this;
  648. }
  649. public function getPropertyQuantity(): ?string
  650. {
  651. return $this->propertyQuantity;
  652. }
  653. public function setPropertyQuantity(?string $propertyQuantity): self
  654. {
  655. $this->propertyQuantity = $propertyQuantity;
  656. return $this;
  657. }
  658. public function getPropertyVariety(): ?string
  659. {
  660. return $this->propertyVariety;
  661. }
  662. public function setPropertyVariety(?string $propertyVariety): self
  663. {
  664. $this->propertyVariety = $propertyVariety;
  665. return $this;
  666. }
  667. public function getPropertyFeature(): ?string
  668. {
  669. return $this->propertyFeature;
  670. }
  671. public function setPropertyFeature(?string $propertyFeature): self
  672. {
  673. $this->propertyFeature = $propertyFeature;
  674. return $this;
  675. }
  676. public function getPropertyAlcoholLevel(): ?string
  677. {
  678. return $this->propertyAlcoholLevel;
  679. }
  680. public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
  681. {
  682. $this->propertyAlcoholLevel = $propertyAlcoholLevel;
  683. return $this;
  684. }
  685. public function getPropertyPackaging(): ?string
  686. {
  687. return $this->propertyPackaging;
  688. }
  689. public function setPropertyPackaging(?string $propertyPackaging): self
  690. {
  691. $this->propertyPackaging = $propertyPackaging;
  692. return $this;
  693. }
  694. public function getPropertyCharacteristics(): ?string
  695. {
  696. return $this->propertyCharacteristics;
  697. }
  698. public function setPropertyCharacteristics(?string $propertyCharacteristics): self
  699. {
  700. $this->propertyCharacteristics = $propertyCharacteristics;
  701. return $this;
  702. }
  703. public function getBehaviorAddToCart(): ?string
  704. {
  705. return $this->behaviorAddToCart;
  706. }
  707. public function setBehaviorAddToCart(?string $behaviorAddToCart): self
  708. {
  709. $this->behaviorAddToCart = $behaviorAddToCart;
  710. return $this;
  711. }
  712. public function getBehaviorPrice(): ?string
  713. {
  714. return $this->behaviorPrice;
  715. }
  716. //TODO move
  717. public function getBehaviorPriceInherited()
  718. {
  719. return $this->getBehaviorPrice();
  720. }
  721. public function setBehaviorPrice(?string $behaviorPrice): self
  722. {
  723. $this->behaviorPrice = $behaviorPrice;
  724. return $this;
  725. }
  726. //TODO move
  727. public function hasProductsWithVariousWeight()
  728. {
  729. if ($this->getActiveProducts()) {
  730. $arrayCountProducts = [];
  731. $products = $this->getProductsOnline();
  732. foreach ($products as $product) {
  733. $titleProduct = $product->getTitleInherited();
  734. if (!isset($arrayCountProducts[$titleProduct])) {
  735. $arrayCountProducts[$titleProduct] = [];
  736. }
  737. if (!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
  738. $arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited();
  739. }
  740. if (count($arrayCountProducts[$titleProduct]) > 1) {
  741. return true;
  742. }
  743. }
  744. }
  745. return false;
  746. }
  747. //TODO move
  748. public function getProductsGroupByTitle()
  749. {
  750. $arrayProductsGroupByTitle = [];
  751. $products = $this->getProductsOnline();
  752. foreach ($products as $product) {
  753. if ($product->getStatus() == 1) {
  754. $titleProduct = $product->getTitleInherited();
  755. if (!isset($arrayProductsGroupByTitle[$titleProduct])) {
  756. $arrayProductsGroupByTitle[$titleProduct] = [];
  757. }
  758. $arrayProductsGroupByTitle[$titleProduct][] = $product;
  759. }
  760. }
  761. return $arrayProductsGroupByTitle;
  762. }
  763. //TODO move
  764. public function getOriginProduct()
  765. {
  766. $products = $this->getProducts();
  767. foreach ($products as $product) {
  768. if ($product->getOriginProduct()) {
  769. return $product;
  770. }
  771. }
  772. }
  773. //TODO move
  774. public function getOriginProductOnline()
  775. {
  776. $originProduct = $this->getOriginProduct();
  777. if ($originProduct->getStatus() == 1) {
  778. return $originProduct;
  779. } else {
  780. return false;
  781. }
  782. }
  783. //TODO move
  784. public function hasOneProductOnline()
  785. {
  786. if (($this->getActiveProducts() && count($this->getProductsOnline()) > 0)
  787. || (!$this->getActiveProducts() && $this->getOriginProduct())) {
  788. return true;
  789. }
  790. return false;
  791. }
  792. public function getSaleStatus(): ?bool
  793. {
  794. return $this->saleStatus;
  795. }
  796. public function setSaleStatus(bool $saleStatus): self
  797. {
  798. $this->saleStatus = $saleStatus;
  799. return $this;
  800. }
  801. //TODO move
  802. public function getFieldBuyingPrice()
  803. {
  804. if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
  805. return 'buyingPrice';
  806. } elseif ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
  807. return 'buyingPriceByRefUnit';
  808. }
  809. }
  810. //TODO move
  811. public function getFieldPrice()
  812. {
  813. if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
  814. return 'price';
  815. } elseif ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
  816. return 'priceByRefUnit';
  817. }
  818. }
  819. public function getImage(): ?FileInterface
  820. {
  821. return $this->image;
  822. }
  823. public function setImage(?FileInterface $image): self
  824. {
  825. $this->image = $image;
  826. return $this;
  827. }
  828. }