diff --git a/vendor/magento/module-configurable-product/Model/LinkManagement.php b/vendor/magento/module-configurable-product/Model/LinkManagement.php index eda3bba4bbced..505bc031311d4 100644 --- a/vendor/magento/module-configurable-product/Model/LinkManagement.php +++ b/vendor/magento/module-configurable-product/Model/LinkManagement.php @@ -1,13 +1,22 @@ productRepository = $productRepository; $this->productFactory = $productFactory; $this->configurableType = $configurableType; $this->dataObjectHelper = $dataObjectHelper; - $this->attributeFactory = $attributeFactory ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory::class); - $this->mediaGallery = $mediaGalleryProcessor ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Catalog\Model\ProductRepository::class); - $this->myModelFactory = $myModelFactory ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class); - $this->optionsFactory = $optionsFactory ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\ConfigurableProduct\Helper\Product\Options\Factory::class); + $this->attributeFactory = $attributeFactory ?: ObjectManager::getInstance() + ->get(AttributeFactory::class); + $this->mediaGallery = $mediaGalleryProcessor ?: ObjectManager::getInstance() + ->get(ProductRepository::class); + $this->myModelFactory = $myModelFactory ?: ObjectManager::getInstance() + ->get(ProductAttributeMediaGalleryEntryInterfaceFactory::class); + $this->optionsFactory = $optionsFactory ?: ObjectManager::getInstance() + ->get(Factory::class); } /** @@ -102,10 +111,10 @@ public function getChildren($sku) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->productRepository->get($sku); - if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { + if ($product->getTypeId() != Product\Type\Configurable::TYPE_CODE) { return []; } - /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable $productTypeInstance */ + /** @var Product\Type\Configurable $productTypeInstance */ $productTypeInstance = $product->getTypeInstance(); $productTypeInstance->setStoreFilter($product->getStoreId(), $product); $childrenList = []; @@ -119,15 +128,12 @@ public function getChildren($sku) $attributes[$attrCode] = $value; } } - $images= (array)$child->getMediaGallery('images'); $attributes['store_id'] = $child->getStoreId(); - $attributes['media_gallery_entries'] = $this->getMediaEntries($images); - /** @var \Magento\Catalog\Api\Data\ProductInterface $productDataObject */ $productDataObject = $this->productFactory->create(); $this->dataObjectHelper->populateWithArray( - $productDataObject, + $productDataObject->setMediaGalleryEntries($child->getMediaGalleryEntries()), $attributes, - \Magento\Catalog\Api\Data\ProductInterface::class + ProductInterface::class ); $childrenList[] = $productDataObject; } @@ -139,6 +145,8 @@ public function getChildren($sku) * * @param array $images * @return array + * @deprecated This approach is designed only for images + * @see ProductInterface::getMediaGalleryEntries */ public function getMediaEntries(array $images): array { @@ -195,7 +203,7 @@ public function addChild($sku, $childSku) } $configurableOptionData = $this->getConfigurableAttributesData($attributeData); - /** @var \Magento\ConfigurableProduct\Helper\Product\Options\Factory $optionFactory */ + /** @var Factory $optionFactory */ $optionFactory = $this->optionsFactory; $options = $optionFactory->create($configurableOptionData); $childrenIds[] = $child->getId(); @@ -216,7 +224,7 @@ public function removeChild($sku, $childSku) { $product = $this->productRepository->get($sku); - if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { + if ($product->getTypeId() != Product\Type\Configurable::TYPE_CODE) { throw new InputException( __('The product with the "%1" SKU isn\'t a configurable product.', $sku) ); diff --git a/vendor/magento/module-product-video/Model/Product/Attribute/Media/ExternalVideoEntryConverter.php b/vendor/magento/module-product-video/Model/Product/Attribute/Media/ExternalVideoEntryConverter.php index 0650777423255..1b8e89ad59df5 100644 --- a/vendor/magento/module-product-video/Model/Product/Attribute/Media/ExternalVideoEntryConverter.php +++ b/vendor/magento/module-product-video/Model/Product/Attribute/Media/ExternalVideoEntryConverter.php @@ -1,7 +1,7 @@ getExtensionAttributes()->getVideoContent(); - $entryArray = [ - 'video_provider' => $videoContent->getVideoProvider(), - 'video_url' => $videoContent->getVideoUrl(), - 'video_title' => $videoContent->getVideoTitle(), - 'video_description' => $videoContent->getVideoDescription(), - 'video_metadata' => $videoContent->getVideoMetadata(), - ]; - $entryArray = array_merge($dataFromPreviewImageEntry, $entryArray); + if ($videoContent = $entry->getExtensionAttributes()->getVideoContent()) { + $entryArray = [ + 'video_provider' => $videoContent->getVideoProvider(), + 'video_url' => $videoContent->getVideoUrl(), + 'video_title' => $videoContent->getVideoTitle(), + 'video_description' => $videoContent->getVideoDescription(), + 'video_metadata' => $videoContent->getVideoMetadata(), + ]; + $entryArray = array_merge($dataFromPreviewImageEntry, $entryArray); + } else { + $entryArray = $dataFromPreviewImageEntry; + } return $entryArray; } }