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.

911 lines
26KB

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