|
@@ -44,6 +44,17 @@ use Illuminate\Database\Eloquent\Model as EloquentModel;
|
|
|
)]
|
|
)]
|
|
|
class AttributeOption extends \Webkul\Attribute\Models\AttributeOption
|
|
class AttributeOption extends \Webkul\Attribute\Models\AttributeOption
|
|
|
{
|
|
{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Number of visible products associated with this option within the
|
|
|
|
|
+ * current category context. Populated by FilterableAttributesProvider.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Uses the Laravel accessor naming convention (get...Attribute) so that
|
|
|
|
|
+ * API Platform discovers it as a virtual attribute.
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getProductCountAttribute(): int
|
|
|
|
|
+ {
|
|
|
|
|
+ return (int) ($this->attributes['product_count'] ?? 0);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
#[ApiProperty(identifier: true, writable: false)]
|
|
#[ApiProperty(identifier: true, writable: false)]
|
|
|
public function getId(): ?int
|
|
public function getId(): ?int
|
|
@@ -63,14 +74,4 @@ class AttributeOption extends \Webkul\Attribute\Models\AttributeOption
|
|
|
return $this->translation;
|
|
return $this->translation;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Number of visible products associated with this option within the
|
|
|
|
|
- * current category context. Populated by FilterableAttributesProvider.
|
|
|
|
|
- */
|
|
|
|
|
- #[ApiProperty(writable: false, readable: true)]
|
|
|
|
|
- public function getProductCount(): int
|
|
|
|
|
- {
|
|
|
|
|
- return (int) ($this->product_count ?? 0);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|