|
@@ -214,13 +214,19 @@ class FlexibleVariantController extends Controller
|
|
|
*/
|
|
*/
|
|
|
public function getProductOptions(int $productId): JsonResponse
|
|
public function getProductOptions(int $productId): JsonResponse
|
|
|
{
|
|
{
|
|
|
- $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'));
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $options=$this->flexibleVariantHelper->getAvailableOptions($productId);
|
|
|
|
|
+ // $this->initProduct($productId);
|
|
|
|
|
+ // $options = $this->_product->options()
|
|
|
|
|
+ // ->with('values', function ($query) {
|
|
|
|
|
+ // $query->whereHas('variants', function ($relation) {
|
|
|
|
|
+ // // dd($relation->getModel()->getTable());exit;
|
|
|
|
|
+ // $relation->whereIn($relation->getModel()->getTable().'.id', $this->_product->variants()->pluck('id'));
|
|
|
|
|
+ // });
|
|
|
|
|
+ // })->toSql();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return response()->json([
|
|
return response()->json([
|
|
|
'success' => true,
|
|
'success' => true,
|
|
|
'data' => $options,
|
|
'data' => $options,
|
|
@@ -407,7 +413,7 @@ class FlexibleVariantController extends Controller
|
|
|
|
|
|
|
|
$variantIds=collect($variants)->pluck('id');
|
|
$variantIds=collect($variants)->pluck('id');
|
|
|
//删除无用的变体
|
|
//删除无用的变体
|
|
|
- $this->_product->variants()->whereNotIn('id', $variantIds)->delete();
|
|
|
|
|
|
|
+ $this->_product->flexibleVariants()->whereNotIn('id', $variantIds)->delete();
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
return response()->json([
|
|
return response()->json([
|
|
|
'success' => true,
|
|
'success' => true,
|