api seller
This commit is contained in:
parent
54b5087afd
commit
bc37bad7be
|
|
@ -14,9 +14,16 @@ use Illuminate\Support\Str;
|
|||
use Webkul\Marketplace\Http\Controllers\Shop\Account\ProductController as SellerProductController;
|
||||
use Webkul\Product\Models\ProductFlat;
|
||||
use Webkul\Product\Models\ProductInventory;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
class SellerProduct extends SellerProductController
|
||||
{
|
||||
/**
|
||||
* Product repository instance.
|
||||
*
|
||||
* @var \Webkul\Product\Repositories\ProductRepository
|
||||
*/
|
||||
protected $productRepository;
|
||||
/**
|
||||
* SellerRepository object
|
||||
*
|
||||
|
|
@ -29,6 +36,24 @@ class SellerProduct extends SellerProductController
|
|||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* $categoryRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productAttributeValueRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
ProductRepository $productRepository,
|
||||
) {
|
||||
$this->_config = request('_config');
|
||||
$this->productRepository = $productRepository;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function storeSellerProd(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
|
@ -124,30 +149,50 @@ class SellerProduct extends SellerProductController
|
|||
|
||||
$prodId = $request->get('product_id');
|
||||
|
||||
$product = ProductFlat::where('product_id', $prodId)->first();
|
||||
\Log::info($product);
|
||||
if ($product) {
|
||||
$product->status = $request->get('status');
|
||||
$product->product_number = $request->get('product_number');
|
||||
$product->name = $request->get('name');
|
||||
$product->description = $request->get('description');
|
||||
// $product->url_key = Str::slug($request->get('name'));
|
||||
$product->new = $request->get('new');
|
||||
$product->featured = $request->get('featured');
|
||||
$product->status = $request->get('status');
|
||||
$product->price = $request->get('price');
|
||||
$product->special_price = $request->get('special_price');
|
||||
$product->weight = 0;
|
||||
$product->locale = 'tm';
|
||||
$product->channel = 'Nurgul';
|
||||
$product->short_description = $request->get('short_description');
|
||||
$product->save();
|
||||
} else {
|
||||
return response([
|
||||
'status' => 500,
|
||||
'message' => 'cant find product'
|
||||
]);
|
||||
}
|
||||
// $product = ProductFlat::where('product_id', $prodId)->first();
|
||||
|
||||
// \Log::info($product);
|
||||
|
||||
$data = array(
|
||||
"status" => $request->get('status'),
|
||||
"product_number" => $request->get('product_number'),
|
||||
"name" => $request->get('name'),
|
||||
"description" => $request->get('description'),
|
||||
"url_key" => Str::slug($request->get('name')),
|
||||
"featured" => $request->get('featured'),
|
||||
"status" => $request->get('status'),
|
||||
"price" => $request->get('price'),
|
||||
"special_price" => $request->get('special_price'),
|
||||
"weight" => 0,
|
||||
"locale" => 'tm',
|
||||
"channel" => 'Nurgul',
|
||||
"short_description" => $request->get('short_description')
|
||||
);
|
||||
|
||||
$product = $this->productRepository->update($data, $prodId, 'id');
|
||||
|
||||
// if ($product) {
|
||||
// $product->status = $request->get('status');
|
||||
// $product->product_number = $request->get('product_number');
|
||||
// $product->name = $request->get('name');
|
||||
// $product->description = $request->get('description');
|
||||
// // $product->url_key = Str::slug($request->get('name'));
|
||||
// $product->new = $request->get('new');
|
||||
// $product->featured = $request->get('featured');
|
||||
// $product->status = $request->get('status');
|
||||
// $product->price = $request->get('price');
|
||||
// $product->special_price = $request->get('special_price');
|
||||
// $product->weight = 0;
|
||||
// $product->locale = 'tm';
|
||||
// $product->channel = 'Nurgul';
|
||||
// $product->short_description = $request->get('short_description');
|
||||
// $product->save();
|
||||
// } else {
|
||||
// return response([
|
||||
// 'status' => 500,
|
||||
// 'message' => 'cant find product'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
$productInventory = ProductInventory::where('product_id', $prodId)->first();
|
||||
if ($productInventory) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Product extends JsonResource
|
|||
return [
|
||||
/* product's information */
|
||||
'id' => $product->id,
|
||||
// 'sku' => $product->sku,
|
||||
'sku' => $product->sku,
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'url_key' => $product->url_key,
|
||||
|
|
@ -54,6 +54,7 @@ class Product extends JsonResource
|
|||
//'logo' => $this->logo ? Storage::url($this->logo) : null,
|
||||
'new' => $this->new,
|
||||
'featured' => $this->featured,
|
||||
'qty' => $product->qty,
|
||||
// 'brand' => $product->brand->name ?? '',
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ProductRepository extends WProductRepository
|
|||
protected $vendorProductRepository;
|
||||
// protected $brandRepository;
|
||||
|
||||
protected $fillableTypes = ['sku', 'name', 'url_key', 'short_description', 'description', 'price', 'weight', 'status'];
|
||||
protected $fillableTypes = ['sku', 'name', 'url_key', 'short_description', 'description', 'price', 'weight', 'status', 'qty'];
|
||||
|
||||
public function __construct(AttributeRepository $attributeRepository,
|
||||
App $app,
|
||||
|
|
@ -521,6 +521,7 @@ class ProductRepository extends WProductRepository
|
|||
AND NOW( ) <= product_flat.special_price_to, IF( product_flat.special_price IS NULL OR product_flat.special_price = 0 , product_flat.price, LEAST( product_flat.special_price, product_flat.price ) ) , product_flat.price ) , IF( product_flat.special_price_from IS NULL , IF( product_flat.special_price_to IS NULL , IF( product_flat.special_price IS NULL OR product_flat.special_price = 0 , product_flat.price, LEAST( product_flat.special_price, product_flat.price ) ) , IF( NOW( ) <= product_flat.special_price_to, IF( product_flat.special_price IS NULL OR product_flat.special_price = 0 , product_flat.price, LEAST( product_flat.special_price, product_flat.price ) ) , product_flat.price ) ) , IF( product_flat.special_price_to IS NULL , IF( NOW( ) >= product_flat.special_price_from, IF( product_flat.special_price IS NULL OR product_flat.special_price = 0 , product_flat.price, LEAST( product_flat.special_price, product_flat.price ) ) , product_flat.price ) , product_flat.price ) ) ) AS price1'))
|
||||
|
||||
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
|
||||
// ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
|
||||
->leftJoin('marketplace_products', 'product_flat.product_id', '=', 'marketplace_products.product_id')
|
||||
->where('product_flat.visible_individually', 1)
|
||||
->where('product_flat.status', 1)
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class ProductFlat
|
|||
'locale' => $locale->code,
|
||||
]);
|
||||
}
|
||||
$productFlat->brand_id = $product->brand_id;
|
||||
// $productFlat->brand_id = $product->brand_id;
|
||||
foreach ($familyAttributes[$product->attribute_family->id] as $attribute) {
|
||||
if ($parentProduct && ! in_array($attribute->code, array_merge($superAttributes[$parentProduct->id], $this->fillableAttributeCodes))) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Product extends Model implements ProductContract
|
|||
'attribute_family_id',
|
||||
'sku',
|
||||
'parent_id',
|
||||
'brand_id'
|
||||
// 'brand_id'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue