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.

1055 satır
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, 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. //TODO move
  287. public function getAvailableQuantityInherited()
  288. {
  289. $availableQuantity = 0;
  290. switch ($this->getBehaviorCountStock()) {
  291. case self::BEHAVIOR_COUNT_STOCK_BY_MEASURE :
  292. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :
  293. $availableQuantity = $this->getAvailableQuantity();
  294. break;
  295. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
  296. foreach ($this->getProductsOnline() as $product) {
  297. $availableQuantity += $product->getAvailableQuantityInherited();
  298. }
  299. break;
  300. case self::BEHAVIOR_COUNT_STOCK_UNLIMITED :
  301. $availableQuantity = false;
  302. break;
  303. }
  304. return $availableQuantity;
  305. }
  306. //TODO move
  307. public function getTaxRateInherited()
  308. {
  309. if ($this->getTaxRate()) {
  310. return $this->getTaxRate();
  311. } else {
  312. return $this->getSection()->getMerchant()->getTaxRate();
  313. }
  314. }
  315. public function getActiveProducts(): ?bool
  316. {
  317. return $this->activeProducts;
  318. }
  319. public function setActiveProducts(bool $activeProducts): self
  320. {
  321. $this->activeProducts = $activeProducts;
  322. return $this;
  323. }
  324. public function getProductsQuantityAsTitle(): ?bool
  325. {
  326. return $this->productsQuantityAsTitle;
  327. }
  328. public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle): self
  329. {
  330. $this->productsQuantityAsTitle = $productsQuantityAsTitle;
  331. return $this;
  332. }
  333. public function getProductsType(): ?string
  334. {
  335. return $this->productsType;
  336. }
  337. public function setProductsType(?string $productsType): self
  338. {
  339. $this->productsType = $productsType;
  340. return $this;
  341. }
  342. public function getQuantityLabel(): ?string
  343. {
  344. return $this->quantityLabel;
  345. }
  346. public function setQuantityLabel(?string $quantityLabel): self
  347. {
  348. $this->quantityLabel = $quantityLabel;
  349. return $this;
  350. }
  351. /**
  352. * @return Collection|ProductInterface[]
  353. */
  354. public function getProducts(): Collection
  355. {
  356. return $this->products;
  357. }
  358. //TODO move
  359. public function getProductsOnline(): Collection
  360. {
  361. $products = $this->getProducts();
  362. $productsOnlineArray = new ArrayCollection();
  363. foreach ($products as $product) {
  364. if ($product->getStatus() == 1 && $product->getOriginProduct() != true) {
  365. $productsOnlineArray[] = $product;
  366. }
  367. }
  368. return $productsOnlineArray;
  369. }
  370. public function addProduct(ProductInterface $product): self
  371. {
  372. if (!$this->products->contains($product)) {
  373. $this->products[] = $product;
  374. $product->setProductFamily($this);
  375. }
  376. return $this;
  377. }
  378. public function removeProduct(ProductInterface $product): self
  379. {
  380. if ($this->products->contains($product)) {
  381. $this->products->removeElement($product);
  382. // set the owning side to null (unless already changed)
  383. if ($product->getProductFamily() === $this) {
  384. $product->setProductFamily(null);
  385. }
  386. }
  387. return $this;
  388. }
  389. public function getReductionCatalog(): ?ReductionCatalogInterface
  390. {
  391. return $this->reductionCatalog;
  392. }
  393. //TODO move
  394. public function getReductionCatalogInherited(): ?ReductionCatalogInterface
  395. {
  396. return $this->getReductionCatalog();
  397. }
  398. public function setReductionCatalog(?ReductionCatalogInterface $reductionCatalog): self
  399. {
  400. $this->reductionCatalog = $reductionCatalog;
  401. return $this;
  402. }
  403. /**
  404. * @return Collection|ProductCategoryInterface[]
  405. */
  406. public function getProductCategories(): Collection
  407. {
  408. return $this->productCategories;
  409. }
  410. public function initProductCategories()
  411. {
  412. $this->productCategories = new ArrayCollection();
  413. }
  414. public function addProductCategory(ProductCategoryInterface $productCategory): self
  415. {
  416. if (!$this->productCategories->contains($productCategory)) {
  417. $this->productCategories[] = $productCategory;
  418. }
  419. return $this;
  420. }
  421. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  422. {
  423. if ($this->productCategories->contains($productCategory)) {
  424. $this->productCategories->removeElement($productCategory);
  425. }
  426. return $this;
  427. }
  428. //TODO move
  429. public function getProductCategoryParent()
  430. {
  431. $productCategories = $this->getProductCategories();
  432. if (count($productCategories) > 0) {
  433. return $productCategories[0]->getParent();
  434. }
  435. return false;
  436. }
  437. //TODO move
  438. public function getProductCategoryChild()
  439. {
  440. $productCategories = $this->getProductCategories();
  441. foreach ($productCategories as $productCategory) {
  442. if ($productCategory->getParent()) {
  443. return $productCategory;
  444. }
  445. }
  446. return false;
  447. }
  448. public function getSubtitle(): ?string
  449. {
  450. return $this->subtitle;
  451. }
  452. public function setSubtitle(?string $subtitle): self
  453. {
  454. $this->subtitle = $subtitle;
  455. return $this;
  456. }
  457. public function getWarningMessage(): ?string
  458. {
  459. return $this->warningMessage;
  460. }
  461. public function setWarningMessage(?string $warningMessage): self
  462. {
  463. $this->warningMessage = $warningMessage;
  464. return $this;
  465. }
  466. public function getWarningMessageType(): ?string
  467. {
  468. return $this->warningMessageType;
  469. }
  470. public function setWarningMessageType(?string $warningMessageType): self
  471. {
  472. $this->warningMessageType = $warningMessageType;
  473. return $this;
  474. }
  475. public function getNote(): ?string
  476. {
  477. return $this->note;
  478. }
  479. public function setNote(?string $note): self
  480. {
  481. $this->note = $note;
  482. return $this;
  483. }
  484. public function getBehaviorOutOfStock(): ?string
  485. {
  486. return $this->behaviorOutOfStock;
  487. }
  488. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  489. {
  490. $this->behaviorOutOfStock = $behaviorOutOfStock;
  491. return $this;
  492. }
  493. public function getBehaviorCountStock(): ?string
  494. {
  495. return $this->behaviorCountStock;
  496. }
  497. public function setBehaviorCountStock(string $behaviorCountStock): self
  498. {
  499. $this->behaviorCountStock = $behaviorCountStock;
  500. return $this;
  501. }
  502. public function getExportTitle(): ?string
  503. {
  504. return $this->exportTitle;
  505. }
  506. public function setExportTitle(?string $exportTitle): self
  507. {
  508. $this->exportTitle = $exportTitle;
  509. return $this;
  510. }
  511. public function getExportNote(): ?string
  512. {
  513. return $this->exportNote;
  514. }
  515. public function setExportNote(?string $exportNote): self
  516. {
  517. $this->exportNote = $exportNote;
  518. return $this;
  519. }
  520. public function getBehaviorStockCycle(): ?string
  521. {
  522. return $this->behaviorStockCycle;
  523. }
  524. public function setBehaviorStockCycle(string $behaviorStockCycle): self
  525. {
  526. $this->behaviorStockCycle = $behaviorStockCycle;
  527. return $this;
  528. }
  529. public function getAvailabilityRenewedThisWeek(): ?bool
  530. {
  531. return $this->availabilityRenewedThisWeek;
  532. }
  533. public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self
  534. {
  535. $this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek;
  536. return $this;
  537. }
  538. public function getBehaviorDisplaySale(): ?string
  539. {
  540. return $this->behaviorDisplaySale;
  541. }
  542. public function setBehaviorDisplaySale(string $behaviorDisplaySale): self
  543. {
  544. $this->behaviorDisplaySale = $behaviorDisplaySale;
  545. return $this;
  546. }
  547. //TODO move
  548. public function isPropertyNoveltyOnline(): ?bool
  549. {
  550. if ($this->getPropertyNoveltyExpirationDate()) {
  551. $now = new \DateTime();
  552. if ($now <= $this->getPropertyNoveltyExpirationDate()) {
  553. return true;
  554. }
  555. }
  556. return false;
  557. }
  558. public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
  559. {
  560. return $this->propertyNoveltyExpirationDate;
  561. }
  562. public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate): self
  563. {
  564. $this->propertyNoveltyExpirationDate = $propertyNoveltyExpirationDate;
  565. return $this;
  566. }
  567. public function getPropertyOrganicLabel(): ?string
  568. {
  569. return $this->propertyOrganicLabel;
  570. }
  571. public function setPropertyOrganicLabel(?string $propertyOrganicLabel): self
  572. {
  573. $this->propertyOrganicLabel = $propertyOrganicLabel;
  574. return $this;
  575. }
  576. public function getPropertyAllergens(): ?string
  577. {
  578. return $this->propertyAllergens;
  579. }
  580. public function setPropertyAllergens(?string $propertyAllergens): self
  581. {
  582. $this->propertyAllergens = $propertyAllergens;
  583. return $this;
  584. }
  585. public function getPropertyComposition(): ?string
  586. {
  587. return $this->propertyComposition;
  588. }
  589. public function setPropertyComposition(?string $propertyComposition): self
  590. {
  591. $this->propertyComposition = $propertyComposition;
  592. return $this;
  593. }
  594. public function getPropertyFragrances(): ?string
  595. {
  596. return $this->propertyFragrances;
  597. }
  598. public function setPropertyFragrances(?string $propertyFragrances): self
  599. {
  600. $this->propertyFragrances = $propertyFragrances;
  601. return $this;
  602. }
  603. //TODO move
  604. public function countProperties(): bool
  605. {
  606. $count = 0;
  607. $count += (int)strlen($this->getPropertyOrganicLabel()) > 0;
  608. $count += (int)strlen($this->getPropertyWeight()) > 0;
  609. $count += (int)strlen($this->getPropertyFragrances()) > 0;
  610. $count += (int)strlen($this->getPropertyComposition()) > 0;
  611. $count += (int)strlen($this->getPropertyAllergens()) > 0;
  612. $count += (int)strlen($this->getPropertyAlcoholLevel()) > 0;
  613. $count += (int)strlen($this->getPropertyCharacteristics()) > 0;
  614. $count += (int)strlen($this->getPropertyFeature()) > 0;
  615. $count += (int)strlen($this->getPropertyPackaging()) > 0;
  616. $count += (int)strlen($this->getPropertyQuantity()) > 0;
  617. $count += (int)strlen($this->getPropertyVariety()) > 0;
  618. $count += (int)($this->getPropertyExpirationDate() != null);
  619. return $count;
  620. }
  621. public function getBehaviorExpirationDate(): ?string
  622. {
  623. return $this->behaviorExpirationDate;
  624. }
  625. public function setBehaviorExpirationDate(?string $behaviorExpirationDate): self
  626. {
  627. $this->behaviorExpirationDate = $behaviorExpirationDate;
  628. return $this;
  629. }
  630. public function getTypeExpirationDate(): ?string
  631. {
  632. return $this->typeExpirationDate;
  633. }
  634. public function setTypeExpirationDate(?string $typeExpirationDate): self
  635. {
  636. $this->typeExpirationDate = $typeExpirationDate;
  637. return $this;
  638. }
  639. public function getPropertyWeight(): ?string
  640. {
  641. return $this->propertyWeight;
  642. }
  643. public function setPropertyWeight(?string $propertyWeight): self
  644. {
  645. $this->propertyWeight = $propertyWeight;
  646. return $this;
  647. }
  648. public function getPropertyQuantity(): ?string
  649. {
  650. return $this->propertyQuantity;
  651. }
  652. public function setPropertyQuantity(?string $propertyQuantity): self
  653. {
  654. $this->propertyQuantity = $propertyQuantity;
  655. return $this;
  656. }
  657. public function getPropertyVariety(): ?string
  658. {
  659. return $this->propertyVariety;
  660. }
  661. public function setPropertyVariety(?string $propertyVariety): self
  662. {
  663. $this->propertyVariety = $propertyVariety;
  664. return $this;
  665. }
  666. public function getPropertyFeature(): ?string
  667. {
  668. return $this->propertyFeature;
  669. }
  670. public function setPropertyFeature(?string $propertyFeature): self
  671. {
  672. $this->propertyFeature = $propertyFeature;
  673. return $this;
  674. }
  675. public function getPropertyAlcoholLevel(): ?string
  676. {
  677. return $this->propertyAlcoholLevel;
  678. }
  679. public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
  680. {
  681. $this->propertyAlcoholLevel = $propertyAlcoholLevel;
  682. return $this;
  683. }
  684. public function getPropertyPackaging(): ?string
  685. {
  686. return $this->propertyPackaging;
  687. }
  688. public function setPropertyPackaging(?string $propertyPackaging): self
  689. {
  690. $this->propertyPackaging = $propertyPackaging;
  691. return $this;
  692. }
  693. public function getPropertyCharacteristics(): ?string
  694. {
  695. return $this->propertyCharacteristics;
  696. }
  697. public function setPropertyCharacteristics(?string $propertyCharacteristics): self
  698. {
  699. $this->propertyCharacteristics = $propertyCharacteristics;
  700. return $this;
  701. }
  702. public function getBehaviorAddToCart(): ?string
  703. {
  704. return $this->behaviorAddToCart;
  705. }
  706. public function setBehaviorAddToCart(?string $behaviorAddToCart): self
  707. {
  708. $this->behaviorAddToCart = $behaviorAddToCart;
  709. return $this;
  710. }
  711. public function getBehaviorPrice(): ?string
  712. {
  713. return $this->behaviorPrice;
  714. }
  715. //TODO move
  716. public function getBehaviorPriceInherited()
  717. {
  718. return $this->getBehaviorPrice();
  719. }
  720. public function setBehaviorPrice(?string $behaviorPrice): self
  721. {
  722. $this->behaviorPrice = $behaviorPrice;
  723. return $this;
  724. }
  725. //TODO move
  726. public function hasProductsWithVariousWeight()
  727. {
  728. if ($this->getActiveProducts()) {
  729. $arrayCountProducts = [];
  730. $products = $this->getProductsOnline();
  731. foreach ($products as $product) {
  732. $titleProduct = $product->getTitleInherited();
  733. if (!isset($arrayCountProducts[$titleProduct])) {
  734. $arrayCountProducts[$titleProduct] = [];
  735. }
  736. if (!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
  737. $arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited();
  738. }
  739. if (count($arrayCountProducts[$titleProduct]) > 1) {
  740. return true;
  741. }
  742. }
  743. }
  744. return false;
  745. }
  746. //TODO move
  747. public function getProductsGroupByTitle()
  748. {
  749. $arrayProductsGroupByTitle = [];
  750. $products = $this->getProductsOnline();
  751. foreach ($products as $product) {
  752. if ($product->getStatus() == 1) {
  753. $titleProduct = $product->getTitleInherited();
  754. if (!isset($arrayProductsGroupByTitle[$titleProduct])) {
  755. $arrayProductsGroupByTitle[$titleProduct] = [];
  756. }
  757. $arrayProductsGroupByTitle[$titleProduct][] = $product;
  758. }
  759. }
  760. return $arrayProductsGroupByTitle;
  761. }
  762. //TODO move
  763. public function getOriginProduct()
  764. {
  765. $products = $this->getProducts();
  766. foreach ($products as $product) {
  767. if ($product->getOriginProduct()) {
  768. return $product;
  769. }
  770. }
  771. }
  772. //TODO move
  773. public function getOriginProductOnline()
  774. {
  775. $originProduct = $this->getOriginProduct();
  776. if ($originProduct->getStatus() == 1) {
  777. return $originProduct;
  778. } else {
  779. return false;
  780. }
  781. }
  782. //TODO move
  783. public function hasOneProductOnline()
  784. {
  785. if (($this->getActiveProducts() && count($this->getProductsOnline()) > 0)
  786. || (!$this->getActiveProducts() && $this->getOriginProduct())) {
  787. return true;
  788. }
  789. return false;
  790. }
  791. public function getSaleStatus(): ?bool
  792. {
  793. return $this->saleStatus;
  794. }
  795. public function setSaleStatus(bool $saleStatus): self
  796. {
  797. $this->saleStatus = $saleStatus;
  798. return $this;
  799. }
  800. //TODO move
  801. public function getFieldBuyingPrice()
  802. {
  803. if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
  804. return 'buyingPrice';
  805. } elseif ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
  806. return 'buyingPriceByRefUnit';
  807. }
  808. }
  809. //TODO move
  810. public function getFieldPrice()
  811. {
  812. if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
  813. return 'price';
  814. } elseif ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
  815. return 'priceByRefUnit';
  816. }
  817. }
  818. public function getImage(): ?FileInterface
  819. {
  820. return $this->image;
  821. }
  822. public function setImage(?FileInterface $image): self
  823. {
  824. $this->image = $image;
  825. return $this;
  826. }
  827. }