Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Qtyincrements.php
Go to the documentation of this file.
1 <?php
8 
11 
22 class Qtyincrements extends Template implements IdentityInterface
23 {
29  protected $_qtyIncrements;
30 
36  protected $_coreRegistry;
37 
41  protected $stockRegistry;
42 
49  public function __construct(
50  \Magento\Framework\View\Element\Template\Context $context,
51  \Magento\Framework\Registry $registry,
52  \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
53  array $data = []
54  ) {
55  $this->_coreRegistry = $registry;
56  $this->stockRegistry = $stockRegistry;
57  parent::__construct($context, $data);
58  }
59 
65  public function getProduct()
66  {
67  return $this->_coreRegistry->registry('current_product');
68  }
69 
75  public function getProductName()
76  {
77  return $this->getProduct()->getName();
78  }
79 
85  public function getProductQtyIncrements()
86  {
87  if ($this->_qtyIncrements === null) {
88  $stockItem = $this->stockRegistry->getStockItem(
89  $this->getProduct()->getId(),
90  $this->getProduct()->getStore()->getWebsiteId()
91  );
92  $this->_qtyIncrements = $stockItem->getQtyIncrements();
93  if (!$this->getProduct()->isSaleable()) {
94  $this->_qtyIncrements = false;
95  }
96  }
97  return $this->_qtyIncrements;
98  }
99 
105  public function getIdentities()
106  {
107  return $this->getProduct()->getIdentities();
108  }
109 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, array $data=[])