/**
  * Cancel order item
  *
  * @param   EventObserver $observer
  * @return  void
  */
 public function execute(EventObserver $observer)
 {
     /** @var \Magento\Sales\Model\Order\Item $item */
     $item = $observer->getEvent()->getItem();
     $children = $item->getChildrenItems();
     $qty = $item->getQtyOrdered() - max($item->getQtyShipped(), $item->getQtyInvoiced()) - $item->getQtyCanceled();
     if ($item->getId() && $item->getProductId() && empty($children) && $qty) {
         $this->stockManagement->backItemQty($item->getProductId(), $qty, $item->getStore()->getWebsiteId());
     }
     $this->priceIndexer->reindexRow($item->getProductId());
 }
Exemplo n.º 2
0
 /**
  * Init indexing process after product delete commit
  *
  * @return void
  */
 public function afterDeleteCommit()
 {
     $this->reindex();
     $this->_productPriceIndexerProcessor->reindexRow($this->getId());
     parent::afterDeleteCommit();
 }
Exemplo n.º 3
0
 /**
  * Cancel order item
  *
  * @param   EventObserver $observer
  * @return  $this
  */
 public function cancelOrderItem($observer)
 {
     $item = $observer->getEvent()->getItem();
     $children = $item->getChildrenItems();
     $qty = $item->getQtyOrdered() - max($item->getQtyShipped(), $item->getQtyInvoiced()) - $item->getQtyCanceled();
     if ($item->getId() && $item->getProductId() && empty($children) && $qty) {
         $this->_stock->backItemQty($item->getProductId(), $qty);
     }
     $this->_priceIndexer->reindexRow($item->getProductId());
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Init indexing process after product delete commit
  *
  * @return void
  */
 protected function _afterDeleteCommit()
 {
     $this->reindex();
     $this->_productPriceIndexerProcessor->reindexRow($this->getId());
     parent::_afterDeleteCommit();
     $this->_indexIndexer->indexEvents(self::ENTITY, \Magento\Index\Model\Event::TYPE_DELETE);
 }
Exemplo n.º 5
0
 /**
  * Reindex product price
  *
  * @param int|\Magento\Catalog\Model\Product $product
  *
  * @return void
  */
 protected function _reindexProduct($product)
 {
     $productId = is_numeric($product) ? $product : $product->getId();
     $this->_processor->reindexRow($productId);
 }