chengwl 6 months ago
parent
commit
9168612202

+ 7 - 2
packages/Longyi/Core/src/Http/Controllers/Admin/FlexibleVariantController.php

@@ -214,8 +214,13 @@ class FlexibleVariantController extends Controller
      */
     public function getProductOptions(int $productId): JsonResponse
     {
-        $options = $this->flexibleVariantHelper->getProductOptions($productId);
-
+        $this->initProduct($productId);
+        $options = $this->_product->options()
+            ->with('values', function ($query) {
+                $query->whereHas('variants', function ($relation) {
+                    $relation->whereIn($relation->getModel()->getTable().'.id', $this->_product->variants()->pluck('id'));
+                });
+            });
         return response()->json([
             'success' => true,
             'data' => $options,