Skip to main content

Posts

Showing posts from April, 2022

How to create a custom Rest API?

REST stands for representational state transfer and API stands for an application programming interface. REST API is basically used for performing some operations and getting responses based on the request using the HTTP protocol. Magento provides a huge list of REST APIs which you can check here . Another approach to check and play with the existing APIs in the Magento system is Swagger. You can access Swagger by any browser and the URL will be your website's baseUrl/swagger . Now let's see how we can add a new custom API in Magento. Let's learn this by creating a custom API to get all the store configurations using API.  Step - 1: Create a webApi.xml file and add the route for your API <?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 method="GET" url="/V1/custom/storeConfigurations/"...

How to apply the Security Patch in Magento?

Magento is a flexible, customizable open-source platform that has a huge number of inbuilt functionalities. Apart from having these advantages of open-source software, Magento has some drawbacks related to security threats and vulnerabilities. To resolve these threats Magento releases security patches from time to time. Security patches contain security fixes only. They are designed to make the upgrade process faster and easier. There are two ways to apply a security patch in Magento using: Command Line Composer Follow the below steps to apply security patches using Composer: Enable Maintenance Mode : It will prevent from customers placing unfulfillable orders. php bin/magento maintenance:enable Check running Cron Jobs : Wait for the currently working cron jobs. Once they are completed, turn off the services. Execute Composer Command : Security patches use the Composer naming convention  2.3.3-px . Use Composer to specify a patch. composer require magento/product-commun...

How to add Extension Attributes for customers in Magento 2?

Magento provides two types of attributes for entities. And here we going to learn how to add a new extension attribute in Magento. Please follow the below steps to add the extension attribute: Step 1: Add extension attribute Here we will add an extension attribute in extension_attributes.xml which resides under the etc folder of your custom module. For scalar attributes: <?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\Customer\Api\Data\CustomerInterface"> <attribute code="stripe_id" type="boolean" /> </extension_attributes> </config> Here, the scalar attributes indicate the simple form of attribute representation, such as an integer, a string, or a boolean. Specify the class or interface of the extension attributes insi...