Good Morning!

I need to create an API that returns the maximum and minimum quantity of a product. What methods can I use?

  • Your question is not descriptive. Please elaborate it little bit more
    – Ajith
    May 14, 2021 at 19:43

1 Answer 1


You need to create first etc/webapi.xml


<?xml version="1.0" ?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
 <route url="/V1/plugin/abc/:productid" method="GET">
    <service class="Company\Plugin\Api\Product\ProductdetailIterface" method="getmaxminQty"/>
        <resource ref="anonymous"/>

Then create the Interface Company\Plugin\Api\Product\ProductdetailIterface and the method getmaxminqty

For the Implementation Create a class inside Company\Plugin\Model\Product\ProductDetail and add the method (Which you must implement because of Interface implementing) getmaxminqty

 public function getmaxminqty($productId)
  Your code


Create a di.xml inside etc and add this lines

<?xml version="1.0" ?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  <preference for="Company\Plugin\Api\Product\ProductdetailIterface" type="Company\Plugin\Model\Product\ProductDetail"/>

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.