Social Icons

twitterfacebookgoogle pluslinkedinemail

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

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=" '<?php echo '' . $_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 href="javascript:void(0);" target="_blank" title="<?php echo $this->__('Share on Twitter') ?>" class="link-twitter svg-replace" onclick=" '<?php echo '' . $_productName . '+' . $_productUrl; ?>' , '_blank' ,'height=500,width=500'); return false">
                            <img class="twitter-icon" style="" src="<?php echo $this->getSkinUrl(); ?>images/social-twitter-icon.png" />

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 --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.

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

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

Free Advertisement

Free Advertisement

Free Advertisement

Free Advertisement