Get the category into the url of the product page
It's a bit confusing, but since this product type has variants, using this should work:

shop/{object.categories.first().slug}/{object.slug}


If it didn't have variants, you wouldn't need the object reference in front of it.  The same thing applies if you're referencing a field inside of Matrix as well.

This has been made easier in the upcoming Commerce 2 so you don't have to worry about the differences.