Beispiel #1
0
 /**
  * Remove product urls from storage
  *
  * @param \Magento\Catalog\Model\ResourceModel\Category $subject
  * @param callable $proceed
  * @param CategoryInterface $category
  * @return mixed
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDelete(\Magento\Catalog\Model\ResourceModel\Category $subject, \Closure $proceed, CategoryInterface $category)
 {
     $categoryIds = $this->childrenCategoriesProvider->getChildrenIds($category, true);
     $categoryIds[] = $category->getId();
     $result = $proceed($category);
     foreach ($categoryIds as $categoryId) {
         $this->deleteRewritesForCategory($categoryId);
     }
     return $result;
 }
 /**
  * @param Category $category
  * @return void
  */
 public function deleteCategoryRewritesForChildren(Category $category)
 {
     $categoryIds = $this->childrenCategoriesProvider->getChildrenIds($category, true);
     $categoryIds[] = $category->getId();
     foreach ($categoryIds as $categoryId) {
         $this->urlPersist->deleteByData([UrlRewrite::ENTITY_ID => $categoryId, UrlRewrite::ENTITY_TYPE => CategoryUrlRewriteGenerator::ENTITY_TYPE]);
         $this->urlPersist->deleteByData([UrlRewrite::METADATA => serialize(['category_id' => $categoryId]), UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE]);
     }
 }