I wish the qty valyue could be dynamic (I mean, get another value if product qty had increment) so I create a module and put a helper. Data.php
namespace Vendor\Module\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
public function __construct(\Magento\CatalogInventory\Block\Qtyincrements $qtyIncrements) {
$this->_qtyIncrements = $qtyIncrements;
}
public function getProductQtyIncrements()
{
return $this->_qtyIncrements->getProductQtyIncrements();
}
}```
and I call this method at app/design/frontend/Smartwave/porto_child/Magento_Catalog/templates/product/view/addtocart.phtml, it's work very well, but I need to do the same thing on magento_catalog/templates/product/list.phtml, but it return a error:
```<input type="text" name="qty" id="qty" maxlength="12" value="Error: Call to a member function getId() on null in /home/master/autopec/vendor/magento/module-catalog-inventory/Block/Qtyincrements.php:89
Stack trace:
#0 /home/master/autopec/app/code/Vendor/Module/Helper/Data.php(13): Magento\CatalogInventory\Block\Qtyincrements->getProductQtyIncrements()
#1 /home/master/autopec/app/design/frontend/Smartwave/porto_child/Magento_Catalog/templates/product/list.phtml(282): Vendor\Module\Helper\Data->getProductQtyIncrements()
#2 /home/master/autopec/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/home/master/au...')```
Could someone help call method in this part of module please ?