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.

ProductCategorySolver.php 1.8KB

3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. }