Skip to content

Rest API: Call to a member function getVideoProvider() on null #40021

Open
@its-leofisher

Description

@its-leofisher

Preconditions and environment

  • Magento 2.4.7 v6

Steps to reproduce

  • Create a configurable with a simple child product
  • add a YouTube Video to the child product (other images not necessary)
  • Click Save, validate the video is there
  • Generate oauth keys in integration
  • Perform a call to /index.php/rest/V1/configurable-products/<configsku>/children
  • Observe error in logs: Call to a member function getVideoProvider() on null [] []

Related files:

This is where media gallery entries are generated for child products
vendor/magento/module-configurable-product/Model/LinkManagement.php within getChildren($sku)

Error is thrown in:
\Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter::convertFrom

Expected result

Payload contains child products are returned and media gallery entries are populated per usual, an example for the video:

{
        "id": 8888,
        "sku": "1234456",
        "name": "Sample Product Name",
        "attribute_set_id": 0,
        "price": 555.55,
        "status": 1,
        "visibility": 1,
        "type_id": "simple",
        "created_at": "2025-06-25 00:56:01",
        "updated_at": "2025-06-25 20:46:21",
        "weight": 1.11,
        "product_links": [],
        "media_gallery_entries": [
            {
                "id": 123456,
                "media_type": "image",
                "label": null,
                "position": null,
                "disabled": false,
                "types": [],
                "file": "/5555/019/5555_019_01.jpg"
            },
            {
                "id": 11111,
                "media_type": "external-video",
                "label": null,
                "position": 3,
                "disabled": false,
                "types": [],
                "file": "/b/h/bhdefault_9.jpg",
                "extension_attributes": {
                    "video_content": {
                        "media_type": "external-video",
                        "video_provider": "",
                        "video_url": "https://www.youtube.com/watch?v=dGEIsnBRWGs",
                        "video_title": "Title of the Video",
                        "video_description": "Description of the video",
                        "video_metadata": ""
                    }
                }
            }
        ],
        "tier_prices": [],
        "custom_attributes": [
            {
                "attribute_code": "required_options",
                "value": "0"
            },
            {
                "attribute_code": "has_options",
                "value": "0"
            },
            {
                "attribute_code": "url_key",
                "value": "url-to-thechild-1"
            },
            {
                "attribute_code": "category_ids",
                "value": []
            },
            {
                "attribute_code": "discontinued",
                "value": "0"
            },
            {
                "attribute_code": "links_exist",
                "value": "0"
            },
            {
                "attribute_code": "image",
                "value": "/5/9/5555.jpg"
            },
            {
                "attribute_code": "small_image",
                "value": "/5/9/55355.jpg"
            },
            {
                "attribute_code": "thumbnail",
                "value": "/5/9/55555.jpg"
            },
            {
                "attribute_code": "msrp_display_actual_price_type",
                "value": "4"
            },
            {
                "attribute_code": "tax_class_id",
                "value": "34"
            },
        ]
    },

Actual result

API returns 500 Internal Server Error:

Magento 2.4.7 v6
Logs display
[2025-06-24T23:44:19.945079+00:00] report.ERROR: 123.123.123.123 - /index.php/rest/V1/configurable-products/5555/children - Call to a member function getVideoProvider() on null [] []

Magento 2.4.7 - Vanilla

Image

Additional information

Potential solution (and I tested that it works) reported by @rhoerr:
klevu/metadata#25 (comment)

Index: vendor/magento/module-configurable-product/Model/LinkManagement.php
Index: vendor/magento/module-configurable-product/Model/LinkManagement.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Model/LinkManagement.php b/Model/LinkManagement.php
--- a/Model/LinkManagement.php
+++ b/Model/LinkManagement.php	(date 1734643949188)
@@ -119,9 +119,7 @@
                     $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(
@@ -129,6 +127,7 @@
                 $attributes,
                 \Magento\Catalog\Api\Data\ProductInterface::class
             );
+            $productDataObject->setMediaGalleryEntries($child->getMediaGalleryEntries());
             $childrenList[] = $productDataObject;
         }
         return $childrenList;

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkComponent: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Reported on 2.4.7-p6Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions