Tag: Magento 2 Tutorials (page 2 of 10)

Magento 2 – How to Add Form Key in phtml File

In this post I am going to explain how to add form key in phtml file. Add below code snippet in Block class. public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\Data\Form\FormKey $formKey, array $data = [] ) { parent::__construct($context, $data); $this->formKey = $formKey; } public function getFormKey() { return $this->formKey->getFormKey(); } Add below code snippet in template…

Magento 2 – How to Unlock Reindex Process | HiddenTechies

In Magento 2, Sometimes an issue comes like the indexing process gets locked at the time of reindexing. When the process or the index type is locked then you cannot reindex that specific locked index type. The reindex will always skip that index type and you will get an error as below. “Index is locked…

Magento 2 – How to Get Region Id and Region Name By Region Code

In this post I am going to explain how to get region id and region name by region code in Magento 2. Use this below code snippet. $regionCode = ‘CA’; $countryCode = ‘US’; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $region = $objectManager->create(‘Magento\Directory\Model\Region’); $regionId = $region->loadByCode($regionCode, $countryCode)->getId(); echo $regionId; $regionName = $region->loadByCode($regionCode, $countryCode)->getName(); echo $regionName;   Thats it. Enjoy…

Magento 2 – How to Remove Customer Account Navigation Links

In this post I am going to explain how to remove customer account navigation links in Magento 2. First you need to create one layout file “customer_account.xml” in your custom extension or theme. Syntax to remove link: <referenceBlock name=”link-block-name” remove=”true” /> Here are list of links. <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”> <body> <!– Store credit –> <referenceBlock…

Magento 2 – How to Resize Product Image

In this post I am going to explain how to resize product image in Magento 2. Using the below code snippet you can resize the product image in the template (.phtml) file. <?php $productId = ’12’; $_product = $block->getProductById($productId); $imageHelper = $this->helper(‘Magento\Catalog\Helper\Image’); $imgWidth = 350; $imgHeight = 400; $imageId = ‘category_page_grid’; $productImage = $imageHelper->init($_product, $imageId)…

How to Change the Admin Startup Page in Magento 2

In this article we’ll show you, how to change the Admin startup page in Magento 2. Follow this simple guideline… Step 1: Get Started Login into Magento Admin Panel and from sidebar go to, Store > Settings > Configuration Step 2: Change the Admin Startup Page Now from sidebar go to, Advanced > Admin Now…

How to Insert Products on Homepage Using Widget in Magento 2

In this article we’ll show you, how to create a new Attribute Set in Magento 2. Follow this simple guideline… Step 1: Get Started Login into Magento Admin Panel and from sidebar go to, Content > Elements > Pages Step 2: Insert Products on Homepage Now on Homepage Title click on Select dropdown and then…

How to Create a New Attribute Set in Magento 2

In this article we’ll show you, how to create a new Attribute Set in Magento 2. Follow this simple guideline… Step 1: Get Started Login into Magento Admin Panel and from sidebar go to, Store > Attribute > Attribute Set Step 2: Add New Attribute Set Here click on Add Attribute Set. Fill the required…

How to Add a New CMS Page in Magento 2

In this article we’ll show you, how to add a new CMS page in Magento 2. Follow this simple guideline… Step 1: Get Started Login into Magento Admin Panel and from sidebar go to, Content > Element > Pages Step 2: Create CMS Page Now click on Add New Page button. Fill the required details….

How to Redirect Customer to Account Dashboard after Login in Magento 2

In this article we’ll show you, how to Redirect Customer to Account Dashboard after Login in Magento 2. Follow this simple guideline… Step 1: Get Started Login into Magento Admin Panel and from sidebar go to, Store > Settings > Configuration Step 2: Configure Redirect Settings Now from sidebar go to, Customers > Customer Configuration…

Older posts Newer posts