Page 48 of 68

Magento 2 – How to Add Custom Links in Footer Links

In this post I am going to explain how to add custom links in footer in Magento 2. Here, I am using my custom module – Ht_Mymodule First you need to add default.xml file in your extension and add below code in it. File Path: app/code/Ht/Mymodule/view/frontend/layout/default.xml <?xml version=”1.0″?> <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”> <body> <referenceBlock name=”footer_links”> <block…

Magento 2 – How to Remove Containers or Blocks from Layout

In this post I am going to explain how to remove containers or blocks from layout in Magento 2. First you need to add one layout file in your extension or theme. In this, you need to use referenceBlock for the blocks, and referenceContainer for the containers. To remove the Container: <referenceContainer name=”footer-container” remove=”true”/> To…

Magento 2 – How to Add Custom Tab on Product View Page

In this post I am going to explain how to add custom tab on product detail page in Magento 2. Here, I am using my custom module – Ht_Mymodule First, create product page layout file catalog_product_view.xml and add following code in it. File Path: app/code/Ht/Mymodule/view/frontend/layout/catalog_product_view.xml <?xml version=”1.0″?> <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”> <body> <referenceBlock name=”product.info.details”> <block class=”Magento\Catalog\Block\Product\View”…

Magento 2 – How to Create or Edit Admin User via Command Line

In this post I am going to explain how to create new admin user or edit existing user via command line in Magento 2 Execute below command to create new admin user. php bin/magento admin:user:create –admin-user=’johndoe’ –admin-password=’john@123′ –admin-email=’[email protected]’ –admin-firstname=’John’ –admin-lastname=’Doe’ After successful execution of command you will get below message Note: If you are editing…

Magento 2 – How to Add More Variable to Window.checkoutConfig on Checkout Page

Sometimes we need to add some custom variables to the Window.checkoutConfig which we can get on checkout page and can use to implement some custom functionality or develop some custom logic. So here I am going to explain how you can add custom variable to Window.checkoutConfig. Here, I am using my custom module – Ht_Mymodule…

Magento 2 – How to Add Custom Class and Attribute to the Body tag

In this post I am going to explain how to add attribute and class to the body tag in Magento 2 Magento 2 adds classes to the body tag on every page to help the developers make custom designs per page. In Magento 2 the controller name and page layout name added as a class…

Magento 2 – How to Add Date Picker Field in System Configuration

In this post I am going to explain how to add date picker field in magento 2 system.xml file or you can say in magento 2 system configuration. Here, I am using my custom module – Ht_Mymodule First, open your module’s system.xml file and add below code in it. File Path: app/code/Ht/Mymodule/etc/adminhtml/system.xml <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Store:etc/config.xsd”>…

Magento 2 – How to Get List of All Countries

In this post I am going to explain how to get country collection in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_countryCollectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, array $data = [] ) { $this->_countryCollectionFactory = $countryCollectionFactory; parent::__construct($context, $data); } public function getCountryCollection() { $collection = $this->_countryCollectionFactory->create()->loadByStore();…

Magento 2 – How to Get Formatted Price With Currency

In this post I am going to explain how to get formatted price with currency in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_priceHelper; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Pricing\Helper\Data $priceHelper, array $data = [] ) { $this->_priceHelper = $priceHelper; parent::__construct($context, $data); } public function getFormattedPrice($price) { $formattedPrice…

Magento 2 – How to Get All Images of Product by Product ID

In this post I am going to explain how to get all images of product by product id in Magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $_productFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Catalog\Model\ProductFactory $productFactory, array $data = [] ) { $this->_productFactory = $productFactory; $this->_storeManager = $storeManager; parent::__construct($context, $data);…

« Older posts Newer posts »