I need the stock item attributt "maxSaleQty" in storview level and not in global level. I have create a new product attribute "maxSaleQtyStore". Then I create a Plugin. This works if I set a static value. But I'm not able to get the current product - with his attributtes.

The load product code comes from How do I get the current product in Magento2?

Here my code of the Item.php:

namespace Vendor\MaxSaleQty\Plugin\Model;

use Magento\Catalog\Model\Product;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;

class Item extends Template

   protected $registry;
   private $product;

    public function __construct(Template\Context $context,
                                Registry $registry,
                                array $data)
        $this->registry = $registry;
        parent::__construct($context, $data);

    private function getProduct()
        if (is_null($this->product)) {
            $this->product = $this->registry->registry('product');

            if (!$this->product->getId()) {
                throw new LocalizedException(__('Failed to initialize product'));

        return $this->product;

    public function afterGetMaxSaleQty()

        $maxSaleQty = $this->getProduct->getMaxSaleQtyStore(); // $productId; 
        return $maxSaleQty;

Big thanks for any help!

1 Answer 1


Use getData method.

$qty_increments = $prod->getData('qty_increments_new');
  • this do not work.
    – R.Jung
    Jun 12, 2017 at 8:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.