diff --git a/src/Models/Product.php b/src/Models/Product.php index 30d4469ce..8d00b1d4f 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -285,7 +285,7 @@ protected function url(): Attribute // or by any tier pricing. protected function price(): Attribute { - return Attribute::get(function () { + return Attribute::get(function ($value) { $customerGroupId = auth('magento-customer') ->user() ?->group_id ?: 0; @@ -295,7 +295,7 @@ protected function price(): Attribute ->firstWhere('customer_group_id', $customerGroupId); if ($price === null) { - return $this->getCustomAttribute('price')?->value; + return $value; } return $price->price ?: $price->min_price; diff --git a/src/Models/Traits/HasCustomAttributes.php b/src/Models/Traits/HasCustomAttributes.php index ac0682948..f597ddc38 100644 --- a/src/Models/Traits/HasCustomAttributes.php +++ b/src/Models/Traits/HasCustomAttributes.php @@ -203,4 +203,9 @@ protected function throwMissingAttributeExceptionIfApplicable($key) { return $this->getCustomAttribute($key); } + + protected function getAttributeFromArray($key) + { + return parent::getAttributeFromArray($key) ?? $this->getCustomAttribute($key); + } }