craftcms/commerce

[5.x]: System Email Preview does not work in multi-site-store setup

stanislavprokopov opened this issue · 3 comments

What happened?

Description

When trying to preview emails under Commerce -> System Settings -> Emails -> Preview button, an error is returned:

Could not find the email or template.```

The issue is in https://github.com/craftcms/commerce/blob/2bd64462cc60f7bb238bafcac4021bf0d42afa73/src/controllers/EmailPreviewController.php#L39, the `getEmailById` method is store has a second argument `$storeId`, and right not it is not provided, this means  that the system uses `Plugin::getInstance()->getStores()->getCurrentStore()->id` and this could be any store you have configured.

### Steps to reproduce

1. Setup multiple sites and stores
2. Create two emails in System Settings
3. Press Preview button

### Expected behavior

Expect the button to work

### Actual behavior

```Can’t preview this email.
Could not find the email or template.```


### Craft CMS version

5.2.8

### Craft Commerce version

5.0.13

### PHP version

_No response_

### Operating system and version

_No response_

### Database type and version

_No response_

### Image driver and version

_No response_

### Installed plugins and versions

-

Thanks for reporting. This is fixed for the next release.

To get the fix early, change your craftcms/commerce requirement in composer.json to:

"require": {
  "craftcms/commerce": "5.x-dev#8a4136a20bb84ff1d4ff8fb0c8721f19f3f6bb53 as 5.0.13",
  "...": "..."
}

Then run composer update.

We will update this ticket once the release is out.

Hi

Commerce 5.0.14 has now been released with this fix included.

Please update your project to get the latest version.

Thanks!