|
|
@@ -20,6 +20,7 @@ use Webkul\Category\Models\CategoryProxy;
|
|
|
use Webkul\Core\Models\ChannelProxy;
|
|
|
use Webkul\Inventory\Models\InventorySourceProxy;
|
|
|
use Webkul\Product\Contracts\Product as ProductContract;
|
|
|
+use Longyi\Core\Models\ProductOption;
|
|
|
use Webkul\Product\Database\Factories\ProductFactory;
|
|
|
use Webkul\Product\Type\AbstractType;
|
|
|
|
|
|
@@ -292,6 +293,17 @@ class Product extends Model implements ProductContract
|
|
|
return $this->belongsToMany(ChannelProxy::modelClass(), 'product_channels', 'product_id', 'channel_id');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * The flexible variant options that belong to the product.
|
|
|
+ */
|
|
|
+ public function options(): BelongsToMany
|
|
|
+ {
|
|
|
+ return $this->belongsToMany(ProductOption::class, 'product_product_options', 'product_id', 'product_option_id')
|
|
|
+ ->withPivot(['position', 'is_required', 'meta'])
|
|
|
+ ->withTimestamps()
|
|
|
+ ->orderBy('product_product_options.position');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Is saleable.
|
|
|
*
|