The following error occurs when trying to edit an existing promotion -
"Uncaught PHP Exception Drupal\\Core\\Entity\\Exception\\UndefinedLinkTemplateException: "No link template 'canonical' found for the 'commerce_promotion' entity type" at /usr/src/app/web/core/lib/Drupal/Core/Entity/Entity.php line 214, referer: http://localhost/admin/commerce/promotions"

I've added a patch to add the "canonical" link for the Promotion entity type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vgardner created an issue. See original summary.

bojanz’s picture

Status: Active » Postponed (maintainer needs more info)

Well that's weird. You seem to be running into an issue that was fixed in Drupal 8.3.0. What's your core version? Can you try updating it and retest?

Promotions are not meant to have a canonical link and we intentionally removed a workaround for this before RC1.

bojanz’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
司南’s picture

Status: Closed (outdated) » Active
Issue tags: -

I want to build a views to show all promotions on my site, and then it trigger this error.

I've seen that Commerce intentionally remove the canonical link for the promotion entity type, but why guy do that?
And how to implement my promotion views please ?

bojanz’s picture

Status: Active » Closed (outdated)

A fix was added in #2986802: Promotions can't be translated:

  /**
   * {@inheritdoc}
   */
  public function toUrl($rel = 'canonical', array $options = []) {
    if ($rel == 'canonical') {
      $rel = 'edit-form';
    }
    return parent::toUrl($rel, $options);
  }
macherif’s picture

I resolved this problem with file_create_url function :

$url = file_create_url($file->getFileUri())