I am using rest/all/V1/products/:SKU API for fetching product details. Now issue I am facing is that i wanted to add one custom data in this API response.

I wanted to append "SellerID" custom data along with product details which I am getting from API. I tried some solutions but not able to add it in the response. Can any one help me to append seller id in product response ?

1 Answer 1


For that purposes Magento proposed the ExtensionAttributes. Add your data to the product extension attributes in etc/extension_attributes.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
        <attribute code="seller_id" type="string" />

write a plugin which add this value to the products data:

    /** @var \Magento\Catalog\Api\Data\ProductExtensionInterface $extension */
    $extension = $item->getExtensionAttributes();
    if ($extension === null) {
        $extension = $this->extensionFactory->create();

and you can see your data in the response in extension_attributes section of the product.

  • I stored extension attribute using Magento\Sales\Api\Data\ShipmentCreationArgumentsInterface in sales_shipment table but now I need to get that shipment extension data using shipmentId. so I tried Magento\Sales\Api\ShipmentRepositoryInterface after get method for add that extension data but i faced issue. so please help me. see my detailed question here magento.stackexchange.com/q/359113/93504 Aug 23, 2022 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.