Tag: Magento 2 Tutorials (page 9 of 10)

Magento 2 – How to Get Module, Controller, Action and Route Name

In this post I am going to explain how to get module, controller, action and route name in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_request; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\App\Request\Http $request, array $data = [] ) { $this->_request = $request; parent::__construct($context, $data); } public function getModuleName()…

Magento 2 – How to get Logo Height, Width, Image URL and Alt Text

In this post I am going to explain how to get logo height, width, image url and alt text in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_logo; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Theme\Block\Html\Header\Logo $logo, array $data = [] ) { $this->_logo = $logo; parent::__construct($context, $data); } //…

Magento 2 – How to Get All Categories of Specific Product

In this post I am going to explain how to get all categories of specific product in magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_categoryCollectionFactory; protected $_productRepository; public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory, \Magento\Catalog\Model\ProductRepository $productRepository, array $data = [] ) { $this->_categoryCollectionFactory = $categoryCollectionFactory; $this->_productRepository = $productRepository;…

Magento 2 – How to Get All Active Payment Methods

In this post I am going to explain how to get all active payment methods in magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_paymentConfig; protected $_scopeConfigInterface; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Payment\Model\Config $paymentConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface, array $data = [] ) { $this->_paymentConfig = $paymentConfig; $this->_scopeConfigInterface = $scopeConfigInterface; parent::__construct($context,…

Magento 2 – How to Get All Payment Methods

In this post I am going to explain how to get all payment methods in magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_paymentHelper; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Payment\Helper\Data $paymentHelper, array $data = [] ) { $this->_paymentHelper = $paymentHelper; parent::__construct($context, $data); } public function getAllPaymentMethods() { $paymentMethods =…

Magento 2 – How to Get Customer Group Collection

In this post I am going to explain how to get customer group collection. 1. Using Dependency Injection Add below code snippet in Block class. protected $_customerGroupCollection; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Customer\Model\ResourceModel\Group\Collection $customerGroupCollection, array $data = [] ) { $this->_customerGroupCollection = $customerGroupCollection; parent::__construct($context, $data); } public function getCustomerGroupCollection() { $customerGroupsCollection = $this->_customerGroupCollection->toOptionArray(); return $customerGroupsCollection;…

Magento 2 – How to get Product Attribute Id, Name, Options from Attribute Code

In this post I am going to explain how to get the attribute information from attribute code in magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_entityAttribute; protected $_attributeOptionCollection; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Eav\Model\Entity\Attribute $entityAttribute, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection $attributeOptionCollection, array $data = [] ) { $this->_entityAttribute = $entityAttribute; $this->_attributeOptionCollection =…

3 Must have Magento 2 WhatsApp Extensions to Boost Sales

WhatsApp has proven to be a tool so valuable with all of the noise across social media — if you haven’t started building a WhatsApp marketing campaign, now is the time. That’s why we’re introducing Magento 2 WhatsApp Extensions: a new way to run your business on the go by bringing customer conversations, marketing workflows,…

How to Install Google Analytics in Magento 2

Do you want to install Google Analytics in Magento 2? Knowing how your audience interacts with your website is crucial for your success. The best way to know your audience is through your traffic stats, and this is what Google Analytics provide for FREE. In this article, we will share why Google Analytics is important,…

How to Choose the Best Magento 2 Extension

High-quality extensions and themes that expand the reach of your store’s core functionality. Extensions make Magento a dream come true for beginners. In very short time there are vast collection of Magento 2 Extensions available in the official Magento marketplace, users find it very difficult to find the best Magento 2 Extension for the job….

Older posts Newer posts