Update
Showing
2 changed files
with
3 additions
and
27 deletions
| 1 | <?php | ||
| 2 | |||
| 3 | namespace FGCT\OverrideCreateInvoice\Helper; | ||
| 4 | |||
| 5 | class Data extends \Magento\Framework\App\Helper\AbstractHelper { | ||
| 6 | protected $_filesystem; | ||
| 7 | protected $_directory_list; | ||
| 8 | protected $_resource; | ||
| 9 | protected $_scopeConfig; | ||
| 10 | public function __construct( | ||
| 11 | \Magento\Framework\App\Helper\Context $context, | ||
| 12 | \Magento\Framework\Filesystem $filesystem, | ||
| 13 | \Magento\Framework\App\ResourceConnection $resource, | ||
| 14 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, | ||
| 15 | \Magento\Framework\App\Filesystem\DirectoryList $directory_list | ||
| 16 | ) { | ||
| 17 | parent::__construct($context); | ||
| 18 | $this->_filesystem = $filesystem; | ||
| 19 | $this->_directory_list = $directory_list; | ||
| 20 | $this->_resource = $resource; | ||
| 21 | $this->_scopeConfig = $scopeConfig; | ||
| 22 | } | ||
| 23 | } |
| ... | @@ -28,16 +28,15 @@ class OrderInvoiceSaveBefore implements ObserverInterface { | ... | @@ -28,16 +28,15 @@ class OrderInvoiceSaveBefore implements ObserverInterface { |
| 28 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | 28 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); |
| 29 | $orderId = $this->_request->getParam('order_id'); | 29 | $orderId = $this->_request->getParam('order_id'); |
| 30 | $invoice = $observer->getEvent()->getInvoice(); | 30 | $invoice = $observer->getEvent()->getInvoice(); |
| 31 | $order = $invoice->getOrder(); | 31 | // $order = $invoice->getOrder(); |
| 32 | $productManager = $objectManager->create('Magento\Catalog\Model\Product'); | 32 | $productManager = $objectManager->create('Magento\Catalog\Model\Product'); |
| 33 | $productsOutStock = $productsNotEnoughQty = []; | 33 | $productsOutStock = $productsNotEnoughQty = []; |
| 34 | foreach ($invoice->getAllItems() as $item) { | 34 | foreach ($invoice->getAllItems() as $item) { |
| 35 | $name = $item->getName(); | 35 | $name = $item->getName(); |
| 36 | $type = $item->getSku(); | 36 | // $type = $item->getSku(); |
| 37 | $productId = $item->getProductId(); | 37 | $productId = $item->getProductId(); |
| 38 | $qty = $item->getQty(); | 38 | $qty = $item->getQty(); |
| 39 | $product = $productManager->load($productId); | 39 | // $product = $productManager->load($productId); |
| 40 | |||
| 41 | $_productStock = $this->_stockItemRepository->get($productId); | 40 | $_productStock = $this->_stockItemRepository->get($productId); |
| 42 | // $_productStock->getQty(); | 41 | // $_productStock->getQty(); |
| 43 | if(!$_productStock->getIsInStock()) { | 42 | if(!$_productStock->getIsInStock()) { | ... | ... |
-
Please register or sign in to post a comment