Пример #1
0
 /**
  * Process event
  *
  * @param \Magento\Index\Model\Event $event
  * @return void
  */
 protected function _processEvent(\Magento\Index\Model\Event $event)
 {
     $data = $event->getNewData();
     if (!empty($data['catalog_url_reindex_all'])) {
         $this->reindexAll();
     }
     // Force rewrites history saving
     $dataObject = $event->getDataObject();
     if ($dataObject instanceof \Magento\Framework\Object && $dataObject->hasData('save_rewrites_history')) {
         $this->_catalogUrl->setShouldSaveRewritesHistory($dataObject->getData('save_rewrites_history'));
     }
     if (isset($data['rewrite_product_ids'])) {
         $this->_catalogUrl->clearStoreInvalidRewrites();
         // Maybe some products were moved or removed from website
         foreach ($data['rewrite_product_ids'] as $productId) {
             $this->_catalogUrl->refreshProductRewrite($productId);
         }
     }
     if (isset($data['rewrite_category_ids'])) {
         $this->_catalogUrl->clearStoreInvalidRewrites();
         // Maybe some categories were moved
         foreach ($data['rewrite_category_ids'] as $categoryId) {
             $this->_catalogUrl->refreshCategoryRewrite($categoryId, null, true, true);
         }
     }
 }
Пример #2
0
 /**
  * @magentoDataFixture Magento/Catalog/_files/url_rewrites_invalid.php
  */
 public function testClearStoreInvalidRewrites()
 {
     $this->assertNotEmpty($this->_loadRewrite('product/1/5')->getId());
     $this->_model->clearStoreInvalidRewrites();
     $this->assertEmpty($this->_loadRewrite('product/1/5')->getId());
 }