/** * Add reindexCallback * * @return \Magento\Catalog\Model\Category */ public function afterSave() { $result = parent::afterSave(); $this->_getResource()->addCommitCallback([$this, 'reindex']); return $result; }
/** * Saving product type related data and init index * * @return \Magento\Catalog\Model\Product */ public function afterSave() { $this->getLinkInstance()->saveProductRelations($this); $this->getTypeInstance()->save($this); if ($this->getStockData()) { $this->setForceReindexEavRequired(true); } $this->_getResource()->addCommitCallback([$this, 'priceReindexCallback']); $this->_getResource()->addCommitCallback([$this, 'eavReindexCallback']); /** * Product Options */ if (!$this->getIsDuplicate()) { $this->getOptionInstance()->setProduct($this)->saveOptions(); } $result = parent::afterSave(); $this->_getResource()->addCommitCallback([$this, 'reindex']); $this->reloadPriceInfo(); // Resize images for catalog product and save results to image cache /** @var Product\Image\Cache $imageCache */ $imageCache = $this->imageCacheFactory->create(); $imageCache->generate($this); return $result; }