Tag: Magento Tutorials (page 1 of 2)

Magento 2 – How to Identify Current Page Type in phtml File

In this post I am going to explain How to Identify Current Page Type in Magento 2. Sometimes when you are working on custom development in Magento 2 then, you need to know what the current type of page being viewed is. You can identify whether the current page is a category page, product page,…

Magento 2 – How to Set Default Values for System Configuration Fields

In this post I am going to explain how to Set Default Values for System Configuration Fields in Magento 2. First we will make one “system.xml” file at below path. Path: app/code/<vendor>/<module>/etc/adminhtml/system.xml <?xml version=”1.0″ ?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Config:etc/system_file.xsd”> <system> <tab id=”ht” translate=”label” sortOrder=”999999″> <label>HT</label> </tab> <section id=”mymodulesection” translate=”label” type=”text” sortOrder=”30″ showInDefault=”1″ showInWebsite=”1″ showInStore=”1″> <class>separator-top</class> <label>My…

How to Add Readonly Field in ui_component Form in Magento 2

In this post I am going to explain how to add readonly field in ui_component form in Magento 2. Check the below example code snippet to add readonly field in ui_component. <field name=”identifier” formElement=”hidden”> <argument name=”data” xsi:type=”array”> <item name=”config” xsi:type=”array”> <item name=”dataType” xsi:type=”string”>text</item> <item name=”label” xsi:type=”string” translate=”true”>Identifier</item> <item name=”formElement” xsi:type=”string”>input</item> <item name=”source” xsi:type=”string”>identifier</item> <item name=”dataScope”…

Magento 2 – How to Get Creditmemo Details by Creditmemo Id

In this post I am going to explain how to get creditmemo details by creditmemo id in Magento 2. Using below code snippet you can get creditmemo details by passing creditmemo id. 1. Using Dependency Injection Add below code snippet in Block class. protected $_creditmemoRepositoryInterface; protected $_logger; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepositoryInterface, \Psr\Log\LoggerInterface…

How to Add Tooltip in ui_component Form Field in Magento 2

In this post I am going to explain how to add tooltip in ui_component form field in Magento 2. Check the below example code snippet to add tooltip in ui_component form field. <field name=”identifier” formElement=”hidden”> <argument name=”data” xsi:type=”array”> <item name=”config” xsi:type=”array”> <item name=”dataType” xsi:type=”string”>text</item> <item name=”label” xsi:type=”string” translate=”true”>Identifier</item> <item name=”formElement” xsi:type=”string”>input</item> <item name=”source” xsi:type=”string”>identifier</item> <item…

How to Get Shipment details by Shipment Id in Magento 2

In this post I am going to explain how to get shipment details by shipment id in Magento 2. Using below code snippet you can get shipment details by passing shipment id. 1. Using Dependency Injection Add below code snippet in Block class. protected $_shipmentRepositoryInterface; protected $_logger; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepositoryInterface, \Psr\Log\LoggerInterface…

Magento 2 – How to Get Customer Order Collection by Customer Id?

In this post I am going to explain how to get customer order collection by customer id in Magento 2. Using below code snippet you can get customer order data by passing customer id. 1. Using Dependency Injection Add below code snippet in Block class.   protected $_orderCollectionFactory; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,…

How to Create Custom Page Layout in Magento 2

In this post I am going to explain how to create custom page layout in Magento 2. Magento 2 provides five front-end page layouts as below. 1. Empty 2. 1column 3. 2columns-left 4. 2columns-right 5. 3column You can find all layouts at below path. vendor/magento/module-theme/view/base/page_layout/ Sometimes if amount of customization is too much then in…

Magento 2 – How to Get Invoice Details by Order Id?

In this post I am going to explain how to get invoice details by order id in Magento 2. Using below code snippet you can get invoice details by passing order id. 1. Using Dependency Injection Add below code snippet in Block class. protected $_searchCriteriaBuilder; protected $_invoiceRepositoryInterface; protected $_logger; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Api\SearchCriteriaBuilder…

Magento 2 – How to Get Shipment details by Order Id

In this post I am going to explain how to get shipment details by order id in Magento 2. Using below code snippet you can get shipment details by passing order id. 1. Using Dependency Injection Add below code snippet in Block class. protected $_searchCriteriaBuilder; protected $_shipmentRepositoryInterface; protected $_logger; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Api\SearchCriteriaBuilder…

Older posts