Category: Magento (page 4 of 24)

Magento 2 – How to Hide Admin Menu Based on System Configuration

In this post I am going to explain how to hide admin menu based on system config in Magento 2. In order to add admin menu we write code in menu.xml file, which is located at <vendor>/<module>/etc/adminhtml/. So now let’s see how you can hide menu based on conditions. Check the below code snippet. <?xml…

Magento 2 – How to Get Creditmemo Details by Order Id

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

How to Add Hidden Field in ui_component Form in Magento 2

In this post I am going to explain how to add hidden field in ui_component form in Magento 2. Check the below example code snippet to add hidden field in ui_component. <field name=”id” formElement=”hidden”> <argument name=”data” xsi:type=”array”> <item name=”config” xsi:type=”array”> <item name=”dataType” xsi:type=”string”>text</item> </item> </argument> </field> Here formElement=”hidden” is used to create a hidden field….

Introducing Etrend – Best Converting Magento 2 Theme!

Meet Etrend Magento 2 Theme built specifically for increase conversion and drive more sales. We’re so exited to share this brand new theme with you. In this post, we’ll unpack Etrend’s exciting features and how they can help you drive more sales. To see it in action, go ahead and check out Etrend demo. Increase…

Magento 2 – How to Create and Call Modal Popup Widget

In this post I am going to explain how to create and call modal popup widget in Magento 2. First, you need to create a “mymodal.js” file at below path. Path: app/code/<vendor>/<module>/view/frontend/web/js/mymodal.js   define([ ‘jquery’, ‘Magento_Ui/js/modal/modal’ ], function( $, modal ) { var options = { type: ‘popup’, responsive: true, innerScroll: true, buttons: [{ text:…

Magento 2 – How to Get Customer Data By Customer ID

In this post I am going to explain how to get customer data by customer id Magento 2. Using below code snippet you can get customer data by passing customer id. Add below code snippet in Block class. protected $_customerRepository; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, array $data = [] ) { $this->_customerRepository =…

Magento 2.4 Release! What’s New?

Great News for Magento Community! The latest version of Magento 2.4 is Release. Magento Open Source 2.4 includes a wealth of new features as well as hundreds of enhancements and fixes to the core product. What’s New in Magento 2.4? Every new release of Magento version comes with new features & improvements and gives better…

Magento 2 – How to Disable Payment Method Programmatically

In this post I am going to explain how to disable payment method programmatically in magento 2. First, We need to write the “payment_method_is_active” event, which checks on checkout for payment method availability. So, we are going to create event.xml file on below path. Path: app/code/Ht/Mymodule/etc/ <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Event/etc/events.xsd”> <event name=”payment_method_is_active”> <observer name=”custom_payment”…

Magento 2 – How to Add Dependant Field in Admin System Configuration

In this post I am going to explain how to add dependant field in admin system configuration in magento 2. In order to create a field dependant on single value, use the below code: <depends> <field id=”parent_field_id”>1</field> </depends> And to create a field dependant on two or more values, use the below code: <depends> <field…

Magento 2 – How to Add Customer Address Programmatically

In this post I am going to explain how to add customer address programmatically in magento 2. 1. Using Dependency Injection Add below code snippet in Block class. protected $addressFactory; public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Customer\Model\AddressFactory $addressFactory, array $data = [] ) { $this->addressFactory = $addressFactory; parent::__construct($context, $data); } public function addAddress($customerId) { $firstName =…

Older posts Newer posts