Category: Magento 2

Registry and Register in Magento 2

Registry and Register in Magento 2 Registry: The Registry in Magento 2 is an instance of \Magento\Framework\Registry class. It allows you to store and retrieve data using a key-based approach. Storing Data: use Magento\Framework\Registry; $registry = $objectManager->get(Registry::class); $registry->register(‘key_name’, $value); Retrieving Data: $data = $registry->registry(‘key_name’); Register: The Register in Magento 2 is an instance of \Magento\Framework\RegisterInterface […]

Read More

Magento 2 Rest API Authentication

Magento 2 Rest API Authentication Magento 2 Rest API Three types of API Authentication. Token based authentication OAUTH based authentication Session Based Authentication 1.Token based authentication Customer token : Base_Url/V1/integration/customer/token Method Type: POST Hit url by POSTMAN Body payload : raw { “username”:”test”, “password”:”test” } ——————————- Admin Token : /V1/integration/admin/token Method Type: POST Hit url […]

Read More

Custom rest api event observer confliction Magento2

Custom rest api event observer confliction Magento2 Custom rest api we need to define event and plugins under webapi_rest folder. In this way it will not conflict default features. Vendor/Module/etc/webapi_rest/events.xml <?xml version=”1.0″ ?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Event/etc/events.xsd”> <event name=”sales_model_service_quote_submit_before”> <observer instance=”vendor\module\Observer\Order\Observerclass” name=”events_change”/> </event> </config> namespace vendor\module\Observer\Order; use Magento\Quote\Model\QuoteRepository; use Psr\Log\LoggerInterface; class Observerclass implements \Magento\Framework\Event\ObserverInterface { protected […]

Read More

Rest API Magento 2 Product list by Postman

Rest API Magento 2 Product list by Postman Get product list need to create simple module usign api,model,webapi.xml and di.xml Create method in api class. <?php namespace Vendor\Module\Api; /** * Interface ProductStockInterface */ interface ProductDataInterface { /** * get products. * * @return array */ public function getProData(); } Create webapi.xml under etc folder webapi.xml […]

Read More