/** * Add reindexCallback * * @return \Magento\Catalog\Model\Category */ protected function _afterSave() { $result = parent::_afterSave(); $this->indexIndexer->processEntityAction($this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE); $this->_getResource()->addCommitCallback(array($this, 'reindex')); return $result; }
/** * Saving product type related data and init index * * @return \Magento\Catalog\Model\Product */ protected function _afterSave() { $this->getLinkInstance()->saveProductRelations($this); $this->getTypeInstance()->save($this); if ($this->getStockData()) { $this->setForceReindexEavRequired(true); } $this->_getResource()->addCommitCallback(array($this, 'priceReindexCallback')); $this->_getResource()->addCommitCallback(array($this, 'eavReindexCallback')); /** * Product Options */ if (!$this->getIsDuplicate()) { $this->getOptionInstance()->setProduct($this)->saveOptions(); } $result = parent::_afterSave(); $this->_indexIndexer->processEntityAction($this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE); $this->_getResource()->addCommitCallback(array($this, 'reindex')); $this->reloadPriceInfo(); return $result; }