Social Icons

twitterfacebookgoogle pluslinkedinemail
Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

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

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,

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

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.

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,

Favicon icon not display in IE OR Firefox or Chrome

Hello Friends,



When you want to try add Favicon icon and then its not display in IE please use following step to display favicon icon in IE.

1. Please following code

<head>
<link href="http://anantprajapati.blogspot.in/favicon.ico" rel="icon" type="image/x-icon"></link>
<link href="http://anantprajapati.blogspot.in/favicon.ico" rel="shortcut icon" type="image/x-icon"></link>
<link href="http://anantprajapati.blogspot.in/favicon.ico" rel="icon" type="image/vnd.microsoft.icon"></link>
</head>


Thursday, 24 October 2013

How to display most popular or most viewed product in magento

Hello Friends,

You want to display Most Popular or Most Viewed Product in magento then please add following code in your script

If you want to display in ,.phtml file

$this->getLayout()->createBlock('catalog/product_mostviewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>

Wednesday, 23 October 2013

How To Solve internal server 500 in magento


Hello Friends,

You are facing problem like "internal server 500" with magento installation on server or other.

its very easy to solve.

please follow the following step to resolved above issue.

1. First of all check rewrite module is enable on your server.
  if not enable then please enable it from php.ini file of server or .htaccess file or other way.


2. please check Folder permission through FTP or Cpanel


change permission  of  all the file and folder to 755

Thursday, 10 October 2013

How to Alter , create new table, delete or update table using upgrade script in magento



Hello Friends,

You can perform database query in magento upgrade script.

you are facing problem with alter,update,delete or create new table in magento but its very easy just write defined code in your upgrade script and you can see your table is altered or insert
create or delete

you must create script for this like beloved name

Name of file : 

syntax : mysql4-upgrade-<old_version>-<new_version>.php
 
Ex : mysql4-upgrade-0.1.0-0.1.1.php

Now you have quesion is that how to find it rifgh?
but it also easy   please open your config.xml file of your module and check the version which is your old_version.

syntax for create , alter and delete table




<?php $this->startSetup()->run("<write your query>")->endSetup();?>

code for ALTER Table

<?php
$this->startSetup()->run("
   ALTER TABLE {$this->getTable('faqs')}
   ADD COLUMN `preview` text AFTER `steps`
")->endSetup();
?>

code for Create New Table


<?php
$this->startSetup()->run("
  
DROP TABLE IF EXISTS {$this->getTable('mytable')};
CREATE TABLE {$this->getTable('
mytable')} (
`entity_id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`content` varchar(255) NOT NULL default '',
`status` smallint(6) NOT NULL default '0',
`created_time` datetime NULL,
`update_time` datetime NULL,
PRIMARY KEY (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

")->endSetup();
?>

code for DELETE Table
<?php
$this->startSetup()->run("
DELETE from table_name where column_name = value
")->endSetup();
?>


code for UPDATE Table
<?php
$this->startSetup()->run("
UPDATE table_name set column_name=value where column_name = value
")->endSetup();
?>

Thanks,


Enjoy Your Self


Monday, 30 September 2013

How to set default customer group to perticular website in magento


Hello Friends,

when you create new multiple website in magento and you 
have multiple customer group then you can assign one default 
customer group to particular website.



For this please follow the following steps:

Step 1 : Login Magento admin area

Step 2 : Go to System Tab From Menu

Sunday, 29 September 2013

How to set Error and success message in magento



Hello  Friends,

You can set error and success message in magento through the following code

Mage::getSingleton('core/session')->addSuccess(Mage::helper('module_name')->__('Please Type Your Success Message'));

Mage::getSingleton('core/session')->addError(Mage::helper('module_name')->__('Please Type Your Error Message'));

Now Code for display error and success message on phtml

Monday, 19 August 2013

How to set data custom phtml file and Add phtml file to another phtml file in magento


when you want to add .phtml file in other phtml file then you can use following code.


<?php echo $this->getLayout()->createBlock('catalog/product_price_template')->setTemplate('catalog/product/view/tierprices.phtml')->toHtml();?>

 when You need to set Data in phtml file when block is create like above. you can add folllowing code.

->setData('product', $_product);

you can use this like   

Friday, 7 June 2013

add yesno field in admin grid

this is way to add dropdown / select field in magento admin grid

file path : app\code\local\Module_Name\Company_Name\Block\Adminhtml\block_name\Grid.php


$yesnoOptions = array('0' => 'No','1' => 'Yes','' => 'No');

 $this->addColumn('is_vendor', array(
           'header'    => Mage::helper('customer')->__('Is Vendor'),
           'index'     => 'is_vendor',
'type'      => 'options',
'options'   => $yesnoOptions,
       ));

Thursday, 11 April 2013

Encode or Decode url in magento

you want to encode url very simple friend just simnple write following code and you can Encode url.

$url = "http://anantprajapati.blogspot.in/" ;

Mage::helper('core')->urlEncode($url);

you want to decode url very simple friend just simnple write following code and you can Decode url.

Mage::helper('core')->urlDecode($url);
 

Free Advertisement

Free Advertisement

Free Advertisement

Free Advertisement