product detail

This commit is contained in:
merdan 2023-04-30 12:19:20 +05:00
parent 02e5800e45
commit 6efb95c6d4
2 changed files with 23 additions and 2 deletions

View File

@ -76,12 +76,32 @@ class Products extends ProductController
// return $product;
Log::info($product);
return ProductDetail::make($product);
}
public function testProduct($id){
$product = $this->productRepository->select('id','attribute_family_id','type','brand_id')
->with(['brand','related_products'=> fn($rp) => $rp->select('id','type','attribute_family_id','brand_id')->with('brand'),
'variants' => function($query){
$query->with(['product_flats' => function($qf){
$channel = core()->getRequestedChannelCode();
$locale = 'tm';//core()->getRequestedLocaleCode();
$qf->where('product_flat.channel', $channel)
->where('product_flat.locale', $locale)
// ->whereNotNull('product_flat.url_key')
->where('product_flat.status',1);
}]);
}])->find($id);
return $product;
// return ProductDetail::make($product);
}
public function variants($id)
{
$product = $this->productRepository->with(['super_attributes:id,code','variants'=>function($query)

View File

@ -62,6 +62,7 @@ Route::group(['prefix' => 'api'], function () {
Route::get('suggestions', [\Sarga\API\Http\Controllers\SearchController::class, 'index'])->middleware('cacheResponse:1200');
Route::get('products/{id}', [Products::class, 'get']);
Route::get('product/{id}', [Products::class, 'product'])->middleware('cacheResponse:60');
Route::get('product_test/{id}', [Products::class, 'testPproduct']);
Route::get('products/{id}/variants', [Products::class, 'variants']);
Route::get('states', [ResourceController::class, 'index'])->defaults('_config', [