This commit is contained in:
Shubham Mehrotra 2020-05-20 13:32:34 +05:30
parent 02faf5e610
commit 7aa860d173
1 changed files with 16 additions and 4 deletions

View File

@ -76,10 +76,22 @@ class ComparisonController extends Controller
if (! $compareProduct) {
// insert new row
$this->compareProductsRepository->create([
'customer_id' => $customerId,
'product_flat_id' => $productId,
]);
$productFlatRepository = app('\Webkul\Product\Models\ProductFlat');
$productFlat = $productFlatRepository
->where('product_id', $productId)
->get()
->first();
if ($productFlat) {
$productId = $productFlat->id;
$this->compareProductsRepository->create([
'customer_id' => $customerId,
'product_flat_id' => $productId,
]);
}
return response()->json([
'status' => 'success',