/**
  * Reindex category's products after reindexing the category
  *
  * @param \Magento\Catalog\Model\Category $subject The cateogry being reindexed
  * @param callable                        $proceed The parent function we are plugged on
  *                                                 : Magento\Catalog\Model\Category::reindex()
  *
  * @return \Magento\Catalog\Model\Category
  */
 public function aroundReindex(\Magento\Catalog\Model\Category $subject, callable $proceed)
 {
     $proceed();
     if (!empty($subject->getAffectedProductIds())) {
         $this->processFullTextIndex($subject->getAffectedProductIds());
     }
     return;
 }
 /**
  * @param \Magento\Catalog\Model\Category $subject
  * @param \Magento\Catalog\Model\Category $result
  * @return \Magento\Catalog\Model\Category
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterSave(\Magento\Catalog\Model\Category $subject, \Magento\Catalog\Model\Category $result)
 {
     /** @var \Magento\Catalog\Model\Category $result */
     $productIds = $result->getAffectedProductIds();
     if ($productIds) {
         $this->productRuleProcessor->reindexList($productIds);
     }
     return $result;
 }
 /**
  * Generate url rewrites for products assigned to category
  *
  * @param Category $category
  * @return array
  */
 public function generateProductUrlRewrites(Category $category)
 {
     $this->isSkippedProduct = [];
     $saveRewriteHistory = $category->getData('save_rewrites_history');
     $storeId = $category->getStoreId();
     $productUrls = [];
     if ($category->getAffectedProductIds()) {
         $this->isSkippedProduct = $category->getAffectedProductIds();
         $collection = $this->productCollectionFactory->create()->setStoreId($storeId)->addIdFilter($category->getAffectedProductIds())->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addAttributeToSelect('url_path');
         foreach ($collection as $product) {
             $product->setStoreId($storeId);
             $product->setData('save_rewrites_history', $saveRewriteHistory);
             $productUrls = array_merge($productUrls, $this->productUrlRewriteGenerator->generate($product));
         }
     } else {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($category, $storeId, $saveRewriteHistory));
     }
     foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
         $productUrls = array_merge($productUrls, $this->getCategoryProductsUrlRewrites($childCategory, $storeId, $saveRewriteHistory));
     }
     return $productUrls;
 }