Update url-key
A Magento 2 store may undergo changes from time to time. There may be changes in product or catalogue pages or changed the location entirely! In such cases, if the URL rewriting is not taken care of, then the store might lose potential customers due to landing on a page that does not exist anymore. Also, the admin would want to rewrite the URL with higher-value keywords to make it more search friendly and improve the SEO of the store. If you’re going to do the same for your store, learn how to manage the Magento 2 URL rewrite! Remember, a misconfigured URL rewrite can cause Magento 2 404 error.
-
The Pacemaker always required an url key, which sometimes led to problems with missing CSV files.
-
With this configuration, it is possible to set the URL key based on the name of a category/product.
Example
- That can get performed by setting the
update-url-key-from-name
flag totrue
:
{
"operation": {
"catalog_product" : {
"add-update": {
"plugins": {
"subject": {
"id": "import.plugin.subject",
"subjects": [
{
"id": "import_product.subject.bunch",
"file-resolver": {
"prefix": "product-import"
},
"params": {
"copy-images": false,
"media-directory" : "pub/media/catalog/product",
"images-file-directory" : "var/importexport/media/catalog/product",
"update-url-key-from-name": true,(1)
"clean-up-variants": false,
"clean-up-links": false,
"clean-up-media-gallery": true,
"clean-up-empty-image-columns": true,
"clean-up-website-product-relations": true,
"clean-up-category-product-relations": true,
"clean-up-empty-columns": [
"special_price",
"special_price_from_date",
"special_price_to_date"
]
},
"observers": [
{
"import": [
"import_product.observer.composite.base.add_update"
]
}
]
}
]
}
}
}
},
"catalog_category": {
"add-update": {
"plugins": {
"subject": {
"id": "import.plugin.subject",
"subjects": [
{
"id": "import_category.subject.bunch",
"file-resolver": {
"prefix": "category-create"
},
"params": {
"copy-images": false,
"media-directory" : "pub/media/catalog/category",
"images-file-directory" : "var/importexport/media/catalog/category",
"clean-up-empty-columns": [],(2)
"update-url-key-from-name": true
},
"observers": [
{
"import": [
"import_category.observer.composite.add_update"
]
}
]
}
]
}
}
}
}
}
}
1 | To set the update-url-key-from-name for product operation flag to true or false . |
2 | To set the update-url-key-from-name for category operation flag to true or false .
|