What are the naming conventions, and how are namespaces established? The root Magento directory contains these primary folders: app/code: where your custom modules are found. Hopefully, very few 3rd- party modules are installed here because it is difficult to remember to keep these up-to-date. Installing modules through Composer provides the module vendor with an easier…
Author: Bikash
How to use Configuration Files in Magento 2
A module’s configuration files are stored in your modules etc/ directory, like app/code/Kaushik/HelloWorld/etc/. In there, you will find several important files. Many of these files can be found in a module’s etc/ directory. However, you sequester these to a particular area (frontend, adminhtml, webapi_rest, as a couple of examples). This is useful if you want…
Magento 2 Send bulk emails using SendGrid API
Here in this post, I’m going to show how you can send bulk transactional emails programmatically using SendGrid API & an email template created in Magento. Before getting started, let’s understand the used table’s role in this script. customer_data_live => here we have a list of customers’ emails with an email sent flag. block_email =>…
Magento 2 admin token using Rest API & CURL
Magento access token is used to synchronize and work with any third-party applications. Using the Magento Rest API provided, you can create, authenticate, and remove a token and its access. ************* curl POST HTTP token authentication **************** curl -XPOST -H ‘Content-Type: application/json’ http://magento231.local/rest/V1/integration/admin/token -d ‘{ “username”: “admin”, “password”: “admin@123” }’ ************* curl GET HTTP token…
Manage Fastly VCL snippets using the API
Delete a snippet 1. Save Fastly service credentials as bash environment variables export FASTLY_SERVICE_ID=<Service ID> export FASTLY_API_TOKEN=<API Token> 2. Check active VCL version curl -H “Fastly-Key: $FASTLY_API_TOKEN” https://api.fastly.com/service/$FASTLY_SERVICE_ID/version/active 3. Save active version number returned in the “number” key export FASTLY_VERSION_ACTIVE=<version> 4. Clone active VCL version and all snippets curl -H “Fastly-Key: $FASTLY_API_TOKEN” https://api.fastly.com/service/$FASTLY_SERVICE_ID/version/$FASTLY_VERSION_ACTIVE/clone -X PUT 5. Save the…
How to redirect to previous page in Magento 2
In Magento 2, You can redirect to the previous page. This allows customers to redirect back to the page from where the customer came. In Your Controller write the following code: <?php namespace Company\Module\Controller\Index; use Magento\Framework\Controller\ResultFactory; class Actionname name extends \Magento\Framework\App\Action\Action { public function execute() { $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); //your code work around here $resultRedirect->setUrl($this->_redirect->getRefererUrl());…
Useful Git Commands
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Here are some of git useful commands that you can use frequently on Github bash. git remote -v git remote remove origin git remote add origin Bitbucket_Repository_URL git diff –stat –cached…
How to use Dependency Injection (DI) in Magento 2
Dependency injection is the idea that a class is given the classes that it needs in the __construct method. Magento uses constructor dependency injection. In your __construct method, you list classes that you want to be injected and Magento’s DI system will do that for you. public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ){ $this->scopeConfig = $scopeConfig;…