9 07, 2015

Magento 2: Get Store configuration value

July 9th, 2015|MAGENTO, MAGENTO 2|0 Comments

Here we are giving the code to get the store configuration value

In .php file (Block)

protected $_scopeConfig;

public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
array $data = []
) {
parent::__construct($context, $data);
$this->_scopeConfig = $scopeConfig;

public function getTelephoneConfig(){

$showTemplateHint = $this->_scopeConfig->getValue('general/store_information/phone', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
return $showTemplateHint;


In .Phtml file

<?php echo $block->getTelephoneConfig(); ?>


9 07, 2015

Magento2 : Create Category attribute

July 9th, 2015|MAGENTO, MAGENTO 2|1 Comment

/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

* Add attributes to the eav/attribute
'group' => 'General',
'type' => 'varchar',
'label' => 'External Link',
'input' => 'text',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '',


9 07, 2015

Magento2: Create Product Attribute

July 9th, 2015|MAGENTO, MAGENTO 2|0 Comments

In magento 2 Attribute is create using Setup file. If we need to install the data in the system (database) create InstallData.php file in Setup folder so path should be

app/code/<package name>/<module name>/Setup/InstallData.php

In the InstallData.php we need to create class for module.We need to add the below content to create attribute.


9 07, 2015

Magento 2: Error to PHP version check for always_populate_raw_post_data

July 9th, 2015|MAGENTO, MAGENTO 2|2 Comments

always_populate_raw_post_data always_populate_raw_post_data

There are 2 solution to change the value

1) change in php.ini

In Php.ini file

always_populate_raw_post_data = -1

2) change in .htaccess file

Solution to change in .htaccess file

php_value always_populate_raw_post_data -1

9 07, 2015

Magento 2: Create configuration file system.xml in our custom module

July 9th, 2015|MAGENTO, MAGENTO 2|0 Comments

Yes, In magento 2 we can create system configuration file same as Magento 1. But we need to create some file. Lets start how to create it

We need to use following file to create it.



This 2 files are important to create system configuration.

In System.xml file

Adding the common content

6 06, 2015

Magento2: Truncate the string

June 6th, 2015|MAGENTO, MAGENTO 2|0 Comments

We have to use the below syntax if we need to truncate the string from .phtml file

<?php $length = 10; ?>

<?php $string = new \Magento\Framework\Stdlib\StringUtils;?>
<?php echo $string->substr($data->getContent(),0,$length); ?>


6 06, 2015

Magento2: Display static block in Phtml file & CMS page

June 6th, 2015|MAGENTO, MAGENTO 2|0 Comments

In Phtml File:

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

in CMS Content:

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

In Xml File:

<referenceContainer name="content">

<block class="Magento\Cms\Block\Block" name="block_identifier">
<argument name="block_id" xsi:type="string">block_identifier</argument>



15 05, 2015

Magento2: Getting error in step 6 at Installation

May 15th, 2015|MAGENTO, MAGENTO 2|0 Comments

When we import the table at the magento setup , we got the below error “Installation is incomplete. ”



Solution of magento 2 installation is incomplete error:

just put the code in .htaccess file

<IfModule [...]

30 03, 2015

Magento 2: Create Simple Hello World Module

March 30th, 2015|MAGENTO, MAGENTO 2|8 Comments

Magento2 beta version has been released by magento for developer understanding. We can get the setup from Git Gub https://github.com/magento/magento2

You can get setup guide from http://www.ubertheme.com/magento-news/magento-2-0-installation-guide/

In Magento2 there is a drastic change in the structure of the code. All the code pools are removed and also the Skin directory. There are many changes related to the theme folder as well. To understand how the structure of Magento2 works, let us check it by creating a simple helloworld module.

Before starting the code section, let us create the directory structure that we will need.



17 03, 2015

Magento 2 : How to add custom top links in header

March 17th, 2015|MAGENTO 2|1 Comment

Steps to add custom link for CMS page in magento 2 header are as under

  • First create a CMS page for example we will create an about us page with identifier as “about-us”.

  • Now usually, to access the cms page in frontend, we use www.domain.com/{identifier}

  • So, the top link that we will add for the about us page should redirect to www.domain.com/about-us

  • To add the top link, we will add following code in default.xml of our theme