Esempio n. 1
0
 /**
  * Update attribute values for entity list per store
  *
  * @param array $productIds
  * @param array $attrData
  * @param int $storeId
  * @return $this
  */
 public function updateAttributes($productIds, $attrData, $storeId)
 {
     $this->_eventManager->dispatch('catalog_product_attribute_update_before', ['attributes_data' => &$attrData, 'product_ids' => &$productIds, 'store_id' => &$storeId]);
     $this->_getResource()->updateAttributes($productIds, $attrData, $storeId);
     $this->setData(['product_ids' => array_unique($productIds), 'attributes_data' => $attrData, 'store_id' => $storeId]);
     if ($this->_hasIndexableAttributes($attrData)) {
         $this->_productEavIndexerProcessor->reindexList(array_unique($productIds));
     }
     $categoryIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID);
     if (!$categoryIndexer->isScheduled()) {
         $categoryIndexer->reindexList(array_unique($productIds));
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Update attribute values for entity list per store
  *
  * @param array $productIds
  * @param array $attrData
  * @param int $storeId
  * @return $this
  */
 public function updateAttributes($productIds, $attrData, $storeId)
 {
     $this->_eventManager->dispatch('catalog_product_attribute_update_before', array('attributes_data' => &$attrData, 'product_ids' => &$productIds, 'store_id' => &$storeId));
     $this->_getResource()->updateAttributes($productIds, $attrData, $storeId);
     $this->setData(array('product_ids' => array_unique($productIds), 'attributes_data' => $attrData, 'store_id' => $storeId));
     if ($this->_hasIndexableAttributes($attrData)) {
         $this->_productEavIndexerProcessor->reindexList(array_unique($productIds));
     }
     // 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));
     }
     return $this;
 }