0

As we had controversial opinions about this on our project, I'd like to ask the question here for another opinion (or two):

For Magento2, should we set url keys for simple products? Which of the three options is best?

a) use a unique url key for each simple product

b) use the same url key for all simples of one configurable

c) leave the url key empty for simple products

Our setup:

  • We have one page per configurable in our shop.
  • all simples of one configurable have the same name

My findings:

  • Configurables must have a unique url key
  • It is possible to add the same url key to multiple simple products
  • If I do not set a url key for a configurable, it is derived from the "name" attribute automatically
  • It is perfectly fine to set no url key for a simple. The simple product will then have no attribute record for the attribute type "url_key".
  • M2 does not seem to automatically increment the url key, if the (automatically derived) url key exists already
0

In Magento 2, the Url Key must be unique for each product.

Similar to Magento1, Magento2 doesn't append a unique number to the URL Key to make it unique if the same URL key exists already. It throws an error in that case.

For Every Product: If you leave the url key empty, Magento will use the product title to create a URL key. If two products have the same product title, then creation of the second product will fail with the error message URL key for specified store already exists.

As per your your setup:

All simples of one configurable have the same name like "Shirt"; so all configurable and simple products will have the same name. But each simple product will have configurable attribute variations like "Color and Size". So it will be like:

Main Configurable Product: Shirt (URL - shirt)

Four Simple Shirt Products:

Shirt Black L (URL - shirt-black-l)

Shirt Black M (URL - shirt-black-m)

Shirt White L (URL - shirt-white-l)

Shirt White M (URL - shirt-white-m)

You can set up the URL key like in the example above. As it is required to use a unique URL key (no need to mention that, if the Title is unique, then it will be successfully derived automatically from the title).

Find my comments on your findings:

  • Configurables must have a unique url key - YES

  • It is possible to add the same url key to multiple simple products - NO

  • If I do not set a url key for a configurable, it is derived from the "name" attribute automatically - YES if Title is unique other wise error will show

  • It is perfectly fine to set no url key for a simple. The simple product will then have no attribute record for the attribute type "url_key". - NO

  • M2 does not seem to automatically increment the url key, if the (automatically derived) url key exists already - YES

  • @dan please select answer and upvote if this help you. – Pankaj Pareek Jun 27 '18 at 4:31
  • Hi @Pankaj Preek, - thank you for your post. I appreciate that you tried to help, and I understand that I should upvote your post if it helps me. I have researched and experimented a lot before I posted this question here. Unfortunately, some of your findings are the opposite of what I found out. I actually set the url key of simple products programmatically to <nothing> upon creation. It works. I now wonder why you cannot, while I can. So far, it rather confused me than helping me; my apologies. – where Jul 4 '18 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.