Exemple #1
0
 /**
  * Update websites for product action
  *
  * Allowed types:
  * - add
  * - remove
  *
  * @param array $productIds
  * @param array $websiteIds
  * @param string $type
  * @return void
  */
 public function updateWebsites($productIds, $websiteIds, $type)
 {
     if ($type == 'add') {
         $this->_productWebsiteFactory->create()->addProducts($websiteIds, $productIds);
     } else {
         if ($type == 'remove') {
             $this->_productWebsiteFactory->create()->removeProducts($websiteIds, $productIds);
         }
     }
     $this->setData(array('product_ids' => array_unique($productIds), 'website_ids' => $websiteIds, 'action_type' => $type));
     // register mass action indexer event
     $this->_indexIndexer->processEntityAction($this, \Magento\Catalog\Model\Product::ENTITY, \Magento\Index\Model\Event::TYPE_MASS_ACTION);
     if (!$this->getCategoryIndexer()->isScheduled()) {
         $this->getCategoryIndexer()->reindexList(array_unique($productIds));
     }
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
 /**
  * Run reindex process after data save
  *
  * @return $this
  */
 protected function _afterSave()
 {
     parent::_afterSave();
     $this->_indexer->processEntityAction($this, self::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE);
     return $this;
 }
Exemple #4
0
 /**
  * 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;
 }
Exemple #5
0
 /**
  * Config data after commit observer.
  *
  * @param EventObserver $observer
  * @return void
  */
 public function processConfigDataSave(EventObserver $observer)
 {
     $configData = $observer->getEvent()->getConfigData();
     $this->_indexer->processEntityAction($configData, \Magento\Framework\App\Config\ValueInterface::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE);
 }