| @@ 83-104 (lines=22) @@ | ||
| 80 | * @param null $storeId |
|
| 81 | * @return bool |
|
| 82 | */ |
|
| 83 | protected function removeProductUrls($productId, $storeId = null) |
|
| 84 | { |
|
| 85 | if (!is_numeric($productId)) { |
|
| 86 | return false; |
|
| 87 | } |
|
| 88 | $data = [ |
|
| 89 | UrlRewrite::ENTITY_ID => $productId, |
|
| 90 | UrlRewrite::ENTITY_TYPE => \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::ENTITY_TYPE, |
|
| 91 | UrlRewrite::REDIRECT_TYPE => 0, |
|
| 92 | ]; |
|
| 93 | ||
| 94 | if (!is_null($storeId)) { |
|
| 95 | $data[] = [UrlRewrite::STORE_ID => $storeId]; |
|
| 96 | } |
|
| 97 | try { |
|
| 98 | $this->getUrlPersist()->deleteByData($data); |
|
| 99 | } catch (\Exception $e) { |
|
| 100 | $this->output->writeln($e->getMessage()); |
|
| 101 | return false; |
|
| 102 | } |
|
| 103 | return true; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Generate list of product urls |
|
| @@ 107-128 (lines=22) @@ | ||
| 104 | * @param null $storeId |
|
| 105 | * @return bool |
|
| 106 | */ |
|
| 107 | protected function removeProductUrls($productId, $storeId = null) |
|
| 108 | { |
|
| 109 | if (!is_numeric($productId)) { |
|
| 110 | return false; |
|
| 111 | } |
|
| 112 | $data = [ |
|
| 113 | UrlRewrite::ENTITY_ID => $productId, |
|
| 114 | UrlRewrite::ENTITY_TYPE => \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::ENTITY_TYPE, |
|
| 115 | UrlRewrite::REDIRECT_TYPE => 0, |
|
| 116 | ]; |
|
| 117 | ||
| 118 | if (!is_null($storeId)) { |
|
| 119 | $data[] = [UrlRewrite::STORE_ID => $storeId]; |
|
| 120 | } |
|
| 121 | try { |
|
| 122 | $this->getUrlPersist()->deleteByData($data); |
|
| 123 | } catch (\Exception $e) { |
|
| 124 | $this->output->writeln($e->getMessage()); |
|
| 125 | return false; |
|
| 126 | } |
|
| 127 | return true; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Generate list of product urls |
|