1

I am trying to modify the following file in Magento2

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\ProductAlert\Block\Product\View;

/**
 * Recurring payment view stock
 *
 * @api
 * @since 100.0.2
 */
class Stock extends \Magento\ProductAlert\Block\Product\View
{
    /**
     * Prepare stock info
     *
     * @param string $template
     * @return $this
     */
    public function setTemplate($template)
    {
        if (!$this->_helper->isStockAlertAllowed() || !$this->getProduct() || $this->getProduct()->isAvailable()) {
            $template = '';
        } else {
            $this->setSignupUrl($this->_helper->getSaveUrl('stock'));
        }
        return parent::setTemplate($template);
    }
}

I want to display a "send me a notification mail" link on the productpage, when the quantity of a product is zero or lower. Because backorders are allowed, products maintain the status of "in stock" even when hitting the zero treshold, or lower.

As I understand right now, a possible solution could be to call for an object in: vendor/magento/module-catalog/Model/Product.php

Could this be a solution? If so, what would the code look like.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.