Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ProductFamily.php 24KB

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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. public function __construct()
  177. {
  178. $this->productCategories = new ArrayCollection();
  179. $this->products = new ArrayCollection();
  180. }
  181. public function __toString()
  182. {
  183. return $this->getTitle();
  184. }
  185. public function getAvailableQuantityInherited()
  186. {
  187. $availableQuantity = 0 ;
  188. switch ($this->getBehaviorCountStock()) {
  189. case self::BEHAVIOR_COUNT_STOCK_BY_MEASURE :
  190. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :
  191. $availableQuantity = $this->getAvailableQuantity() ;
  192. break;
  193. case self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
  194. foreach($this->getProductsOnline() as $product) {
  195. $availableQuantity += $product->getAvailableQuantityInherited() ;
  196. }
  197. break ;
  198. case self::BEHAVIOR_COUNT_STOCK_UNLIMITED :
  199. $availableQuantity = false;
  200. break;
  201. }
  202. return $availableQuantity ;
  203. }
  204. public function getTaxRateInherited()
  205. {
  206. if ($this->getTaxRate()) {
  207. return $this->getTaxRate();
  208. } else {
  209. return $this->getMerchant()->getTaxRate();
  210. }
  211. }
  212. public function getMerchant(): ?Merchant
  213. {
  214. return $this->merchant;
  215. }
  216. public function setMerchant(?Merchant $merchant): self
  217. {
  218. $this->merchant = $merchant;
  219. return $this;
  220. }
  221. public function getActiveProducts(): ?bool
  222. {
  223. return $this->activeProducts;
  224. }
  225. public function setActiveProducts(bool $activeProducts): self
  226. {
  227. $this->activeProducts = $activeProducts;
  228. return $this;
  229. }
  230. public function getProductsQuantityAsTitle(): ?bool
  231. {
  232. return $this->productsQuantityAsTitle;
  233. }
  234. public function setProductsQuantityAsTitle(bool $productsQuantityAsTitle): self
  235. {
  236. $this->productsQuantityAsTitle = $productsQuantityAsTitle;
  237. return $this;
  238. }
  239. public function getProductsType(): ?string
  240. {
  241. return $this->productsType;
  242. }
  243. public function setProductsType(?string $productsType): self
  244. {
  245. $this->productsType = $productsType;
  246. return $this;
  247. }
  248. public function getQuantityLabel(): ?string
  249. {
  250. return $this->quantityLabel;
  251. }
  252. public function setQuantityLabel(?string $quantityLabel): self
  253. {
  254. $this->quantityLabel = $quantityLabel;
  255. return $this;
  256. }
  257. /**
  258. * @return Collection|ProductInterface[]
  259. */
  260. public function getProducts(): Collection
  261. {
  262. return $this->products;
  263. }
  264. public function getProductsOnline(): Collection
  265. {
  266. $products = $this->getProducts() ;
  267. $productsOnlineArray = new ArrayCollection() ;
  268. foreach($products as $product) {
  269. if($product->getStatus() == 1 && $product->getOriginProduct() !=true) {
  270. $productsOnlineArray[] = $product ;
  271. }
  272. }
  273. return $productsOnlineArray ;
  274. }
  275. public function addProduct(ProductInterface $product): self
  276. {
  277. if (!$this->products->contains($product)) {
  278. $this->products[] = $product;
  279. $product->setProductFamily($this);
  280. }
  281. return $this;
  282. }
  283. public function removeProduct(ProductInterface $product): self
  284. {
  285. if ($this->products->contains($product)) {
  286. $this->products->removeElement($product);
  287. // set the owning side to null (unless already changed)
  288. if ($product->getProductFamily() === $this) {
  289. $product->setProductFamily(null);
  290. }
  291. }
  292. return $this;
  293. }
  294. public function getReductionCatalog(): ?ReductionCatalog
  295. {
  296. return $this->reductionCatalog;
  297. }
  298. public function getReductionCatalogInherited(): ?ReductionCatalog
  299. {
  300. return $this->getReductionCatalog() ;
  301. }
  302. public function setReductionCatalog(?ReductionCatalog $reductionCatalog): self
  303. {
  304. $this->reductionCatalog = $reductionCatalog;
  305. return $this;
  306. }
  307. /**
  308. * @return Collection|ProductCategory[]
  309. */
  310. public function getProductCategories(): Collection
  311. {
  312. return $this->productCategories;
  313. }
  314. public function initProductCategories()
  315. {
  316. $this->productCategories = new ArrayCollection();
  317. }
  318. public function addProductCategory(ProductCategory $productCategory): self
  319. {
  320. if (!$this->productCategories->contains($productCategory)) {
  321. $this->productCategories[] = $productCategory;
  322. }
  323. return $this;
  324. }
  325. public function removeProductCategory(ProductCategory $productCategory): self
  326. {
  327. if ($this->productCategories->contains($productCategory)) {
  328. $this->productCategories->removeElement($productCategory);
  329. }
  330. return $this;
  331. }
  332. public function getProductCategoryParent()
  333. {
  334. $productCategories = $this->getProductCategories();
  335. if (count($productCategories) > 0) {
  336. return $productCategories[0]->getParent();
  337. }
  338. return false;
  339. }
  340. public function getProductCategoryChild()
  341. {
  342. $productCategories = $this->getProductCategories();
  343. foreach ($productCategories as $productCategory) {
  344. if ($productCategory->getParent()) {
  345. return $productCategory;
  346. }
  347. }
  348. return false;
  349. }
  350. public function getSupplierTaxRate(): ?TaxRate
  351. {
  352. return $this->supplierTaxRate;
  353. }
  354. public function setSupplierTaxRate(?TaxRate $supplierTaxRate): self
  355. {
  356. $this->supplierTaxRate = $supplierTaxRate;
  357. return $this;
  358. }
  359. public function getSubtitle(): ?string
  360. {
  361. return $this->subtitle;
  362. }
  363. public function setSubtitle(?string $subtitle): self
  364. {
  365. $this->subtitle = $subtitle;
  366. return $this;
  367. }
  368. public function getWarningMessage(): ?string
  369. {
  370. return $this->warningMessage;
  371. }
  372. public function setWarningMessage(?string $warningMessage): self
  373. {
  374. $this->warningMessage = $warningMessage;
  375. return $this;
  376. }
  377. public function getWarningMessageType(): ?string
  378. {
  379. return $this->warningMessageType;
  380. }
  381. public function setWarningMessageType(?string $warningMessageType): self
  382. {
  383. $this->warningMessageType = $warningMessageType;
  384. return $this;
  385. }
  386. public function getNote(): ?string
  387. {
  388. return $this->note;
  389. }
  390. public function setNote(?string $note): self
  391. {
  392. $this->note = $note;
  393. return $this;
  394. }
  395. public function getBehaviorOutOfStock(): ?string
  396. {
  397. return $this->behaviorOutOfStock;
  398. }
  399. public function setBehaviorOutOfStock(?string $behaviorOutOfStock): self
  400. {
  401. $this->behaviorOutOfStock = $behaviorOutOfStock;
  402. return $this;
  403. }
  404. public function getBehaviorCountStock(): ?string
  405. {
  406. return $this->behaviorCountStock;
  407. }
  408. public function setBehaviorCountStock(string $behaviorCountStock): self
  409. {
  410. $this->behaviorCountStock = $behaviorCountStock;
  411. return $this;
  412. }
  413. public function isPropertyNoveltyOnline(): ?bool
  414. {
  415. if ($this->getPropertyNoveltyExpirationDate()) {
  416. $now = new \DateTime();
  417. if ($now <= $this->getPropertyNoveltyExpirationDate()) {
  418. return true;
  419. }
  420. }
  421. return false;
  422. }
  423. public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
  424. {
  425. return $this->propertyNoveltyExpirationDate;
  426. }
  427. public function setPropertyNoveltyExpirationDate(?\DateTimeInterface $propertyNoveltyExpirationDate): self
  428. {
  429. $this->propertyNoveltyExpirationDate = $propertyNoveltyExpirationDate;
  430. return $this;
  431. }
  432. public function getPropertyOrganicLabel(): ?string
  433. {
  434. return $this->propertyOrganicLabel;
  435. }
  436. public function setPropertyOrganicLabel(?string $propertyOrganicLabel): self
  437. {
  438. $this->propertyOrganicLabel = $propertyOrganicLabel;
  439. return $this;
  440. }
  441. public function getPropertyAllergens(): ?string
  442. {
  443. return $this->propertyAllergens;
  444. }
  445. public function setPropertyAllergens(?string $propertyAllergens): self
  446. {
  447. $this->propertyAllergens = $propertyAllergens;
  448. return $this;
  449. }
  450. public function getPropertyComposition(): ?string
  451. {
  452. return $this->propertyComposition;
  453. }
  454. public function setPropertyComposition(?string $propertyComposition): self
  455. {
  456. $this->propertyComposition = $propertyComposition;
  457. return $this;
  458. }
  459. public function getPropertyFragrances(): ?string
  460. {
  461. return $this->propertyFragrances;
  462. }
  463. public function setPropertyFragrances(?string $propertyFragrances): self
  464. {
  465. $this->propertyFragrances = $propertyFragrances;
  466. return $this;
  467. }
  468. public function countProperties(): bool
  469. {
  470. $count = 0;
  471. $count += (int)strlen($this->getPropertyOrganicLabel()) > 0;
  472. $count += (int)strlen($this->getPropertyWeight()) > 0;
  473. $count += (int)strlen($this->getPropertyFragrances()) > 0;
  474. $count += (int)strlen($this->getPropertyComposition()) > 0;
  475. $count += (int)strlen($this->getPropertyAllergens()) > 0;
  476. $count += (int)strlen($this->getPropertyAlcoholLevel()) > 0;
  477. $count += (int)strlen($this->getPropertyCharacteristics()) > 0;
  478. $count += (int)strlen($this->getPropertyFeature()) > 0;
  479. $count += (int)strlen($this->getPropertyPackaging()) > 0;
  480. $count += (int)strlen($this->getPropertyQuantity()) > 0;
  481. $count += (int)strlen($this->getPropertyVariety()) > 0;
  482. $count += (int)($this->getPropertyExpirationDate() != null);
  483. return $count;
  484. }
  485. public function getBehaviorExpirationDate(): ?string
  486. {
  487. return $this->behaviorExpirationDate;
  488. }
  489. public function setBehaviorExpirationDate(?string $behaviorExpirationDate): self
  490. {
  491. $this->behaviorExpirationDate = $behaviorExpirationDate;
  492. return $this;
  493. }
  494. public function getTypeExpirationDate(): ?string
  495. {
  496. return $this->typeExpirationDate;
  497. }
  498. public function setTypeExpirationDate(?string $typeExpirationDate): self
  499. {
  500. $this->typeExpirationDate = $typeExpirationDate;
  501. return $this;
  502. }
  503. public function getPropertyWeight(): ?string
  504. {
  505. return $this->propertyWeight;
  506. }
  507. public function setPropertyWeight(?string $propertyWeight): self
  508. {
  509. $this->propertyWeight = $propertyWeight;
  510. return $this;
  511. }
  512. public function getPropertyQuantity(): ?string
  513. {
  514. return $this->propertyQuantity;
  515. }
  516. public function setPropertyQuantity(?string $propertyQuantity): self
  517. {
  518. $this->propertyQuantity = $propertyQuantity;
  519. return $this;
  520. }
  521. public function getPropertyVariety(): ?string
  522. {
  523. return $this->propertyVariety;
  524. }
  525. public function setPropertyVariety(?string $propertyVariety): self
  526. {
  527. $this->propertyVariety = $propertyVariety;
  528. return $this;
  529. }
  530. public function getPropertyFeature(): ?string
  531. {
  532. return $this->propertyFeature;
  533. }
  534. public function setPropertyFeature(?string $propertyFeature): self
  535. {
  536. $this->propertyFeature = $propertyFeature;
  537. return $this;
  538. }
  539. public function getPropertyAlcoholLevel(): ?string
  540. {
  541. return $this->propertyAlcoholLevel;
  542. }
  543. public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
  544. {
  545. $this->propertyAlcoholLevel = $propertyAlcoholLevel;
  546. return $this;
  547. }
  548. public function getPropertyPackaging(): ?string
  549. {
  550. return $this->propertyPackaging;
  551. }
  552. public function setPropertyPackaging(?string $propertyPackaging): self
  553. {
  554. $this->propertyPackaging = $propertyPackaging;
  555. return $this;
  556. }
  557. public function getPropertyCharacteristics(): ?string
  558. {
  559. return $this->propertyCharacteristics;
  560. }
  561. public function setPropertyCharacteristics(?string $propertyCharacteristics): self
  562. {
  563. $this->propertyCharacteristics = $propertyCharacteristics;
  564. return $this;
  565. }
  566. public function getBehaviorAddToCart(): ?string
  567. {
  568. return $this->behaviorAddToCart;
  569. }
  570. public function setBehaviorAddToCart(?string $behaviorAddToCart): self
  571. {
  572. $this->behaviorAddToCart = $behaviorAddToCart;
  573. return $this;
  574. }
  575. public function getBehaviorPrice(): ?string
  576. {
  577. return $this->behaviorPrice;
  578. }
  579. public function getBehaviorPriceInherited()
  580. {
  581. return $this->getBehaviorPrice() ;
  582. }
  583. public function setBehaviorPrice(?string $behaviorPrice): self
  584. {
  585. $this->behaviorPrice = $behaviorPrice;
  586. return $this;
  587. }
  588. public function hasProductsWithVariousWeight()
  589. {
  590. if ($this->getActiveProducts()) {
  591. $arrayCountProducts = [];
  592. $products = $this->getProductsOnline();
  593. foreach ($products as $product) {
  594. $titleProduct = $product->getTitleInherited();
  595. if (!isset($arrayCountProducts[$titleProduct])) {
  596. $arrayCountProducts[$titleProduct] = [];
  597. }
  598. if (!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
  599. $arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited();
  600. }
  601. if (count($arrayCountProducts[$titleProduct]) > 1) {
  602. return true;
  603. }
  604. }
  605. }
  606. return false;
  607. }
  608. public function getProductsGroupByTitle()
  609. {
  610. $arrayProductsGroupByTitle = [];
  611. $products = $this->getProductsOnline();
  612. foreach ($products as $product) {
  613. if($product->getStatus() == 1) {
  614. $titleProduct = $product->getTitleInherited();
  615. if (!isset($arrayProductsGroupByTitle[$titleProduct])) {
  616. $arrayProductsGroupByTitle[$titleProduct] = [];
  617. }
  618. $arrayProductsGroupByTitle[$titleProduct][] = $product;
  619. }
  620. }
  621. return $arrayProductsGroupByTitle;
  622. }
  623. public function getOriginProduct()
  624. {
  625. $products = $this->getProducts() ;
  626. foreach($products as $product) {
  627. if($product->getOriginProduct()) {
  628. return $product ;
  629. }
  630. }
  631. }
  632. public function getOriginProductOnline()
  633. {
  634. $originProduct = $this->getOriginProduct() ;
  635. if($originProduct->getStatus()==1){
  636. return $originProduct;
  637. }else{
  638. return false;
  639. }
  640. }
  641. public function hasOneProductOnline()
  642. {
  643. if( ($this->getActiveProducts() && count($this->getProductsOnline()) > 0)
  644. || (!$this->getActiveProducts() && $this->getOriginProduct())){
  645. return true ;
  646. }
  647. return false ;
  648. }
  649. }