Tuesday, September 27, 2016

How to reset lost admin password in Magento 2 ?

If you forgot your admin password in magento 2 in localhost you cann't retrieve by just clicking on lost password. For that you can reset through Magento CLI, then you can easily change password of your original user.

Go inside magento directory and type:

php bin/magento admin:user:create --admin-use="admin" --admin-password="admin123" --admin-email="admin@gmail.com" --admin-firstname="Admin" --admin-lastname="Admin"



Monday, September 26, 2016

How to render static blocks in any pages in magento 2

In between Magento 1.x and 2.x, rendering the Static block is quiet different. You can call either in .phtml template, CMS page or layout file in the following way.

In phtml file:
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block-identifier')->toHtml();?>

In any CMS block:
{{block class="Magento\Cms\Block\Block" block_id="block-identifier"}}

In layout file:
<referenceContainer name="content">
<block class="magento\Cms\Block\Block" name="block-identifier">
<arguments>
<argument name="block_id" xsi:type="string">block-identifier</argument>
</arguments>
</block>
</referenceContainer>