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.

55 lines
1.4KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\Product;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  5. use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
  6. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  7. class ProductSolver
  8. {
  9. public function isProductSaleStatusOn(ProductInterface $product)
  10. {
  11. if ($product->getProductFamily()->getSaleStatus() != 1) {
  12. return false;
  13. }
  14. $allCategoriesSalesOff = true;
  15. $unavailableSpecificDay = false;
  16. foreach ($product->getProductFamily()->getProductCategories() as $category) {
  17. if ($category->getParent()) {
  18. if ($category->getSaleStatus() && $category->getParent()->getSaleStatus()) {
  19. $allCategoriesSalesOff = false;
  20. }
  21. } else {
  22. if ($category->getSaleStatus()) {
  23. $allCategoriesSalesOff = false;
  24. }
  25. }
  26. // specific day
  27. // @TODO : spécifique pdl ?
  28. $displaySpecificDay = $category->getDisplaySpecificDay();
  29. if ($displaySpecificDay && $displaySpecificDay != date('N')) {
  30. $unavailableSpecificDay = true;
  31. }
  32. }
  33. if ($allCategoriesSalesOff) {
  34. return false;
  35. }
  36. if ($unavailableSpecificDay) {
  37. return false;
  38. }
  39. return true;
  40. }
  41. }