Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

50 rindas
1.8KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Product;
  3. use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
  4. class ProductCategorySolver
  5. {
  6. protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver;
  7. public function __construct(ProductFamilySectionPropertySolver $productFamilySectionPropertySolver){
  8. $this->productFamilySectionPropertySolver = $productFamilySectionPropertySolver;
  9. }
  10. public function isOnline(ProductCategoryInterface $productCategory)
  11. {
  12. if ($productCategory->getParent()) {
  13. if ($productCategory->getStatus() && $productCategory->getParent()->getStatus()) {
  14. return true;
  15. }
  16. } elseif ($productCategory->getStatus()) {
  17. return true;
  18. }
  19. return false;
  20. }
  21. public function hasOnlineProductFamily(ProductCategoryInterface $productCategory){
  22. if($productCategory->getProductFamilies()) {
  23. foreach ($productCategory->getProductFamilies() as $productFamily) {
  24. $productFamilySectionProperty = $this->productFamilySectionPropertySolver->getProductFamilySectionProperty($productFamily, $productCategory->getSection());
  25. //vérifie que le produit est en ligne et qu'il est actif sur cette section
  26. if ($productFamily->getStatus() == 1 && $productFamilySectionProperty && $productFamilySectionProperty->getStatus() == 1) {
  27. return true;
  28. }
  29. }
  30. }
  31. foreach($productCategory->getChildrens() as $productCategoryChildren){
  32. if($this->hasOnlineProductFamily($productCategoryChildren) && $productCategoryChildren->getStatus()==1){
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. }