How To

How to Get Product Information Using SOAP API in Magento 2

Hello Magento Friends,

I am here yet with another tutorial blog in accordance with SOAP API. Today we will learn about retrieving Product Information with the help of SOAP API in Magento 2.

Check up on other related guides

SOAP API is used when you want to link an external system with your Magento 2 site. It enables data transfer between the two. When you need to fetch product information outside your Magento 2 website, you can make use of SOAP API.

Let’s learn how to get product information using SOAP API in Magento 2.

Steps to Get Product Information Using SOAP API in Magento 2:

Step 1: Create call_soap.php file anywhere and add the following code

<?php
$request = new SoapClient("http://yourdomain/index.php/soap/?wsdl&services=integrationAdminTokenServiceV1", array("soap_version" => SOAP_1_2));
// changes your store url.
$token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken(array("username"=>"admin", "password"=>"admin@123"));

$request = new SoapClient(
    'http://yourdomain/index.php/soap/default?wsdl&services=catalogProductRepositoryV1',
    array(
        'soap_version' => SOAP_1_2,
        'stream_context' => stream_context_create(array(
            'http'=> array('header' => 'Authorization: Bearer '.$token->result)
        ))
    )
);
// changes your store url.
$serviceArgs = array('searchCriteria'=> 
        array('filterGroups' => 
            array ('filters' =>
                array('field' =>'sku',
                      'value' => '24-MB01' , 
                      'condition_type' => 'eq')
                )
         )
);
$response = $request->catalogProductRepositoryV1GetList($serviceArgs);
echo "<pre>";
print_r($response);

?>

Conclusion:

Hence, this way you can successfully receive product details through SOAP API in Magento 2. If you come across any error while applying the code, reach me via the comment section. Share the tutorial over your social media handles and stay with us for more Magento solutions.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

Recent Posts

Magento 2: How to Add View Button in Admin Grid to Open a View Page in Slide Window

Hello Magento Friends, In Magento 2, customizations to the admin panel can significantly enhance the…

13 hours ago

Magento 2: How to Observe the Multi-shipping Order Creation Event

Hello Magento Friends, Magento 2 provides a robust event-driven architecture that allows developers to observe…

3 days ago

Hyvä Theme FAQs

Hyvä is gradually gaining popularity in this current market, and even 3.5% of Magento websites…

4 days ago

What is Curbside Pickup?

In today’s fast-paced society, where convenience and safety are paramount, curbside pickup has emerged as…

4 days ago

What is a Planogram?

Have you ever observed how complementary and similar items are often displayed together in brick-and-mortar…

4 days ago

Hyvä Checkout – A Real Game Changer

You may be familiar with Hyvä, the frontend theme for Magento 2, which has been…

4 days ago