Social Icons

twitterfacebookgoogle pluslinkedinemail

Saturday, 13 October 2018

How to add External JS and CSS in Magento 2




Hello Friends,

Sometimes we need to add some external js or css in Magento 2.

So, Here is the code which will help you to add external js or css in your Magento 2 Project.

Please update below path of the file

/app/design/frontend/<ThemeName>/<Theme>/Magento_Theme/layout/default_head_blocks.xml
like
/app/design/frontend/Magento/luma/Magento_Theme/layout/default_head_blocks.xml

if there will no file than please copy from below path and add it in your theme template.
vendor/magento/module-theme/view/frontend/layout/default_head_blocks.xml

Wednesday, 21 March 2018

Magento 2 Internal Server Error

Hello Guys,

Recently I faced one issue related to Internal Server Error. after debug and google I found some of the solution which are useful to you.

After installation of magento 2 or setup old source code to the server at that time we are getting error like


Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.





So, First of all we must check related to .htaccess file. I am sure this is cause of the .htaccess file.

we must check .htaccess file in setup root directory and also under the pub/ directory.

Setup Root .htaccess file should be like .htaccess

Pub/.htaccess file should be like pub/.htaccess

After Changes .htaccess please run the below commands

1. rm -rf var/cache/* var/page_cache/* var/generation/* var/view_preprocessed/* var/di/*
2. php bin/magento setup:upgrade
2. php bin/magento setup:di:compile (if deploy mode is production)
3. php bin/magento setup:static-content:deploy
4. chmod -R 777 var/* pub/* generated/*

if still facing same issue than please enable mod_rewrite and mod_version php module from your hosting server.
Also please check folder permission.

you can share comment here if still facing issue. I will sure help you to fix it.

Thank you.
Anant Prajapati (Enjoy Your Self)


Wednesday, 28 February 2018

Magento 2 How to Get Current Store Date Time

Hello Friends,

if you want to display current date time zone wise in magento 2 than you can use this code. it will help you to display current timezone date.



$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objDate = $objectManager->create('Magento\Framework\Stdlib\DateTime\TimezoneInterface');
$objDate->date()->format('y-m-d H:i:s')



Hope this short article will help you fix date issue.

Sunday, 6 August 2017

Share Facebook and twitter in magento

Hello Friends,

This article is use to share your product in facebook and twitter. Here is the simple code to add into app/design/frontend/<theme>/<theme>/template/catalog/product/view.phtml

Please check first your theme path and also detail page file. here is the default path
 app/design/frontend/base/default/template/catalog/product/view.phtml

You can find file path to enable path hint from back-end.

Add below code and save the file

<?php $_productName = urlencode(trim($_helper->productAttribute($_product, $_product->getName(), 'name')))?>
                    <?php $_productImageUrl = urlencode(trim($this->helper('catalog/image')->init($_product, 'image')))?>
                    <?php $_productUrl = urlencode(trim($_product->getProductUrl()))?>
<?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))); ?>   
                    <div class="social-links" style="float: right;">
                        <a href="javascript:void(0);" title="<?php echo $this->__('Share on Facebook') ?>" class="link-facebook svg-replace" onclick="window.open( '<?php echo 'http://www.facebook.com/sharer.php?s=100&' . $_u; ?>' , '_blank' ,'height=500,width=500'); return false">
                            <img class="fb-icon" style="" src="<?php echo $this->getSkinUrl(); ?>images/social-fb-icon.png" alt="Share Facebook" />
                        </a>
                       
                        <a href="javascript:void(0);" target="_blank" title="<?php echo $this->__('Share on Twitter') ?>" class="link-twitter svg-replace" onclick="window.open( '<?php echo 'http://twitter.com/home?status=' . $_productName . '+' . $_productUrl; ?>' , '_blank' ,'height=500,width=500'); return false">
                            <img class="twitter-icon" style="" src="<?php echo $this->getSkinUrl(); ?>images/social-twitter-icon.png" />
                        </a>
                    </div>

Notes: This code will help you in core php, WordPress, Drupal, Joomla and other framework also you just need to setup parameter and it will work.

Thank you,
Enjoy Your Self,

Thursday, 6 October 2016

Magento 2: how to create new admin user without access backend

Hello Friends,

In Magento2, Sometime your account is disabled or forgot the password of your current admin user and you can not update the password from database because magento 2 use the encrypted technique
So, don't worry about it. here is the very simple trick to create new user.


For this you must have ssh access because you can create new user using the command in magento 2.



php setup_magento2/bin/magento admin:user:create --admin-user anant --admin-password anant101289 --admin-email anantprajapati111@email.com --admin-firstname Anant --admin-lastname Prajapati






Now You can login with this user and update your current user password from back-end.

Hope, this trick will help you to resolve your reset password / forgot password / new user issue.

Thanks
Enjoy Your Self

Sunday, 4 September 2016

How to get current category details on listing page - magento 2

Hello Friends,

Here is the code to get details of current category in magento 2.

Please add below code in list.phtml (or you want any page of catalog) and you will get the category details in magento 2.


$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
var_dump($category->getData());

You will get output like this

Friday, 17 June 2016

How To setup magento2 on server

Hello Friend,

Today, we are talking about the magento2 commands which are useful to run successfully Magento2 Project on your server.

Here i am writing the steps of the setup new project on your server. (NOTE : this is the depend on the hosting server. So, may be it will not work on all server.)

Step1 : Please upload your theme or magento2 setup on server via FTP or Cpanel.

Step2 : Please extract the uploaded folder on server from Cpanel.

Step3 : Please create database name from the phpmyadmin on server.

Step4 : Please start the setup of the magento2 like run the url where you extract magento2 folder.

Step5 : once setup magento2 Please open ssh and connect it with ssh.

Step6 :  Run this command in terminal(CMD):
php bin/magento setup:upgrade

Step6 : Now , Run this command to check for static content
php bin/magento setup:static-content:deploy
  
Now You can run url of the site to check if is it working fine or not.

Hope This article will help you to setup magento2 project
Thank you
Enjoy Your Self

Saturday, 14 March 2015

wysiwyg editor remove allowfullscreen from iframe in magento

Hello Friends,

Today  I want to saw you that how to add "allowfullscreen" or other attribute in TinyMCE for iframe.

Basically i want to allow "allowfullscreen" to TinyMCE html editor for magento and I also searched this on Google but not found the any solution. so i start to check the tiny_mce.js. and i got the one code and add this attribute in that code. let me share the code for you. so, you can fix this issue yourself.

I tried this for the magento Tiny_Mce but i think this for all framework and cms.

Saturday, 31 January 2015

How to add or change currency symbol in magento



Hello Friends,

Here i want to learn you that how can we add the Indian Rs currency symbol in magento. I searched on internet but not found proper answer. so i want to write this article for this.

Hope you all are enjoying with this.




 Here is the steps to change symbol

1. Please open the FTP or cpanel
2. go to this directory lib/Zend/Locale/Data
3. Please open file name root.xml
4. here are the list of all the currency symbols. you can change any currency symbols from here
5. write the below code inside this file.
for indian RS go to line no 2867 or find "<currency type="INR">"  text

<currency type="INR">
        <symbol>RS</symbol>
</currency>

Replace to

<currency type="INR">
      <symbol>&#x20B9;</symbol>
</currency>


6. Please clear the catch from the backend and refresh the site you can see the set currency symbol on your site.

Hope this article will help you

Thank you
Enjoy Your Self


Tuesday, 20 January 2015

How to add select dropdown in magento registration page for Date of birth field

Hello Friends,

Today i want to know you that how you can add to convert textbox to select dropdown for date of birth field on registration page.

you can not add the dropdown in magento registration form for date of birth because its working on textbox and it update those value in
<input type="hidden" id="dob" name="dob">

without it we can not store the DOB in magento db.

Here is the simple way to integrate dropdown in DOB.

Saturday, 20 December 2014

How to create log file in magento

Hello Friends,

Today, i want to see you how to create log file for the debug in magento.

I search on google so many times to find perfect code for the create log file in magento but not got it.
So i plan to check in magento code and found one code for this so, here i mention one code to generate log file in magento.

Its always use to debug the code when you are working on live site. so its easy to debug the code.

Just copy below code and paste on your file where you want to debug and you can get the log file. it's just one line code


Sunday, 23 March 2014

customer login not working in magento 1.8.1


When we are upgrading the magento to 1.8.1 version there are in frontend customer login not working after the register for the account.

for that one fix is working for login to the existing account.

There are the missing the bit line of code in following file:


Saturday, 22 March 2014

shippng method and shopping cart not working in magento 1.8.1


In magento 1.8.1, there are the following issues and how to solve it.

When we are add to cart the product and  proceed for to checkout then that time shipping1 method not working because of the ajax not the loading any content from js.

I have fixed for that the copy the

Wednesday, 12 March 2014

Display Left navigation on product listing page in magento



Hello Freinds,

If you want to display the left navigation bar on product listing page in magento then please follow the following steps.

1. First of all you need to create/use local.xml from your current theme like

   app\design\frontend\default\default\layout

2. Now you need to just write the code like


Friday, 28 February 2014

FONT Is not working on FireFox

Hello, friends


If you are facing font issue in firefox browser then follow the step:
 
1.  Please use full url path.
2.  Moving/Creating 'fonts' folder to the root
3.  Directly use src url in the css. like
For example, 'http://yoursite.com/fonts/test.ttf' instead of '../fonts/test.ttf'



Thank you,

How to Create Randon Number in Magento?

Hello, friends

In magento it is possible that the we are generating  Random number through the following one line code:

Use getRandomString() method and generating random number. In getRandomString() method we pass the number till we get the random number from to 0.





Ex : if we pass the 5 number in gerRandomString() method then it will fetch rendom number from 0 to 5.

Friday, 1 November 2013

How to get selected value or html content of dropdown or select using jquery

Hello Freinds,


if you want to get selected value or html content of dropdown or select using jquery then you can use on change event and also you can get all the attribute of selected option.

<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.js "></script>
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function(){
                jQuery('#select_id').change(function(){
//get content from dropdown option tag                   
                          alert(jQuery(this).find("option:selected").text());
                          alert(jQuery(this).find("option:selected").val());
                });
        });
 </script>

<select id="select_id" /><option value="1">option 1</option>
<option value="1">option 2</option>
<option value="1">option 3</option>
</select>
</body>
</html>

Live Demo

Monday, 28 October 2013

Program for traversing a graph through BFS and DFS

Breadth-first search (BFS) and depth-first search (DFS) are two distinct orders in which to visit the vertices and edges of a graph. BFS radiates out from a root to visit vertices in order of their distance from the root. Thus closer nodes get visited first.

#include<stdio.h>
#define MAX 20
typedef enum boolean{false,true} bool;
int adj[MAX][MAX];
bool visited[MAX];
int n; /* Denotes number of nodes in the graph */
main()
{
int i,v,choice;
create_graph();
while(1)
{
printf("\n");
printf("1. Adjacency matrix\n");
printf("2. Depth First Search using stack\n");
printf("3. Depth First Search through recursion\n");
printf("4. Breadth First Search\n");
printf("5. Adjacent vertices\n");
printf("6. Components\n");
printf("7. Exit\n");
printf("Enter your choice : ");
scanf("%d",&choice);


Implementation of Binary Search Tree

                                 A binary search tree is a tree where each node has a left and right child. Either child, or both children, may be missing. Figure 3-2 illustrates a binary search tree. Assuming k represents the value of a given node, then a binary search tree also has the following property: all children to the left of the node have values smaller than k, and all children to the right of the node have values larger than k. The top of a tree is known as the root, and the exposed nodes at the bottom are known as leaves.                                                                                                                                                                                                                                    

Implementation of Binary Search Tree


# include <stdio.h>
# include <malloc.h>
struct node
{
int info;
struct node *lchild;
struct node *rchild;
}*root;
main()
{
int choice,num;
root=NULL;
clrscr();
while(1)
{
printf("\n");
printf("1.Insert\n");
printf("2.Delete\n");
printf("3.Inorder Traversal\n");
printf("6.Display\n");
printf("7.Quit\n");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the number to be inserted : ");
scanf("%d",&num);
insert(num);
break;
case 2:
printf("Enter the number to be deleted : ");
scanf("%d",&num);
del(num);
break;
case 3:
inorder(root);
break;
case 6:
display(root,1);
break;
case 7:
exit();
default:
printf("Wrong choice\n");
}/*End of switch */
}/*End of while */
}/*End of main()*/
find(int item,struct node **par,struct node **loc)
{
struct node *ptr,*ptrsave;
if(root==NULL) /*tree empty*/
{
*loc=NULL;
*par=NULL;
return;
}
if(item==root->info) /*item is at root*/
{
*loc=root;
*par=NULL;
return;
}
/*Initialize ptr and ptrsave*/
if(item<root->info)
ptr=root->lchild;
else
ptr=root->rchild;
ptrsave=root;
while(ptr!=NULL)
{
if(item==ptr->info)
{ *loc=ptr;
*par=ptrsave;
return;
}
ptrsave=ptr;
if(item<ptr->info)
ptr=ptr->lchild;
else
ptr=ptr->rchild;
}/*End of while */
*loc=NULL; /*item not found*/
*par=ptrsave;
}/*End of find()*/
insert(int item)
{ struct node *tmp,*parent,*location;
find(item,&parent,&location);
if(location!=NULL)
{
printf("Item already present");
return;
}
tmp=(struct node *)malloc(sizeof(struct node));
tmp->info=item;
tmp->lchild=NULL;
tmp->rchild=NULL;
if(parent==NULL)
root=tmp;
else
if(item<parent->info)
parent->lchild=tmp;
else
parent->rchild=tmp;
}/*End of insert()*/
del(int item)
{
struct node *parent,*location;
if(root==NULL)
{
printf("Tree empty");
return;
}
find(item,&parent,&location);
if(location==NULL)
{
printf("Item not present in tree");
return;
}
if(location->lchild==NULL && location->rchild==NULL)
case_a(parent,location);
if(location->lchild!=NULL && location->rchild==NULL)
case_b(parent,location);
if(location->lchild==NULL && location->rchild!=NULL)
case_b(parent,location);
if(location->lchild!=NULL && location->rchild!=NULL)
case_c(parent,location);
free(location);
}/*End of del()*/
case_a(struct node *par,struct node *loc )
{
if(par==NULL) /*item to be deleted is root node*/
root=NULL;
else
if(loc==par->lchild)
par->lchild=NULL;
else
par->rchild=NULL;
}/*End of case_a()*/
case_b(struct node *par,struct node *loc)
{
struct node *child;
/*Initialize child*/
if(loc->lchild!=NULL) /*item to be deleted has lchild */
child=loc->lchild;
else /*item to be deleted has rchild */
child=loc->rchild;
if(par==NULL ) /*Item to be deleted is root node*/
root=child;
else
if( loc==par->lchild) /*item is lchild of its parent*/
par->lchild=child;
else /*item is rchild of its parent*/
par->rchild=child;
}/*End of case_b()*/
case_c(struct node *par,struct node *loc)
{
struct node *ptr,*ptrsave,*suc,*parsuc;
/*Find inorder successor and its parent*/
ptrsave=loc;
ptr=loc->rchild;
while(ptr->lchild!=NULL)
{
ptrsave=ptr;
ptr=ptr->lchild;
}
suc=ptr;
parsuc=ptrsave;
if(suc->lchild==NULL && suc->rchild==NULL)
case_a(parsuc,suc);
else
case_b(parsuc,suc);
if(par==NULL) /*if item to be deleted is root node */
root=suc;
else
if(loc==par->lchild)
par->lchild=suc;
else
par->rchild=suc;
suc->lchild=loc->lchild;
suc->rchild=loc->rchild;
}/*End of case_c()*/
inorder(struct node *ptr)
{
if(root==NULL)
{
printf("Tree is empty");
return;
}
if(ptr!=NULL)
{
inorder(ptr->lchild);
printf("%d ",ptr->info);
inorder(ptr->rchild);
}
}/*End of inorder()*/
display(struct node *ptr,int level)
{
int i;
if ( ptr!=NULL )
{
display(ptr->rchild, level+1);
printf("\n");
for (i = 0; i < level; i++)
printf(" ");
printf("%d", ptr->info);
display(ptr->lchild, level+1);
}/*End of if*/
}/*End of display()*/

Saturday, 26 October 2013

fatal error call to a member function getusername() on a non-object in magento

Hello Friend,

when you get like this error "
Fatal error: Call to a member function getUsername() on a non-object in .../app/design/adminhtml/default/default/template/page/header.phtml on line 31".

Please  follow the steps


  1. Backup the var folder as (var-back)
  2. Create a new var directory
  3. Backup the locks folder as (locks-back) {if available}
  4. Create the locks directory



Thanks
Enjoy Your Self,
 

Free Advertisement

Free Advertisement

Free Advertisement

Free Advertisement