File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,21 +50,25 @@ class ProductCurrencyPrice extends DataObject
5050
5151 public function canCreate ($ member = null , $ context = []): bool
5252 {
53- return $ this ->Product ()->canEdit ($ member );
53+ $ product = $ this ->Product ();
54+ return $ product && $ product ->exists () ? $ product ->canEdit ($ member ) : false ;
5455 }
5556
5657 public function canEdit ($ member = null ): bool
5758 {
58- return $ this ->Product ()->canEdit ($ member );
59+ $ product = $ this ->Product ();
60+ return $ product && $ product ->exists () ? $ product ->canEdit ($ member ) : false ;
5961 }
6062
6163 public function canDelete ($ member = null ): bool
6264 {
63- return $ this ->Product ()->canEdit ($ member );
65+ $ product = $ this ->Product ();
66+ return $ product && $ product ->exists () ? $ product ->canEdit ($ member ) : false ;
6467 }
6568
6669 public function canView ($ member = null ): bool
6770 {
68- return $ this ->Product ()->canView ($ member );
71+ $ product = $ this ->Product ();
72+ return $ product && $ product ->exists () ? $ product ->canView ($ member ) : false ;
6973 }
7074}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ final class ProductCurrencyPriceTest extends SapphireTest
2222 protected static $ fixture_file = __DIR__ . '/../Fixtures/shop.yml ' ;
2323
2424 /**
25- * @var SimpleCurrencyService
25+ * @var CurrencyService
2626 */
2727 private CurrencyService $ currencyService ;
2828
You can’t perform that action at this time.
0 commit comments