craft\commerce\services\Stores::getStoreById(): Argument #1 ($id) must be of type int, null given, called in /var/www/html/vendor/craftcms/commerce/src/base/StoreTrait.php on line 28
The issue is that base ShippingMethod class implements StoreTrait and it expects to have $storeId set, in commerce plugin they store storeId in the commerce_shippingmethods table and then fetched from db it gets automatically set. When Postie creates a new ShippingMethod it does not set the value of this field and so CP gets broken.
Describe the bug
Cannot open any order for edit in cp, reason:
craft\commerce\services\Stores::getStoreById(): Argument #1 ($id) must be of type int, null given, called in /var/www/html/vendor/craftcms/commerce/src/base/StoreTrait.php on line 28
The issue is that base
ShippingMethod
class implementsStoreTrait
and it expects to have$storeId
set, in commerce plugin they storestoreId
in thecommerce_shippingmethods
table and then fetched from db it gets automatically set. When Postie creates a newShippingMethod
it does not set the value of this field and so CP gets broken.Setting a dummy
$shippingMethod->storeId = 1;
in https://github.com/verbb/postie/blob/ff43ed6d51f3ef22acfa86c7ac3712019da9d7c2/src/services/Providers.php#L375 fixes CP, need to find a way to get the correct store id and set it.Commerce 5.0.11
Steps to reproduce
Setup craft + commerce + postie add a dummy Provider, now create a dummy order and try to open it in CP.
Craft CMS version
5.2.2
Plugin version
5.0.1
Multi-site?
Yes
Additional context
No response