選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ProductFamilyModel.php 24KB

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