Add getting product details extra method

This commit is contained in:
Shohrat 2023-09-14 14:15:29 +05:00
parent ef1264c359
commit 20dd5c59f7
3 changed files with 12 additions and 2 deletions

View File

@ -91,6 +91,12 @@ class Vendors extends V1Controller
return ProductResource::collection($products);
}
public function sellerProductsById(ProductRepository $productRepository,$seller_id, $product_id){
$products = $productRepository->findAllBySellerNotActive($seller_id,request()->input('category_id'), $product_id);
return ProductResource::collection($products);
}
public function vendor($seller_id){
$vendor = $this->vendorRepository->select('marketplace_sellers.id','url','logo','banner','shop_title', 'ship_time','ship_price','slogan')
->where('id',$seller_id)

View File

@ -41,6 +41,7 @@ Route::group(['prefix' => 'api'], function () {
Route::post('order', [SellerProduct::class, 'sellerOrderDetail']);
Route::get('products/{vendor_id}',[Vendors::class,'sellerProducts']);
Route::get('products/{vendor_id}/{product_id}',[Vendors::class,'sellerProductsById']);
Route::post('create/product', [SellerProduct::class, 'storeSellerProd']);
Route::post('update/product', [SellerProduct::class, 'updateProductFlat']);
});

View File

@ -502,11 +502,11 @@ class ProductRepository extends WProductRepository
* @param integer $seller
* @return Collection
*/
public function findAllBySellerNotActive($seller_id,$category_id = null)
public function findAllBySellerNotActive($seller_id, $category_id = null, $product_id = null)
{
$params = request()->input();
$results = app('Webkul\Product\Repositories\ProductFlatRepository')->scopeQuery(function($query) use($seller_id, $params,$category_id) {
$results = app('Webkul\Product\Repositories\ProductFlatRepository')->scopeQuery(function($query) use($seller_id, $params,$category_id, $product_id) {
$channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
$locale = request()->get('locale') ?: app()->getLocale();
@ -535,6 +535,9 @@ class ProductRepository extends WProductRepository
if ($category_id) {
$qb->whereIn('product_categories.category_id', explode(',', $category_id));
}
if ($product_id) {
$qb->where('products.id', $product_id);
}
if (isset($params['new'])){
$qb->where('product_flat.new', $params['new']);
}