diff --git a/packages/Sarga/API/Http/Resources/Catalog/ProductVariant.php b/packages/Sarga/API/Http/Resources/Catalog/ProductVariant.php index 8130e055a..5194bc4b6 100644 --- a/packages/Sarga/API/Http/Resources/Catalog/ProductVariant.php +++ b/packages/Sarga/API/Http/Resources/Catalog/ProductVariant.php @@ -53,20 +53,22 @@ class ProductVariant extends JsonResource private function super_attributes(){ if(is_countable($this->attributes)){ return $this->attributes->map(function($item, $key){ + $option = $item->options()->where('id',$this->{$item->code})->first(); return [ 'code' => $item->id, 'value' => $this->{$item->code}, 'name' => $item->name??$item->admin_name, - 'label' => $item->options->where('id',$this->{$item->code})->first()->admin_name + 'label' => $option->admin_name, ]; })->toArray(); }else{ $item = $this->attributes; + $option = $item->options()->where('id',$this->{$item->code})->first(); return [ 'code' => $item->id, 'value' => $this->{$item->code}, 'name' => $item->name??$item->admin_name, - 'label' => $item->options->where('id',$this->{$item->code})->first()->admin_name + 'label' => $option->admin_name, ]; }