This commit is contained in:
rahul shukla 2021-01-08 19:02:17 +05:30
parent a419661b1e
commit 65627ceede
1 changed files with 35 additions and 30 deletions

View File

@ -15,47 +15,52 @@ class ComparisonController extends Controller
*/
public function getComparisonList()
{
if (request()->get('data')) {
$productSlugs = null;
if (! core()->getConfigData('general.content.shop.compare_option')) {
$productCollection = [];
abort(404);
} else {
if (request()->get('data')) {
$productSlugs = null;
if (auth()->guard('customer')->user()) {
$productCollection = $this->compareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
'product_flat.id'
)
->where('customer_id', auth()->guard('customer')->user()->id)
->get()
->toArray();
$productCollection = [];
$items = [];
if (auth()->guard('customer')->user()) {
$productCollection = $this->compareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
'product_flat.id'
)
->where('customer_id', auth()->guard('customer')->user()->id)
->get()
->toArray();
foreach ($productCollection as $index => $customerCompare) {
array_push($items, $customerCompare['id']);
}
$items = [];
$items = implode('&', $items);
$productCollection = $this->velocityHelper->fetchProductCollection($items);
foreach ($productCollection as $index => $customerCompare) {
array_push($items, $customerCompare['id']);
}
} else {
// for product details
if ($items = request()->get('items')) {
$items = implode('&', $items);
$productCollection = $this->velocityHelper->fetchProductCollection($items);
} else {
// for product details
if ($items = request()->get('items')) {
$productCollection = $this->velocityHelper->fetchProductCollection($items);
}
}
$response = [
'status' => 'success',
'products' => $productCollection,
];
} else {
$response = view($this->_config['view']);
}
$response = [
'status' => 'success',
'products' => $productCollection,
];
} else {
$response = view($this->_config['view']);
return $response;
}
return $response;
}
/**