Issue #3571
This commit is contained in:
parent
c3831e7033
commit
1ba0eccd5d
|
|
@ -5,6 +5,7 @@ namespace Webkul\Product\Helpers;
|
|||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Product\Models\ProductAttributeValue;
|
||||
use Webkul\Product\Facades\ProductImage;
|
||||
use Webkul\Product\Facades\ProductVideo;
|
||||
|
||||
class ConfigurableOption extends AbstractProduct
|
||||
{
|
||||
|
|
@ -50,6 +51,7 @@ class ConfigurableOption extends AbstractProduct
|
|||
],
|
||||
'variant_prices' => $this->getVariantPrices($product),
|
||||
'variant_images' => $this->getVariantImages($product),
|
||||
'variant_videos' => $this->getVariantVideos($product),
|
||||
'chooseText' => trans('shop::app.products.choose-option'),
|
||||
];
|
||||
|
||||
|
|
@ -211,4 +213,27 @@ class ConfigurableOption extends AbstractProduct
|
|||
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product videos for configurable variations
|
||||
*
|
||||
* @param \Webkul\Product\Contracts\Product|\Webkul\Product\Contracts\ProductFlat $product
|
||||
* @return array
|
||||
*/
|
||||
protected function getVariantVideos($product)
|
||||
{
|
||||
$videos = [];
|
||||
|
||||
foreach ($this->getAllowedProducts($product) as $variant) {
|
||||
if ($variant instanceof \Webkul\Product\Models\ProductFlat) {
|
||||
$variantId = $variant->product_id;
|
||||
} else {
|
||||
$variantId = $variant->id;
|
||||
}
|
||||
|
||||
$videos[$variantId] = ProductVideo::getVideos($variant);
|
||||
}
|
||||
|
||||
return $videos;
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +304,11 @@
|
|||
});
|
||||
|
||||
if (this.simpleProduct) {
|
||||
this.config.variant_images[this.simpleProduct].forEach(function(image) {
|
||||
this.config.variant_images[this.simpleProduct].forEach(function(video) {
|
||||
galleryImages.unshift(video)
|
||||
});
|
||||
|
||||
this.config.variant_videos[this.simpleProduct].forEach(function(image) {
|
||||
galleryImages.unshift(image)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,6 +318,10 @@
|
|||
});
|
||||
|
||||
if (this.simpleProduct) {
|
||||
this.config.variant_images[this.simpleProduct].forEach(function(video) {
|
||||
galleryImages.unshift(video)
|
||||
});
|
||||
|
||||
this.config.variant_images[this.simpleProduct].forEach(function(image) {
|
||||
galleryImages.unshift(image)
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue