Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Model/UrlRewrite/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,21 @@ public function rebuild(int $storeId, array $arguments = [])
$this->productCollection->clear();
$this->productCollection->setStoreId($storeId);
$this->productCollection->addAttributeToSelect(['url_path', 'url_key']);

// do we have any arguments for this
if ($arguments) {
$this->productCollection->addFieldToFilter('entity_id', ['in' => $arguments]);
// Are we trying to do a range from x to y?
if(strstr((string)$arguments[0], '-'))
{
$range = (string)$arguments[0];
$parts = explode("-", $range);
$from_id = (int)$parts[0];
$to_id = (int)$parts[1];
// make sure we have two valid IDs
if($from_id && $to_id)
{
$this->productCollection->addFieldToFilter('entity_id', ['from' => $from_id, 'to' => $to_id]);
}
}
}

$this->urlRewrite
Expand All @@ -54,4 +66,5 @@ public function rebuild(int $storeId, array $arguments = [])
->setCollection($this->productCollection)
->rebuild();
}

}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Rebuild only products

```php
bin/magento urlrewrite:rebuild products
```

or products by IDs as an ID range this example is IDs from 16 to 69

```php
bin/magento urlrewrite:rebuild products -p=16-69
```

Rebuild only cms-pages
Expand Down