-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PHP error when editing inventory level in modal
- Loading branch information
1 parent
7f12e65
commit 73b35ed
Showing
2 changed files
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,20 +52,25 @@ class InventoryItem extends Model | |
*/ | ||
public ?\DateTime $dateUpdated = null; | ||
|
||
public function getCpEditUrl(): string | ||
{ | ||
return UrlHelper::cpUrl('commerce/inventory/item/' . $this->id); | ||
} | ||
|
||
/** | ||
* @var Purchasable|null | ||
*/ | ||
private ?Purchasable $_purchasable = null; | ||
/** | ||
* @return ?Purchasable | ||
* @var null|string|int $siteId | ||
*/ | ||
public function getPurchasable(): ?Purchasable | ||
public function getPurchasable(null|string|int $siteId = null): ?Purchasable | ||
Check failure on line 64 in src/models/InventoryItem.php GitHub Actions / ci / Code Quality / PHPStan / PHPStan
|
||
{ | ||
if ($this->_purchasable !== null) { | ||
return $this->_purchasable; | ||
} | ||
|
||
/** @var ?Purchasable $purchasable */ | ||
$purchasable = \Craft::$app->getElements()->getElementById($this->purchasableId); | ||
$this->_purchasable = \Craft::$app->getElements()->getElementById(elementId: $this->purchasableId, siteId: $siteId); | ||
Check failure on line 71 in src/models/InventoryItem.php GitHub Actions / ci / Code Quality / PHPStan / PHPStan
Check failure on line 71 in src/models/InventoryItem.php GitHub Actions / ci / Code Quality / PHPStan / PHPStan
|
||
|
||
return $purchasable; | ||
return $this->_purchasable; | ||
Check failure on line 73 in src/models/InventoryItem.php GitHub Actions / ci / Code Quality / PHPStan / PHPStan
|
||
} | ||
|
||
public function getSku(): string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,9 +129,11 @@ public function getInventoryLocation(): InventoryLocation | |
|
||
/** | ||
* @return Purchasable | ||
* @var null|string|int $siteId | ||
*/ | ||
public function getPurchasable(): Purchasable | ||
public function getPurchasable(null|string|int $siteId = null): Purchasable | ||
Check failure on line 134 in src/models/InventoryLevel.php GitHub Actions / ci / Code Quality / PHPStan / PHPStan
|
||
{ | ||
return $this->getInventoryItem()->getPurchasable(); | ||
|
||
return $this->getInventoryItem()->getPurchasable($siteId); | ||
} | ||
} |