src/Service/Cart/Cart.php line 495

Open in your IDE?
  1. <?php
  2. namespace App\Service\Cart;
  3. use App\Env;
  4. use App\DTO\AppDTO;
  5. use App\DTO\CartDTO;
  6. use App\Entity\Prod;
  7. use App\Model\ProdColor;
  8. use App\Service\Auth\Auth;
  9. use App\ValueObject\Money;
  10. use App\Entity\CartUnsaved;
  11. use App\Entity\Cart as EntityCart;
  12. use App\Repository\CartRepository;
  13. use App\Repository\ProdRepository;
  14. use App\Service\Discount\NumDiscount;
  15. use App\Service\Discount\SumDiscount;
  16. use App\Service\Discount\UserDiscount;
  17. use Doctrine\ORM\EntityManagerInterface;
  18. use App\Repository\CartUnsavedRepository;
  19. use Symfony\Component\Security\Core\Security;
  20. use Symfony\Component\HttpFoundation\RequestStack;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23. class Cart
  24. {
  25.     protected EntityManagerInterface $em;
  26.     protected AppDTO $app;
  27.     protected Auth $Auth;
  28.     protected SessionInterface $Session;
  29.     protected ProdColor $prodColor;
  30.     protected RequestStack $rs;
  31.     protected $cart;
  32.     protected $prods_limited = [];
  33.     protected $order_id;
  34.     protected NumDiscount $NumDiscount;
  35.     protected SumDiscount $SumDiscount;
  36.     protected UserDiscount $UserDiscount;
  37.     //Repository
  38.     protected ProdRepository $Prods;
  39.     protected CartUnsavedRepository $CartUnsaved;
  40.     protected CartRepository $Carts;
  41.     public function __construct(EntityManagerInterface $emAppDTO $appAuth $AuthNumDiscount $NumDiscountSumDiscount $SumDiscountUserDiscount $UserDiscountProdColor $prodColorRequestStack $rsSecurity $security)
  42.     {
  43.         $this->em $em;
  44.         $this->app $app;
  45.         $this->Auth $Auth;
  46.         $this->Auth->setUser($security->getUser());
  47.         $this->prodColor $prodColor;
  48.         $this->rs $rs;
  49.         $this->Session $rs->getSession();
  50.         $this->Prods $this->em->getRepository(Prod::class);
  51.         $this->CartUnsaved $this->em->getRepository(CartUnsaved::class);
  52.         $this->Carts $this->em->getRepository(EntityCart::class);
  53.         $this->NumDiscount $NumDiscount;
  54.         $this->SumDiscount $SumDiscount;
  55.         $this->UserDiscount $UserDiscount;
  56.         $this->cart $this->Session->get('cart');
  57.         
  58.         if (empty($this->cart)) {
  59.             $this->cart = [];
  60.         }
  61.         if (empty($this->cart)) {
  62.             $this->load_session();
  63.         }
  64.         $this->recount();
  65.         $this->flush();
  66.     }
  67.     public function getCart(): array
  68.     {
  69.         $deleted 0;
  70.         foreach ($this->cart as $k => $v) {
  71.             $prod $this->Prods->find($v['id']);
  72.             if ($prod == null) {
  73.                 $deleted 1;
  74.                 unset ($this->cart[$k]);
  75.             }
  76.         }
  77.         if ($deleted) {
  78.             $this->save_session();
  79.             $this->flush();
  80.         }
  81.         return $this->cart;
  82.     }
  83.     public function isFreeDelivery(float $free_delivery_min): bool
  84.     {
  85.         $freedelivery false;
  86.         if ($this->getAmount() >= $free_delivery_min && !$this->Auth->isOpt()) {
  87.             $freedelivery true;
  88.         }
  89.         return $freedelivery;
  90.     }
  91.     public function getDeliveryIndicatorData(float $free_delivery_min): array
  92.     {
  93.         $percent round($this->getAmount()/$free_delivery_min*100);
  94.         $percent 100 $percent 100 null;
  95.         $remainder $free_delivery_min $this->getAmount();
  96.         $remainder $remainder null;
  97.         $data = [
  98.             'freedelivery' => $this->isFreeDelivery($free_delivery_min),
  99.             'freedelivery_min' => $free_delivery_min,
  100.             'amount' => $this->getAmount(),
  101.             'remainder' => round($remainderEnv::price_precission()),
  102.             'percent' => $percent,
  103.         ];
  104.         return $data;
  105.     }
  106.     public function getFromOrder(int $order_id): array
  107.     {
  108.         $Prods $this->em->getRepository(Prod::class);
  109.         $cart $this->loadFromOrder2($order_id);
  110.         // $cart = $this->getCart();
  111.         if (empty($cart)) {
  112.             return [];
  113.         }
  114.         
  115.         foreach ($cart as $k => $v) {
  116.             $cart[$k]['prod'] = $Prods->find($v['id']);
  117.         }
  118.         
  119.         return $cart;
  120.     }
  121.     public function loadFromOrder(int $order_id)
  122.     {
  123.         $this->order_id $order_id;
  124.         /** @var \App\Entity\Cart[] $prods */
  125.         $prods $this->em->createQuery("SELECT c FROM App\Entity\Cart c WHERE c.order_id = ".$order_id)->getResult();
  126.                 
  127.         foreach($prods as $prod) {
  128.             $this->cart[$this->getCartId($prod->getProd()->getId(), 0)] = [
  129.                 'cid' => $prod->getId(),
  130.                 'id' => $prod->getProd()->getId(),
  131.                 'var' => $prod->getVar(),
  132.                 'num' => $prod->getNum(),
  133.                 'baseprice' => (new Money($prod->getPrice()))->getAmount(),
  134.                 'price' => 0,
  135.                 'skidka' => $prod->getSkidka(),
  136.                 'numdiscount' => $prod->getNumdiscount(),
  137.                 'userdiscount' => $prod->getUserdiscount(),
  138.             ];
  139.         }
  140.         $this->flush();
  141.     }
  142.     public function loadFromOrder2(int $order_id)
  143.     {
  144.         $cart = [];
  145.         $this->order_id $order_id;
  146.         /** @var \App\Entity\Cart[] $prods */
  147.         $prods $this->em->createQuery("SELECT c FROM App\Entity\Cart c WHERE c.order_id = ".$order_id)->getResult();
  148.                 
  149.         foreach($prods as $prod) {
  150.             if ($prod->getProd() == null) {
  151.                 continue;
  152.             }
  153.             $cart[$this->getCartId($prod->getProd()->getId(), 0)] = [
  154.                 'cid' => $prod->getId(),
  155.                 'id' => $prod->getProd()->getId(),
  156.                 'var' => $prod->getVar(),
  157.                 'num' => $prod->getNum(),
  158.                 'baseprice' => (new Money($prod->getPrice()))->getAmount(),
  159.                 'price' => (new Money($prod->getPrice()))->getAmount(),
  160.                 'skidka' => $prod->getSkidka(),
  161.                 'numdiscount' => $prod->getNumdiscount(),
  162.                 'userdiscount' => $prod->getUserdiscount(),
  163.             ];                       
  164.         }
  165.         $cart $this->recount($cart);
  166.         return $cart;
  167.     }
  168.     public function getCartId(int $prod_idint $var 0, array $chars = [], int $user_id 0) {
  169.         $id $prod_id."_".$var;
  170.             
  171.         if (!empty($chars)) {
  172.             ksort($chars);
  173.             $id .= "_".json_encode($chars);                
  174.         }
  175.             
  176.         if ($user_id) {
  177.             $id .= "_".$user_id;
  178.         }
  179.             
  180.         return md5($id);
  181.     }
  182.     public function addItem($id 0$var 0$num 1$price 0$skidka 0$numdiscount = [], $weight 0){
  183.         $cart_id $this->getCartId($id$var);
  184.             
  185.         if(isset($this->cart[$cart_id])){
  186.             $this->cart[$cart_id]['num'] += $num;
  187.             if($this->cart[$cart_id]['skidka'] == 0){
  188.                 $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  189.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  190.             }else{
  191.                 $this->cart[$cart_id]['numdiscount'] = 0;
  192.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  193.             }
  194.         }else{
  195.             $this->cart array_merge(
  196.                 [
  197.                     $cart_id => [
  198.                         'id'       => intval($id),
  199.                         'var'      => intval($var),
  200.                         'num'      => intval($num),
  201.                         'baseprice'=> floatval($price),
  202.                         'price'    => floatval($price),
  203.                         'skidka'   => floatval($skidka),
  204.                         'weight'   => floatval($weight),
  205.                     ]
  206.                 ],
  207.                 $this->cart
  208.             );
  209.             if($this->cart[$cart_id]['skidka'] == 0){
  210.                 $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  211.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  212.             }else{
  213.                 $this->cart[$cart_id]['numdiscount'] = 0;
  214.                 $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  215.             }
  216.         }
  217.         $this->recount();
  218.         $this->save_session();
  219.         $this->flush();
  220.     }
  221.     public function updateItem($cart_id ''$num 0$numdiscount = []){
  222.         if($num == 0){
  223.             $prod $this->cart[$cart_id]['id'];
  224.             $prodvar $this->cart[$cart_id]['var'];
  225.             unset($this->cart[$cart_id]);
  226.         }else{
  227.             $this->cart[$cart_id]['num'] = intval($num);
  228.             if($this->order_id == 0) {
  229.                 if($this->cart[$cart_id]['skidka'] == 0){
  230.                     $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  231.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  232.                 }else{
  233.                     $this->cart[$cart_id]['numdiscount'] = 0;
  234.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  235.                 }
  236.             } else {
  237.                 if($this->cart[$cart_id]['skidka'] == 0){
  238.                     $this->cart[$cart_id]['numdiscount'] = $this->NumDiscount->getDiscount($num$numdiscount);
  239.                     $this->cart[$cart_id]['userdiscount'] = $this->UserDiscount->getValue();
  240.                 }else{
  241.                     $this->cart[$cart_id]['numdiscount'] = 0;
  242.                     $this->cart[$cart_id]['userdiscount'] = 0;
  243.                 }
  244.             }
  245.                 
  246.             $this->recount();
  247.             $prod intval($this->cart[$cart_id]['id']);
  248.             $prodvar intval($this->cart[$cart_id]['var']);
  249.         }
  250.         $this->save_session();
  251.         $this->flush();
  252.     }
  253.     public function deleteItem(string $cart_id)
  254.     {
  255.         $prod $this->cart[$cart_id]['id'];
  256.         $prodvar $this->cart[$cart_id]['var'];
  257.         unset($this->cart[$cart_id]);
  258.         $this->recount();
  259.         $this->save_session();
  260.         $this->flush();
  261.     }
  262.     public function deleteAll()
  263.     {
  264.         $this->cart = [];
  265.         $this->delete_session();
  266.         $this->flush();
  267.     }    
  268.     public function cart_id($prod 0$var 0$chars = array(), $user_id 0)
  269.     {
  270.         $this->getCartId($prod$var$chars$user_id);        
  271.     }
  272.                 
  273.     public function getAmount(): float
  274.     {
  275.         $amount 0;
  276.         foreach($this->cart as $k => $v)
  277.             $amount += round($v['price'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  278.             
  279.         return $amount;
  280.     }
  281.     public function getBaseAmount(): float 
  282.     {
  283.         $amount 0;
  284.         foreach($this->cart as $k => $v)
  285.             $amount += round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  286.             
  287.         return $amount;
  288.     }
  289.     public function getAmountWithoutDiscount()
  290.     {
  291.         $amount 0;
  292.             
  293.         foreach ($this->cart as $k => $v) {
  294.             $amount += round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP) * $v['num'];
  295.         }
  296.             
  297.         return $amount;
  298.     }
  299.     public function getAmountDelivery()
  300.     {
  301.         return (float)@$_SESSION['_sf2_attributes']['checkout']['delivery_cost'];
  302.     }
  303.     public function getAmountWithDelivery()
  304.     {
  305.         if (($this->getAmount() < $this->app->sett->get('free_delivery_amount')) || ($this->Auth->isOpt())) {
  306.             return $this->getAmount() + $this->getAmountDelivery();
  307.         } else {
  308.             return $this->getAmount();
  309.         }
  310.     }
  311.     public function userLogin($user_id)
  312.     {
  313.         $this->load_session($user_id);
  314.         $discount $this->UserDiscount->getValue();
  315.         if ($discount >= 0) {
  316.             foreach ($this->cart as $k => $v) {
  317.                 $prod $this->Prods->find((int)$v['id']);
  318.                 $numdiscount $prod->getNumdiscount();
  319.         
  320.                 if($v['var'] == 2){
  321.                     $numdiscount $prod->getNumdiscount2();
  322.                 }
  323.     
  324.                 if($v['var'] == 3){
  325.                     $numdiscount $prod->getNumdiscount3();
  326.                 }
  327.                 
  328.                 $this->cart[$k]['userdiscount'] = $discount;
  329.                 if($this->Auth->isOpt()) {
  330.                     $this->cart[$k]['numdiscount'] = $this->NumDiscount->getDiscount((int) $this->cart[$k]['num'], $numdiscount);
  331.                 }
  332.             }
  333.         }
  334.         $this->recount();
  335.         $this->save_session();
  336.         $this->em->createQuery("DELETE App\Entity\CartUnsaved c WHERE c.user_id = '".$this->Auth->guestId()."'")->getResult();
  337.         $this->flush();
  338.     }
  339.         
  340.     public function setUserDiscount($discount){
  341.         if($discount){
  342.             foreach($this->cart as $k => $v){
  343.                 $this->cart[$k]['userdiscount'] = $discount;
  344.             }
  345.         }
  346.         $this->recount();
  347.         $this->save_session();
  348.         $this->flush();
  349.     }
  350.         
  351.     protected function recount($cart = [])
  352.     {
  353.         if (!empty($cart)) {
  354.             foreach ($cart as $k => $v) {
  355.                 if (!isset($v['userdiscount'])) $cart[$k]['userdiscount'] = 0;
  356.                 if (!isset($v['numdiscount'])) $cart[$k]['numdiscount'] = 0;
  357.                 if (!isset($v['skidka'])) $cart[$k]['skidka'] = 0;                
  358.                 
  359.                 $cart[$k]['baseprice'] = (new Money($v['baseprice']))->getAmount();
  360.                 if ($v['skidka']) {
  361.                     $cart[$k]['price'] = (new Money(($v['baseprice']) * (100 $v['skidka']) / 100))->getAmount();
  362.                 } else {
  363.                     $cart[$k]['price'] = (new Money((($v['baseprice']) * (100 $v['userdiscount']) * (100 $v['numdiscount']) / 100 100)))->getAmount();
  364.                 }                
  365.             }
  366.             return $cart;
  367.         }
  368.         foreach ($this->cart as $k => $v) {
  369.             if (!isset($v['userdiscount'])) $this->cart[$k]['userdiscount'] = 0;
  370.             if (!isset($v['numdiscount'])) $this->cart[$k]['numdiscount'] = 0;
  371.             if (!isset($v['skidka'])) $this->cart[$k]['skidka'] = 0;
  372.             
  373.             if ($this->order_id == 0) {
  374.                 $prod $this->Prods->find((int) $v['id']);
  375.                 if ($prod) {
  376.                     $skidka $prod->getSkidka();
  377.             
  378.                     if ($v['var'] == 2) {
  379.                         $skidka $prod->getSkidka2();
  380.                     }
  381.     
  382.                     if ($v['var'] == 3) {
  383.                         $skidka $prod->getSkidka3();
  384.                     }
  385.                 
  386.                     $this->cart[$k]['skidka'] = $skidka;
  387.                 }                
  388.             }
  389.             
  390.             $this->cart[$k]['baseprice'] = (new Money($v['baseprice']))->getAmount();
  391.             if ($v['skidka']) {
  392.                 $this->cart[$k]['price'] = (new Money(($v['baseprice']) * (100 $v['skidka']) / 100))->getAmount();
  393.             } else {
  394.                 $this->cart[$k]['price'] = (new Money((($v['baseprice']) * (100 $v['userdiscount']) * (100 $v['numdiscount']) / 100 100)))->getAmount();
  395.             }                
  396.         }    
  397.     }
  398.         
  399.     public function getProdNum()
  400.     {
  401.         return (empty($this->cart)) ? count($this->cart);
  402.     }
  403.     public function getPackNum()
  404.     {
  405.         $num 0;
  406.         foreach($this->cart as $k => $v)
  407.             $num += $v['num'];
  408.         return $num;
  409.     }
  410.     public function getWeight()
  411.     {
  412.         $weight 0;
  413.         foreach($this->cart as $k => $v)
  414.         {
  415.             $n $v['num'] ?? 0;
  416.             $w $v['weight'] ?? 0;
  417.             $weight += $n $w;
  418.         }
  419.             
  420.         return round($weight 10002);
  421.     }
  422.     protected function load_session()
  423.     {
  424.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  425.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  426.         if ($unsaved_cart) {
  427.             $cart json_decode($unsaved_cart->getCart(), true);    
  428.             foreach ($cart as $k => $v) {
  429.                 $prod $this->Prods->find((int) $v['id']);
  430.                 
  431.                 $v['baseprice'] = $prod->getPrice();
  432.                 if ($v['var'] == 2) { 
  433.                     $v['baseprice'] = $prod->getPrice2();
  434.                 } elseif ($v['var'] == 3) {
  435.                     $v['baseprice'] = $prod->getPrice3();
  436.                 }
  437.                 
  438.                 if (!isset($this->cart[$k])) {
  439.                     $this->cart[$k] = $v;
  440.                 }                
  441.             }
  442.         }
  443.         $this->flush();
  444.     }
  445.     private function flush()
  446.     {
  447.         $this->Session->set('cart'$this->cart);
  448.     }
  449.     public function save_session()
  450.     {
  451.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  452.         $cart json_encode($this->cartJSON_UNESCAPED_UNICODE);
  453.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  454.         if ($unsaved_cart) {
  455.             $unsaved_cart->setCart($cart);
  456.         } else {
  457.             $unsaved_cart = new CartUnsaved();
  458.             $unsaved_cart->setUserId($uid);
  459.             $unsaved_cart->setCart($cart);
  460.             $this->em->persist($unsaved_cart);
  461.         }
  462.         $this->em->flush();
  463.     }
  464.     public function delete_session()
  465.     {
  466.         $uid $this->Auth->getUserId() ? $this->Auth->getUserId(): $this->Auth->guestId();
  467.         $unsaved_cart $this->CartUnsaved->findOneBy(["user_id" => $uid]);
  468.         if ($unsaved_cart) {
  469.             $this->em->remove($unsaved_cart);
  470.             $this->em->flush();
  471.         }
  472.     }
  473.         
  474.     public function saveCart(int $order_id) {
  475.         // if ($this->Auth->isAuth() || !$this->Auth->isOpt()) {
  476.         //     $userdiscount = $this->UserDiscount->calculateUserDiscount(new Model_Discount, new Model_Order(), new Model_User(), Auth::userid());
  477.         // } else {
  478.         //     $userdiscount = 0;
  479.         // }
  480.         
  481.         foreach ($this->cart as $k => $v) {
  482.             $prod $this->Prods->find((int) $v['id']);
  483.             $price $prod->getPrice();
  484.             $num $prod->getNum();
  485.             
  486.             if ($v['var'] == 2) {
  487.                 $price $prod->getPrice2();
  488.             } elseif($v['var'] == 3) {
  489.                 $price $prod->getPrice3();
  490.             }
  491.             if($v['skidka']){
  492.                 $v['numdiscount'] = 0;
  493.             }
  494.                 
  495.             if ($v['skidka']) {
  496.                 $v['numdiscount'] = 0;
  497.             }
  498.                 
  499.             $Cart = new EntityCart();
  500.             $Cart->setOrderId($order_id);
  501.             $Cart->setProd($prod);
  502.             $Cart->setVar((int) $v['var']);
  503.             $Cart->setNum((int) $v['num']);
  504.             $Cart->setPrice(round($priceEnv::price_precission(), PHP_ROUND_HALF_UP));
  505.             $Cart->setSkidka((int) $v['skidka']);
  506.             $Cart->setNumdiscount((int) $v['numdiscount']);
  507.             $Cart->setUserdiscount((int) $v['userdiscount']);
  508.             //$Cart->setSumdiscount((int) $v['sumdiscount']);
  509.             $this->em->persist($Cart);                
  510.         }
  511.         $this->em->flush();
  512.         $this->flush();
  513.     }
  514.     //Удалить товары с нулевыми остатками из цветов
  515.     public function deleteNullFromColors()
  516.     {
  517.         foreach ($this->cart as $k => $v) {
  518.             $prod $this->Prods->find((int) $v['id']);
  519.             $prod_num $prod->getNum();
  520.             if ($v['var'] == 2$prod_num $prod->getNum2();
  521.             if ($v['var'] == 3$prod_num $prod->getNum3();
  522.             if ($prod->getId() == $v['id'] && $prod_num && $prod_num $v['num']) {
  523.                 $this->prods_limited[] = $v['id'];
  524.                 $this->cart[$k]['num'] = $prod_num;
  525.             }
  526.             if ($prod->getId() == $v['id'] && $prod_num <= 0) {
  527.                 $this->prodColor->deleteColor($prod->getId());
  528.             }
  529.         }
  530.         $this->flush();
  531.     }
  532.     public function save_cart_admin($order_id) {
  533.         $this->em->createQuery("DELETE App\Entity\Cart c WHERE c.order = ".$order_id)->getResult();
  534.         
  535.         foreach ($this->cart as $v) {
  536.             $prod $this->Prods->find((int) $v['id']);
  537.             if ($v['skidka']) {
  538.                 $v['numdiscount'] = 0;
  539.             }
  540.             $Cart = new EntityCart();
  541.             $Cart->setOrderId($order_id);
  542.             $Cart->setProd($prod);
  543.             $Cart->setVar((int) $v['var']);
  544.             $Cart->setNum((int) $v['num']);
  545.             $Cart->setPrice(round($v['baseprice'], Env::price_precission(), PHP_ROUND_HALF_UP));
  546.             $Cart->setSkidka((int) $v['skidka']);
  547.             $Cart->setNumdiscount((int) $v['numdiscount']);
  548.             $Cart->setUserdiscount((int) $v['userdiscount']);
  549.             $Cart->setSumdiscount((int) $v['sumdiscount']);
  550.             $this->em->persist($Cart);
  551.         }
  552.         $this->em->flush();
  553.         $this->flush();
  554.     }
  555.     
  556.     public function prods_limited() {
  557.         foreach ($this->cart as $k => $v) {
  558.             $prod $this->Prods->find((int) $v['id']);
  559.             $prod_num $prod->getNum();
  560.             if ($v['var'] == 2$prod_num $prod->getNum2();
  561.             if ($v['var'] == 3$prod_num $prod->getNum3();
  562.         
  563.             if ($prod->getId() == $v['id'] && $prod_num && $prod_num $v['num']) {
  564.                 $this->prods_limited[] = $v['id'];
  565.                 $this->cart[$k]['num'] = $prod_num;
  566.             }
  567.             if ($prod->getId() == $v['id'] && $prod_num <= 0) {
  568.                 unset($this->cart[$k]);
  569.             }
  570.         }
  571.         $this->flush();
  572.         $this->save_session();
  573.         if (!empty($this->prods_limited)) return true;
  574.         else return false;
  575.     }
  576.     public function getProdsLimited (): array
  577.     {
  578.         return $this->prods_limited;
  579.     }
  580. }