main screen categories and products

This commit is contained in:
merdan 2022-01-20 18:01:24 +05:00
parent a88d02f7f0
commit 47a36585ca
2 changed files with 25 additions and 3 deletions

View File

@ -23,6 +23,7 @@ class ProductRepository extends WProductRepository
protected $productFlatRepository;
protected $attributeValueRepository;
protected $imageRepository;
protected $vendorProductRepository;
protected $fillableTypes = ['sku', 'name', 'url_key', 'short_description', 'description', 'price', 'weight', 'status'];
public function __construct(AttributeRepository $attributeRepository,
App $app,
@ -30,6 +31,7 @@ class ProductRepository extends WProductRepository
ProductFlatRepository $productFlatRepository,
ProductAttributeValueRepository $productAttributeValueRepository,
ProductImageRepository $productImageRepository,
VendorProductRepository $vendorProductRepository,
AttributeOptionRepository $optionRepository)
{
$this->attributeGroupRepo = $attributeGroupRepo;
@ -37,6 +39,7 @@ class ProductRepository extends WProductRepository
$this->attributeValueRepository = $productAttributeValueRepository;
$this->productFlatRepository = $productFlatRepository;
$this->imageRepository = $productImageRepository;
$this->vendorProductRepository = $vendorProductRepository;
parent::__construct($attributeRepository, $app);
}
@ -282,8 +285,7 @@ class ProductRepository extends WProductRepository
public function createSellerProduct($product, $seller_id){
Event::dispatch('marketplace.catalog.product.create.before');
$sellerProduct = parent::create([
$sellerProduct = $this->vendorProductRepository->create([
'marketplace_seller_id' => $seller_id,
'is_approved' => 1,
'condition' => 'new',
@ -293,7 +295,7 @@ class ProductRepository extends WProductRepository
]);
foreach ($sellerProduct->product->variants as $baseVariant) {
parent::create([
$this->vendorProductRepository->create([
'parent_id' => $sellerProduct->id,
'product_id' => $baseVariant->id,
'is_owner' => 1,

View File

@ -0,0 +1,20 @@
<?php
namespace Sarga\API\Repositories;
use Illuminate\Container\Container as App;
use Webkul\Core\Eloquent\Repository;
class VendorProductRepository extends Repository
{
public function __construct(
App $app
){
parent::__construct($app);
}
public function model()
{
return 'Webkul\Marketplace\Contracts\Product';
}
}