Posts

Connect JSP with mysql

In this example we will show you how to connect to MySQL database from your JSP code. First, you need to create database and then write jsp code to connect jsp to database. 1. Create a database: First create a database named usermaster in mysql. Before running the jsp code you need to paste mySqlConnector.jar in lib directory of jdk. mysql> create database usermaster; (This query create database in my sql command prompt) 2. Connect JSP with mysql: Here is the jsp code. ConnectJspToMysql.jsp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <html> <head> <title>Connection with mysql database</title> </head> <body> <h1>Connection status </h1> <% try { /* Create string of connection url within specified format w

Custom offline payment module with custom validation on checkout page

In this blog session i am going to add an extra custom validation on checkout page which will verify user's email domain with the email domain you provided in store config. If both domain matches then only a success message shown and you can proceed with place order, other wise it will show error message and you are unable to  place order.                                                             This blog is related to my previous blog in which i had created an extra offline payment method on checkout page so please check it  here  . So, at that time we have already these files and folder structure * etc    * adminhtml       * system.xml    * config.xml    * module.xml    * payment.xml * Model    * CustomPayment.php * view     * frontend        * layout           * checkout_index_index.xml        * web           * js              * view                 * payment                    * method-rendered                       * custompayment-method.js      

Creating a new offline payment method module in magento 2

Image
As, we know that magento 2 supports a wide variety of payment method including-- Online payment Cash on delivery Paypal payment Solution Amazon pay Card payment Braintree payment solution Cheque and Money Order If you wish to add any other offline payment method along with these existing one then you are at right place. Store view      Today i am going to show you how to create module which enables us to choose  a custom offline payment method at checkout page in magento 2. Follow these steps in order to achieve this- 1. Create a new folder under app/code/ Excellence / OfflinePaymentMethods     Here Excellence is namespace and OfflinePaymentMethods is module name. 2. Create registration.php file under app/code/Excellence/OfflinePaymentMethods with following          content registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Excellence_OfflinePay

Adding twitter's Bootstrap library into magento 2 for responsive theme design

Since, magento2 doesn't include bootstrap library by default. Instead it has it's own library for responsive layout for all devices.                                                     Peoples like me who are familiar with bootstrap and used to use these library face difficulties while going to design theme without bootstarp. So, here i am going to link bootstrap library into magento 2 theme for responsive theme design.                                  Yes it is true that bootstrap made conflict with existing styling of magento 2, which should be over-rided on your own. You can add Bootstrap this way, follow below steps 1) Place your JS and CSS at below location /app/design/frontend/vendor-name/theme-name/web/css /app/design/frontend/vendor-name/theme-name/web/js 2) Call files in your  default_head_blocks.xml app/design/frontend/vendor-name/theme-name/Magento_Theme/layout/default_head_blocks.xml add these line of code <css src="css/bootstrap.css&qu

Empty Design configuration Issue (We couldn't find any record)

Image
Recently while designing a new theme in magento 2 i had faced a new issue in magento theme design configuration.                   Let me explain the issue in detail. While creating new theme in magento 2 i am unable to see theme configuration records into that table after page rendered. I am attaching a screen shot for better understanding. usually you will see all two Luma and Blank theme entry there along with any other themes if you have made previously. But in my case magento was unable to fetch any one of them. It is rare  but happens with me i i found the solution on  https://github.com/magento/magento2/issues/14600    thanx to the author of this repo who shorted out my issue and save my time and effort in wondering  on web.      The exact problem is due to magento renderer indexer, to short out this issue you need to reset and reindex the all file using below commands. magento indexer:info magento indexer:status magento indexer:reset design_config_grid magento

Directory Structure in magento 2

Magento 2 directory structure are pretty much self explained only by it's name. If you are inside root of your magento project then you would see following directory... /app /bin /dev /generated /lib /pub /var /vendor /app In this folder, you will find following subfolders: /code It includes the Magento 2 core code (One of the locations where you can develop your custom Magento 2 code (custom modules). In some cases, you might not find the core code here. In this case, it’s placed in / vendor/magento  directory . /design This directory has  /adminhtml  and  /frontend  sub-directories which contain theme directories having  phtml, xml, JS  and  LESS files. /etc This directory contains the  di.xml  and  env.php  configuration file, the di.xml file contains class mapping and interface preferences. The env.php file contains the configuration details of your Magento 2. It also contains  config.php  which contains the list of modules, enabled as well as disabled ones.

Creating a new module in magento 2

In magento 2 all modules reside in the folder app/code directory, previously in magento1 there was the concept of local/ community/ core/ folders but that has been removed now. For creating modules in magento 2 we need at least these 3 files in our module in this directory arrangement. Step1 Module names in magento 2 are divided into two part “VendorName_ModuleName” e.g Magento_Contact, Magento_Catalog or Trieffects_Test first part is the vendor and second part is the actual module. Let’s take our module name to be “Trieffects_Hello”. First we need to make the folders app/code/Trieffects/Hello Step2 – module.xml Next we need to add the module.xml file app/code/Trieffects/Hello/etc/module.xml with following contents <?xml version="1.0"?>        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">         <module name="Trie