Custom query inside Custom Module Block Magento2

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get(‘Magento\Framework\App\ResourceConnection’);
$connection = $resource->getConnection();
$tableName = $resource->getTableName(‘test’);
$sql = “Select * FROM ” . $tableName.” where id=”.$id;
$result = $connection->fetchAll($sql);
return $result;


Mysql is not recognized as an internal or external command windows OS

Having XAMPP installed when i try to type mysql in my windows command prompt it would give me the following error:

'mysql' is not recognized as an internal or external command, operable program or batch file.

This simply means that the ‘mysql’ excutable command file (mysql.exe) was not added to your system path therefore the system was unable to locate this file. To add the ‘mysql’ to system path try to locate the ‘mysql’ resident folder. In my case (Windows7) it was


Copy it (to clipboard) and go to Control Panel -> System and Security -> System and paste the copied folder path into Variable value: field of Edit System Variable pop up. Prefix it with a semi-colon (;) to separate it from other existing values (see image below – click to open larger image)

Magento2 showing error Required parameter ‘theme_dir’ was not passed while saving product in admin

This error appears when you remove a template folder, which is still referenced in the database. The simplest way to fix it is, go to database, and in table ‘theme’, find the theme name which does not exist in app/design/frontend/package.
DELETE the reference to the missing theme from the table.


Magento2 Toplink Default Blocks

   <referenceBlock name="top.links">
        <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
        <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
        <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
        <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->


Important commands in magento2

Run this command from terminal having the Root path of the files of magento

  1. php bin/magento setup:upgrade
  2. php bin/magento setup:di:compile
  3. php bin/magento setup:static-content:deploy
  4. php bin/magento cache:clean

Layout structure start pages

Root/ vendor/magento/module-theme/view/frontend/layout/default.xml

Table core_config_data is where we need to change the base url while migrating the site from one domain to another and follow the above 4 commands in the same order

Static content deploy particular theme in magento2

php bin/magento setup:static-content:deploy –area frontend –theme Inspirationconcepts/id4sports

Enable Development mode in Magento2

bin/magento deploy:mode:set developer