<?php

namespace Magetop\Agency\Model\Rewrite\CatalogInventory\Stock;

class Item extends \Magento\CatalogInventory\Model\Stock\Item
{
    public function getIsInStock()
    {
        if (!$this->getManageStock()) {
            return true;
        }
        return (bool) $this->_getData(static::IS_IN_STOCK);
    }

    /**
     * @return float
     */
    public function getQty()
    {
        $fullActionName = $this->helper()->getFullActionName();//catalog_product_edit
        $productId = $this->getProductId();
        $qty = 0;
        if ($fullActionName == 'catalog_product_edit') {
            return $this->_getData(static::QTY) - $qty;
        }
        return parent::_getData(static::QTY);
    }

    public function helper()
    {
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $helper = $objectManager->get('Magetop\Agency\Helper\Data');
        return $helper;
    }
}
