From ea66157655a2078771fd09b8249ee5d8dd5a33a5 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 19 Feb 2021 15:43:21 +0530 Subject: [PATCH] Issue #4645 fixed and product videos added in product api --- .../API/Http/Resources/Catalog/Product.php | 5 +++- .../Http/Resources/Catalog/ProductVideo.php | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 packages/Webkul/API/Http/Resources/Catalog/ProductVideo.php diff --git a/packages/Webkul/API/Http/Resources/Catalog/Product.php b/packages/Webkul/API/Http/Resources/Catalog/Product.php index ef7e1ed74..649e2c36f 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Product.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Product.php @@ -17,6 +17,8 @@ class Product extends JsonResource $this->productReviewHelper = app('Webkul\Product\Helpers\Review'); $this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist'); + + parent::__construct($resource); } /** @@ -45,7 +47,8 @@ class Product extends JsonResource 'formated_price' => core()->currency($productTypeInstance->getMinimalPrice()), 'short_description' => $product->short_description, 'description' => $product->description, - 'images' => ProductImageFacade::collection($product->images), + 'images' => ProductImage::collection($product->images), + 'videos' => ProductVideo::collection($product->videos), 'base_image' => ProductImageFacade::getProductBaseImage($product), 'created_at' => $product->created_at, 'updated_at' => $product->updated_at, diff --git a/packages/Webkul/API/Http/Resources/Catalog/ProductVideo.php b/packages/Webkul/API/Http/Resources/Catalog/ProductVideo.php new file mode 100644 index 000000000..c45239561 --- /dev/null +++ b/packages/Webkul/API/Http/Resources/Catalog/ProductVideo.php @@ -0,0 +1,23 @@ + $this->id, + 'type' => $this->type, + 'url' => $this->url + ]; + } +} \ No newline at end of file