Is it possible to add custom data in magento 2 rest API?Getting full image url for products via REST APIMagento 2: REST API not returning data for orders using CRON?How to reduce the API response time using Magento-2Fetching all the cross sell product using rest apiMagento2: How to create custom API to get all product details of specific category?Create configurable product using rest api magento 2.2.6How to specific pass fields in custom rest api for get product InformationMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response APIMagento 2.3 - How to Get product-salable-quantity using REST API?Magento 2 : how to add additional information in rest API response?
How to play vs. 1.e4 e5 2.Nf3 Nc6 3.Bc4 d6?
Was Tyrion always a poor strategist?
How could the B-29 bomber back up under its own power?
What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
Statue Park: Five
Do most Taxis give Receipts in London?
Eigenvalues of the Laplace-Beltrami operator on a compact Riemannnian manifold
What causes a person to remain in this world as a ghost?
Do 'destroy' effects count as damage?
Farthing / Riding
Requirement for splicing neutrals in a switch
Way of refund if scammed?
Circuit construction for execution of conditional statements using least significant bit
How do you cope with rejection?
Why does an injection from a set to a countable set imply that set is countable?
How to use Screen Sharing if I don't know the remote Mac's IP address
400–430 degrees Celsius heated bath
Separate the element after every 2nd ',' and push into next row in bash
How to become an Editorial board member?
Do seaplanes need to get clearance for takeoff?
Hotel booking: Why is Agoda much cheaper than booking.com?
Is my company merging branches wrong?
How could Dwarves prevent sand from filling up their settlements
Is it possible to add custom data in magento 2 rest API?
Getting full image url for products via REST APIMagento 2: REST API not returning data for orders using CRON?How to reduce the API response time using Magento-2Fetching all the cross sell product using rest apiMagento2: How to create custom API to get all product details of specific category?Create configurable product using rest api magento 2.2.6How to specific pass fields in custom rest api for get product InformationMagento 2 REST - SKU to items on cart totals API response is not available, How to get SKU in response APIMagento 2.3 - How to Get product-salable-quantity using REST API?Magento 2 : how to add additional information in rest API response?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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 ?
magento2 rest-api integration
New contributor
add a comment |
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 ?
magento2 rest-api integration
New contributor
add a comment |
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 ?
magento2 rest-api integration
New contributor
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 ?
magento2 rest-api integration
magento2 rest-api integration
New contributor
New contributor
New contributor
asked May 14 at 11:55
MagenewstudentMagenewstudent
111
111
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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="MagentoCatalogApiDataProductInterface">
<attribute code="seller_id" type="string" />
</extension_attributes>
</config>
write a plugin which add this value to the products data:
/** @var MagentoCatalogApiDataProductExtensionInterface $extension */
$extension = $item->getExtensionAttributes();
if ($extension === null)
$extension = $this->extensionFactory->create();
$extension->setSellerId($item->getData('seller_id'));
$item->setExtensionAttributes($extension);
and you can see your data in the response in extension_attributes
section of the product.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Magenewstudent is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274540%2fis-it-possible-to-add-custom-data-in-magento-2-rest-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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="MagentoCatalogApiDataProductInterface">
<attribute code="seller_id" type="string" />
</extension_attributes>
</config>
write a plugin which add this value to the products data:
/** @var MagentoCatalogApiDataProductExtensionInterface $extension */
$extension = $item->getExtensionAttributes();
if ($extension === null)
$extension = $this->extensionFactory->create();
$extension->setSellerId($item->getData('seller_id'));
$item->setExtensionAttributes($extension);
and you can see your data in the response in extension_attributes
section of the product.
add a comment |
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="MagentoCatalogApiDataProductInterface">
<attribute code="seller_id" type="string" />
</extension_attributes>
</config>
write a plugin which add this value to the products data:
/** @var MagentoCatalogApiDataProductExtensionInterface $extension */
$extension = $item->getExtensionAttributes();
if ($extension === null)
$extension = $this->extensionFactory->create();
$extension->setSellerId($item->getData('seller_id'));
$item->setExtensionAttributes($extension);
and you can see your data in the response in extension_attributes
section of the product.
add a comment |
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="MagentoCatalogApiDataProductInterface">
<attribute code="seller_id" type="string" />
</extension_attributes>
</config>
write a plugin which add this value to the products data:
/** @var MagentoCatalogApiDataProductExtensionInterface $extension */
$extension = $item->getExtensionAttributes();
if ($extension === null)
$extension = $this->extensionFactory->create();
$extension->setSellerId($item->getData('seller_id'));
$item->setExtensionAttributes($extension);
and you can see your data in the response in extension_attributes
section of the product.
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="MagentoCatalogApiDataProductInterface">
<attribute code="seller_id" type="string" />
</extension_attributes>
</config>
write a plugin which add this value to the products data:
/** @var MagentoCatalogApiDataProductExtensionInterface $extension */
$extension = $item->getExtensionAttributes();
if ($extension === null)
$extension = $this->extensionFactory->create();
$extension->setSellerId($item->getData('seller_id'));
$item->setExtensionAttributes($extension);
and you can see your data in the response in extension_attributes
section of the product.
answered May 14 at 12:45
Siarhey UchukhlebauSiarhey Uchukhlebau
10.3k93058
10.3k93058
add a comment |
add a comment |
Magenewstudent is a new contributor. Be nice, and check out our Code of Conduct.
Magenewstudent is a new contributor. Be nice, and check out our Code of Conduct.
Magenewstudent is a new contributor. Be nice, and check out our Code of Conduct.
Magenewstudent is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274540%2fis-it-possible-to-add-custom-data-in-magento-2-rest-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown