![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Amasty/MWishlist/ViewModel/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Multiple Wishlist for Magento 2 */ namespace Amasty\MWishlist\ViewModel; use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter; use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface; use Magento\CatalogInventory\Model\StockRegistry; use Magento\Framework\View\Element\Block\ArgumentInterface; class AllowedQuantity implements ArgumentInterface { /** * @var StockRegistry */ private $stockRegistry; /** * @var ItemInterface */ private $item; public function __construct(StockRegistry $stockRegistry) { $this->stockRegistry = $stockRegistry; } /** * @return ItemInterface */ public function getItem(): ItemInterface { return $this->item; } /** * @param ItemInterface $item * @return self */ public function setItem(ItemInterface $item): self { $this->item = $item; return $this; } /** * @return array */ public function getMinMaxQty(): array { $product = $this->getItem()->getProduct(); $stockItem = $this->stockRegistry->getStockItem($product->getId(), $product->getStore()->getWebsiteId()); $params = []; $params['minAllowed'] = (float)$stockItem->getMinSaleQty(); if ($stockItem->getMaxSaleQty()) { $params['maxAllowed'] = (float)$stockItem->getMaxSaleQty(); } else { $params['maxAllowed'] = (float)StockDataFilter::MAX_QTY_VALUE; } return $params; } }