From 47a36585cae97b6f1d8929e147039ef43c9733c9 Mon Sep 17 00:00:00 2001 From: merdan Date: Thu, 20 Jan 2022 18:01:24 +0500 Subject: [PATCH] main screen categories and products --- .../API/Repositories/ProductRepository.php | 8 +++++--- .../Repositories/VendorProductRepository.php | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 packages/Sarga/API/Repositories/VendorProductRepository.php diff --git a/packages/Sarga/API/Repositories/ProductRepository.php b/packages/Sarga/API/Repositories/ProductRepository.php index f12913a75..5d51fe7f7 100644 --- a/packages/Sarga/API/Repositories/ProductRepository.php +++ b/packages/Sarga/API/Repositories/ProductRepository.php @@ -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, diff --git a/packages/Sarga/API/Repositories/VendorProductRepository.php b/packages/Sarga/API/Repositories/VendorProductRepository.php new file mode 100644 index 000000000..9fc19b3f5 --- /dev/null +++ b/packages/Sarga/API/Repositories/VendorProductRepository.php @@ -0,0 +1,20 @@ +