|
|
@@ -69,11 +69,14 @@ class FlexibleVariantController extends Controller
|
|
|
$this->productRepository = $productRepository;
|
|
|
$this->flexibleVariantHelper = $flexibleVariantHelper;
|
|
|
//根据请求初始化产品信息
|
|
|
- $this->initProduct(request()->product_id ?? null);
|
|
|
+ // $this->initProduct(request()->product_id ?? null);
|
|
|
|
|
|
|
|
|
}
|
|
|
public function initProduct(int $productId){
|
|
|
+ if(!$productId){
|
|
|
+ $productId = request()->route('productId');
|
|
|
+ }
|
|
|
$this->_product = $this->productRepository->find($productId);
|
|
|
if (!$this->_product) {
|
|
|
throw new \Exception('Product not found');
|
|
|
@@ -306,7 +309,8 @@ class FlexibleVariantController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function saveVariants(Request $request){
|
|
|
+ public function saveVariants(int $productId,Request $request){
|
|
|
+ $this->initProduct($productId);
|
|
|
$this->validate($request,[
|
|
|
'selected_options' => 'array',
|
|
|
'selected_options.*.code' => 'required|string',
|