Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Product
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2017 at 06:36 UTC
Updated:
8 Mar 2017 at 13:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bojanz commentedIt's implemented dynamically in ProductVariation::toUrl().
Where's the exception coming from?
Comment #3
replicaobscuraI've got a search results View that's showing a Search API index of product variations. The results are showing as rendered entities of a custom view mode ("Search result") of product variations. On the title of the variation, as well as the image field, I've selected in the Form display settings to link to the content. When trying to render the results page with these settings I get the mentioned error that there is no "canonical" link.
Comment #4
replicaobscuraThe first line in my stack trace was the key, I should have posted it sooner. Apparently it's because "revision" is being used as the link $rel, which doesn't get the dynamic "canonical" editing that normally happens.
Comment #5
replicaobscuraI'm unclear on why the "revision" link is being requested on a product variation in the first place. Is this the actual bug? I didn't think variations were currently revisionable.
The parent class's toUrl() method includes this block:
This is what's converting the "revision" $rel into "canonical" and then failing for variations since it's already inside the parent method's call. But if variations aren't revisionable then why the "revision" link is being requested as part of the rendered entity display mode is confusing to me.
Comment #6
replicaobscuraThe default StringFormatter field plugin, if linking to the entity, automatically uses
$url = $items->getEntity()->urlInfo('revision');without knowing if the item is revisionable, as far as I can tell. I'm working on a patch for commerce that'll convert "revision" back to "canonical" before the conditional so that the dynamic link template works still.Comment #7
replicaobscuraIn actuality, I think this is possibly a core bug, though I don't know if it's already got a separate issue. "revision" should not be assumed a valid link template on every entity, only revisionable entities.
However, since it's easier to fix here for now, this patch fixes the issue for me.
Comment #8
replicaobscuraComment #9
replicaobscuraLinked to the related core issue I filed. Not 100% sure it's needed yet, but it seems like it to me.
Comment #10
bojanz commentedMore precise title.
Comment #12
bojanz commentedThanks!