Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

915 lines
23KB

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