<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<atom:link href="https://www.meghrajtechnosoft.com/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.meghrajtechnosoft.com</link>
	<description></description>
	<lastBuildDate>Wed, 31 Mar 2021 07:01:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.15</generator>

<image>
	<url>https://www.meghrajtechnosoft.com/wp-content/uploads/2020/10/fevecon.png</url>
	<title>PHP &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<link>https://www.meghrajtechnosoft.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to login as customer in Magento 2</title>
		<link>https://www.meghrajtechnosoft.com/how-to-login-as-customer-in-magento-2/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-login-as-customer-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 31 Mar 2021 07:01:01 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17923</guid>

					<description><![CDATA[<p>Enable Magento 2 log in as Customer Enable the feature In the admin page click&#160;Stores -&#62; Settings -&#62; Configuration. In the left panel, expand&#160;Customers&#160;and choose&#160;Login as Customer. Option Value Description Enable Login as Customer Yes / No Enable/Disable the Login [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-login-as-customer-in-magento-2/">How to login as customer in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h5 id="h-enable-magento-2-log-in-as-customer"><strong>Enable Magento 2 log in as Customer</strong></h5>



<h5><strong>Enable the feature</strong></h5>



<ol><li>In the admin page click&nbsp;<strong>Stores -&gt; Settings -&gt; Configuration</strong>.</li><li>In the left panel, expand&nbsp;<strong>Customers</strong>&nbsp;and choose&nbsp;<strong>Login as Customer</strong>.</li></ol>



<figure class="wp-block-image size-large"><img src="https://magegadgets.com/blog/wp-content/uploads/2021/03/magento-2-login-as-customer-settings-1024x545-2.png" alt="" class="wp-image-2167"/><figcaption><strong>Describe the fields in config</strong></figcaption></figure>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Option</strong></td><td><strong>Value</strong></td><td><strong>Description</strong></td></tr><tr><td>Enable Login as Customer</td><td>Yes / No</td><td>Enable/Disable the Login as Customer feature</td></tr><tr><td>Disable Page Cache For Admin User</td><td>Yes / No</td><td>If Yes, the page cache will be disabled for the admin user.</td></tr><tr><td>Store View To Login To</td><td>Auto-Detection (default) / Manual selection</td><td>Automatic uses the default store setting for that company user. Use Manual Selection if you want the Admin user to select the store view when logging in as a customer.</td></tr></tbody></table></figure>



<p>3. When complete, click&nbsp;<strong>Save Config</strong>&nbsp;and&nbsp;<strong>Clear Cache</strong></p>



<h5 id="h-using-login-as-customer"><strong>Using Login as Customer</strong></h5>



<p>Login as Customer allows you to see the site just as the customer does, and allows you to troubleshoot and take other actions as the customer. This feature requires an admin account with access to Customers &gt; Login as Customer in their role.</p>



<p>From&nbsp;Magento 2.4.1&nbsp;onward, customers will also have to enable&nbsp;<em>Allow remote shopping assistance</em>&nbsp;from their Dashboard before an admin can log in:</p>



<figure class="wp-block-image size-large"><img src="https://magegadgets.com/blog/wp-content/uploads/2021/03/magento-2-login-as-customer-edit-account-info.png" alt="" class="wp-image-2168"/></figure>



<p>If a customer has not enabled this option, then when an admin tries to log in to their account, an error message will be displayed: “<strong>The user has not enabled the &#8220;Allow remote shopping assistance&#8221; functionality. Contact the customer to discuss this user configuration.</strong>”</p>



<p>To skip this extra step, store administrators can disable the module&nbsp;<strong>LoginAsCustomerAssistance</strong>&nbsp;via command line:</p>



<pre><code>php bin/magento module:disable Magento_LoginAsCustomerAssistance</code></pre>



<p>then redeploy the site.</p>



<p><strong>Login as Customer</strong>&nbsp;appears on the following pages:</p>



<ul><li><strong>Customer Edit Page</strong></li></ul>



<ol><li>On the&nbsp;<em>Admin</em>&nbsp;sidebar, go to<strong>&nbsp;Customers -&gt; All Customers.</strong></li><li>Find the customer in the grid and click Edit in the&nbsp;<em>Action</em>&nbsp;column.</li><li>On the top control bar, click &#8220;<strong>Login as Customer</strong>&#8220;</li></ol>



<figure class="wp-block-image size-large"><img src="https://magegadgets.com/blog/wp-content/uploads/2021/03/magento-2-login-as-customer-edit-page-1024x538-1.png" alt="" class="wp-image-2169"/></figure>



<ul><li><strong>Order View Page</strong></li></ul>



<ol><li>On the&nbsp;<em>Admin</em>&nbsp;sidebar, go to&nbsp;<strong>Sales</strong>&nbsp;-&gt;&nbsp;<strong>Orders</strong>.</li><li>Find the order in the grid.</li><li>In the&nbsp;<em>Action</em>&nbsp;column, click&nbsp;<strong>View</strong>.</li><li>Click “<strong>Login as Customer</strong>”</li></ol>



<figure class="wp-block-image size-large"><img src="https://magegadgets.com/blog/wp-content/uploads/2021/03/magento-2-login-as-customer-order-view-page-1024x543-1.png" alt="" class="wp-image-2170"/></figure>



<ul><li><strong>Invoice View Page</strong></li><li><strong>Shipment View Page</strong></li><li><strong>Credit Memo View Page</strong></li></ul>



<p>Admin connection will display on the header.&nbsp;<strong>Close session</strong>&nbsp;button will end the login session clear related caches</p>



<figure class="wp-block-image size-large"><img src="https://magegadgets.com/blog/wp-content/uploads/2021/03/magento-2-login-as-customer-admin-connection-1024x759-1.png" alt="" class="wp-image-2171"/></figure>



<p><strong>READ MORE</strong>:<strong> <a href="https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/" class="rank-math-link">How to add update product Tier Price programmatically Magento 2?</a></strong></p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-login-as-customer-in-magento-2/">How to login as customer in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-login-as-customer-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to add update product Tier Price programmatically Magento 2?</title>
		<link>https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 24 Mar 2021 12:32:45 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17918</guid>

					<description><![CDATA[<p>You can add/update tier price to the Product from the Admin Panel Manually by click on the Products -&#62; Add or Edit Product -&#62; Price (Click on Advanced Pricing). If you have to task to add tier price in the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/">How to add update product Tier Price programmatically Magento 2?</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>You can add/update tier price to the Product from the Admin Panel Manually by click on the Products -&gt; Add or Edit Product -&gt; Price (Click on Advanced Pricing).</p>



<p>If you have to task to add tier price in the product programmatically in Magento using&nbsp;<strong>add()</strong>&nbsp;method from the&nbsp;<strong>ScopedProductTierPriceManagementInterface</strong>.</p>



<p>Core Method to add tier price,<br><strong>public function add($sku, \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice);</strong></p>



<p><strong>$sku&nbsp;</strong>is the Product SKU.<br><strong>$tierPrice</strong>&nbsp;is the ProductTierPriceInterface where you need to create ProductTierPriceInterfacefactory with set Qty(float), Price Value(float) and Customer Group id to add tier price.</p>



<pre><code>
    <?php
    namespace Jesadiya\AddTierPrice\Model;
    
    use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
    use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;
    
    class AddUpdateTierPrice
    {
        /**
         * @var ScopedProductTierPriceManagementInterface
         */
        private $tierPrice;
    
        /**
         * @var ProductTierPriceInterfaceFactory
         */
        private $productTierPriceFactory;
    
        public function __construct(
            ScopedProductTierPriceManagementInterface $tierPrice,
            ProductTierPriceInterfaceFactory $productTierPriceFactory
        ) {
            $this->tierPrice = $tierPrice;
            $this->productTierPriceFactory = $productTierPriceFactory;
        }
    
        /**
         * Add Tier price to the Product
         *
         * @return bool
         */
        public function addTierPrice()
        {
            $qty = 10.00;//must be float value.
            $price = 150.00;//must be float value.
            $customerGroupId = 8;
            $sku = '102-mts';
            try {
                $tierPriceData = $this->productTierPriceFactory->create();
                $tierPriceData->setCustomerGroupId($customerGroupId)
                    ->setQty($qty)
                    ->setValue($price);
                
                // If you want to set price_type as 'discount' use below code.
                
                $extensionAttributes = $tierPriceData->getExtensionAttributes();
                $extensionAttributes->setPercentageValue($price);
                $tierPriceData->setExtensionAttributes($extensionAttributes);
                
                $tierPrice = $this->tierPrice->add($sku, $tierPriceData);
            } catch (NoSuchEntityException $exception) {
                throw new NoSuchEntityException(__($exception->getMessage()));
            }
        }
    }   
    ?>
</code></pre>



<p>You can add tier price by call method,<br><strong>echo $tierPriceData = $this-&gt;addTierPrice();</strong></p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/">How to add update product Tier Price programmatically Magento 2?</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-add-update-product-tier-price-programmatically-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Use phtml File in Email Template in Magento 2</title>
		<link>https://www.meghrajtechnosoft.com/how-to-use-phtml-file-in-email-template-in-magento-2/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-use-phtml-file-in-email-template-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 23 Jan 2021 06:56:36 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17732</guid>

					<description><![CDATA[<p>Magento 2 store owners send emails to customers for not only marketing purposes but also for sending the order, shipping, and invoice details. For branding purposes, the merchants use custom email templates over the default one. When a customer receives [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-use-phtml-file-in-email-template-in-magento-2/">How to Use phtml File in Email Template in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Magento 2 store owners send emails to customers for not only marketing purposes but also for sending the order, shipping, and invoice details.</p>



<p>For branding purposes, the merchants use custom email templates over the default one. When a customer receives emails having the store name and logo with a well-organized email template design, it makes a great impression.</p>



<p>To check the email template design while creating, Magento 2 offers the preview option. That shows how the email template design will look in the frontend. However, the process is complicated and time-consuming as well.</p>



<p>Here are the steps that you have to follow for checking the output of the design of the email template from the admin panel:</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="880" height="289" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-grid-880x289-1.png" alt="" class="wp-image-17734" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-grid-880x289-1.png 880w, https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-grid-880x289-1-300x99.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-grid-880x289-1-768x252.png 768w" sizes="(max-width: 880px) 100vw, 880px" /></figure>



<ol><li><strong>Login to Magento 2 admin panel</strong></li><li><strong>Login to Magento 2 admin panel</strong></li><li><strong>Visit Marketing > Communications > Email Templates </strong></li><li><strong>Click on Add New Template</strong></li><li><strong>Select and click on Load Template</strong></li></ol>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="578" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-preview-1024x578.png" alt="" class="wp-image-17733" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-preview-1024x578.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-preview-300x169.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-preview-768x434.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2021/01/Email-template-preview.png 1248w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<ul><li>Now, click on <strong>Preview Template </strong>to see the changes that you have made.</li></ul>



<p>However, the programmatic method to <em><strong>use phtml file in Email template in Magento 2</strong></em> can be a better option that eliminates the above steps and removes the admin’s dependency.</p>



<h4><strong>Steps to Use phtml File in Email Template in Magento 2</strong></h4>



<p>Create <em><em><strong>app/code/Vendor/Extension/registration.php</strong></em></em></p>



<pre><code><?php 
Magento\Framework\Component\ComponentRegistrar;
 
ComponentRegistrar::register(
    ComponentRegistrar::MODULE, 
    'Vendor_Extension', 
    __DIR__
);</code></pre>



<p>Create <em><em><strong>app/code/Vendor/Extension/etc/module.xml</strong></em></em></p>



<pre><code><? 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="Vendor_Extension" setup_version="1.0.0">
    </module>
</config></code></pre>



<p>Create <em><strong>app/code/Vendor/Extension/etc/frontend/routes.xml</strong></em></p>



<pre><code><? xml version = "1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="extension" frontName="extension">
            <module name="Vendor_Extension"/>
        </route>
    </router>
</config></code></pre>



<p>Create <em><em><strong>app/code/Vendor/Extension/Controller/Index/Index.php</strong></em></em></p>



<?php namespace Vendor\Extension\Controller\Index;
 
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Action;
 
class Index extends Action
{
    protected $resultPageFactory;
 
  <pre><code> public function __construct(Context $context, PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }
 
    public function execute()
    {
        return $resultPage = $this->resultPageFactory->create();
    }
}</code></pre>



<p>Create <em><em><strong>app/code/Vendor/Extension/view/frontend/layout/extension_index_index.xml</strong></em></em></p>



<pre><code><?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Vendor\Extension\Block\Extension" name="extension_index_index"
                   template="Vendor_Extension::template_file.phtml"/>
        </referenceContainer>
    </body>
</page></code></pre>



<p>Create <em><strong>app/code/Vendor/Extension/Block/Extension.php</strong></em></p>



<pre><code><?php namespace Vendor\Extension\Block;
 
use Magento\Framework\View\Element\Template;
 
class Extension extends Template
{
    protected $_template = 'Vendor_Extension::template_file.phtml';
}</code></pre>



<p>Create <em><em><strong>app/code/Vendor/Extension/view/frontend/templates/template_file.phtml</strong></em></em></p>



<pre><code>This is the content of the phtml file 1</code></pre>



<p>Create <em><em><strong>app/code/Vendor/Extension/view/frontend/email/email_template.html</strong></em></em></p>



<pre><code><!--@subject Use phtml file in email template @-->
<!--@vars {"store url=\"\"":"Store Url", "skin url=\"images/logo_email.gif\" _area='frontend'":"Email Logo Image"} @-->
<!--@styles body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; } @--> {{template
config_path="design/email/header_template"}} 
{{var template|raw}}</code></pre>



<p>Create <em><strong>app/code/Vendor/Extension/etc/email_templates.xml</strong></em></p>



	
<?xml version="1.0"?>
 
<pre><code><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="my_custom_email_template"
              label="Use phtml file in email template"
              file="email_template.html"
              type="html"
              module="Vendor_Extension"
              area="frontend"
    />
 
</config></code></pre>



<p>Create <em><strong>app/code/Vendor/Extension/Helper/Data.php</strong></em></p>



<pre><code><?php

namespace Vendor\Extension\Helper;

use Magento\Framework\App\Area;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\View\Element\Template;
use Magento\Store\Model\App\Emulation;
use Magento\Framework\Translate\Inline\StateInterface;
use Vendor\Extension\Block\Extension;

class Data extends Template
{

private $transportBuilder;

private $appEmulation;

protected $_appState;

protected $_layout;

protected $inlineTranslation;

public function __construct(
Emulation $appEmulation,
TransportBuilder $transportBuilder,
\Magento\Framework\App\State $appState,
\Magento\Framework\View\LayoutInterface $layout,
StateInterface $state,
Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->transportBuilder = $transportBuilder;
$this->appEmulation = $appEmulation;
$this->_appState = $appState;
$this->_layout = $layout;
$this->inlineTranslation = $state;
}

/**
* Create block instance
*
* @param string|AbstractBlock $block
* @return AbstractBlock
* @throws LocalizedException
*/
public function createBlock($block)
{
if (is_string($block)) {
if (class_exists($block)) {
$block = $this->_layout->createBlock($block);
}
}
if (!$block instanceof AbstractBlock) {
throw new LocalizedException(__('Invalid block type: %1', $block));
}
return $block;
}
//call this function to send mail
public function sendEmail()
{
// this is an example and you can change template id,fromEmail,toEmail,etc as per your need.
$templateId = 'my_custom_email_template'; // template id
$fromEmail = 'frommail@email.com'; // sender Email id
$fromName = 'From Name'; // sender Name
$toEmail = 'tomail@email.com'; // receiver email id

try {

$block = $this->createBlock(Extension::class);//pass reference of block class here, connected with phtml file
// make sure in your block class there is
// $_template variable exist which specifies the reference to the phtml file like
// protected $_template = 'Vendor_Module::template.phtml';
$template = $this->_appState->emulateAreaCode(
Area::AREA_FRONTEND,
[$block, 'toHtml']
); // pass this variable as template variable of email template.
// template variables pass here
$templateVars = [
'template' => $template
];
// use this template variable in email template as {{var template|raw}}
$storeId = $this->_storeManager->getStore()->getId();

$from = ['email' => $fromEmail, 'name' => $fromName];
$this->inlineTranslation->suspend();

$templateOptions = [
'area' => Area::AREA_FRONTEND,
'store' => $storeId
];
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
->setTemplateOptions($templateOptions)
->setTemplateVars($templateVars)
->setFrom($from)
->addTo($toEmail)
->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
} catch (\Exception $e) {
$this->_logger->info($e->getMessage());
}
}
}</code></pre>



<p>That’s it.</p>



<p>If you have queries regarding this post, feel free to ask in the Comments section below.</p>



<p>I would be happy to help you.</p>



<p>Do consider sharing this article with Magento Community via social media.</p>



<p>Thank you.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-use-phtml-file-in-email-template-in-magento-2/">How to Use phtml File in Email Template in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-use-phtml-file-in-email-template-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Send Email with Attachment in Laravel</title>
		<link>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/</link>
					<comments>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 08:03:29 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17703</guid>

					<description><![CDATA[<p>This post will give you example of how to send email with attachment in laravel.In this article, we will implement sending attachment in mail in laravel. Alright, let’s dive into the steps.This tutorial of sending mail with attachment can be [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/">Send Email with Attachment in Laravel</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post will give you example of how to send email with attachment in laravel.In this article, we will implement sending attachment in mail in laravel. Alright, let’s dive into the steps.<br>This tutorial of sending mail with attachment can be implemented in following versions of laravel:- laravel 6,7,8.</p>



<p><strong>Step 1: Install Laravel</strong></p>



<p>I am going to explain step by step from scratch so, we need to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run below command:</p>



<pre><code>composer create-project --prefer-dist laravel/laravel blog</code></pre>



<p><strong>Step 2: Make Configuration</strong></p>



<p>In first step, you have to add send mail configuration with mail driver, mail host, mail port, mail username, mail password so laravel will use those sender details on email. So you can simply add as like following.</p>



<p><strong>.env</strong></p>



<pre><code>MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MAIL_ADDRESS
MAIL_PASSWORD=PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=MAIL_ADDRESS
MAIL_FROM_NAME="${APP_NAME}"</code></pre>



<p><strong>Step 3: Add Route</strong></p>



<p>In this is step we need to create routes for items listing. so open your &#8220;routes/web.php&#8221; file and add following route.</p>



<p><strong>routes/web.php</strong></p>



<pre><code><?php
  
    use Illuminate\Support\Facades\Route;
      
    use App\Http\Controllers\PDFController;
      
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
      
    Route::get('send-email-pdf', [PDFController::class, 'index']);</code></pre>



<p><strong>Step 4: Add Controller</strong></p>



<p>Here,we require to create new controller PDFController that will manage generatePDF method of route.</p>



<p>make sure you have "files" folder in public with following files.</p>



<p>So let's put below code.</p>



<p><strong>app/Http/Controllers/PDFController.php</strong></p>



<pre><code><?php
  
    namespace App\Http\Controllers;
      
    use PDF;
    use Mail;
      
    class PDFController extends Controller
    {
        /**
         * Write code on Method
         *
         * @return response()
         */
        public function index()
        {
            $data["email"] = "MAIL_ADDRESS";
            $data["title"] = "Sending Attachment in mail";
            $data["body"] = "This is Demo";
     
            $files = [
                public_path('files/160031367318.pdf'),
                public_path('files/1599882252.png'),
            ];
      
            Mail::send('emails.myTestMail', $data, function($message)use($data, $files) {
                $message->to($data["email"], $data["email"])
                        ->subject($data["title"]);
     
                foreach ($files as $file){
                    $message->attach($file);
                }
                
            });
     
            dd('Mail sent successfully');
        }
    }</code></pre>



<p><strong>Step 5: Create View File</strong></p>



<p>In Last step, let's create myTestMail.blade.php(resources/views/emails/myTestMail.blade.php) for layout of pdf file and put following code:</p>



<p><strong>resources/views/emails/myTestMail.blade.php</strong></p>



<pre><code><!DOCTYPE html>
<html>
<head>
    <title>meghrajtechnosoft.com</title>
</head>
<body>
    <h1>{{ $title }}</h1>
    <p>{{ $body }}</p>
     
    <p>Thank you</p>
</body>
</html></code></pre>



<p>Now you can run and check example.</p>



<p>It will send you email, let' see.</p>



<p><strong>Run Project:</strong></p>



<pre><code>php artisan serve</code></pre>



<p>Now hit URL as given below or you can run according to your routes:</p>



<pre><code>localhost:8000/send-email-pdf</code></pre>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/">Send Email with Attachment in Laravel</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/send-email-with-attachment-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sending Mail with Dynamic SMTP configuration</title>
		<link>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/</link>
					<comments>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 08:00:37 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17700</guid>

					<description><![CDATA[<p>Firstly, create a table in database and create all fields according to SMTP settings(.env file). Step:1 Create a Custom Mail Provider php artisan make:provider MailConfigServiceProvider Step:2 Fetch data from database in app/Providers/MailConfigServiceProvider</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/">Sending Mail with Dynamic SMTP configuration</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Firstly, create a table in database and create all fields according to SMTP settings(.env file).</p>



<p>Step:1  Create a Custom Mail Provider</p>



<pre><code>php artisan make:provider MailConfigServiceProvider</code></pre>



<p>Step:2 Fetch data from database in app/Providers/MailConfigServiceProvider</p>



<pre><code><?php

    namespace App\Providers;
    
    use Illuminate\Support\ServiceProvider;
    use DB;
    use Config;
    
    class MailConfigServiceProvider extends ServiceProvider
    {
        public function register()
        {
            $mail = DB::table('mail')->first();
            if ($mail) {
                $config = array(
                    'driver'     => $mail->driver,
                    'host'       => $mail->host,
                    'port'       => $mail->port,
                    'from'       => array('address' => $mail->from_address, 'name' => $mail->from_name),
                    'encryption' => $mail->encryption,
                    'username'   => $mail->username,
                    'password'   => $mail->password,
                    'sendmail'   => '/usr/sbin/sendmail -bs',
                    'pretend'    => false,
                );
                Config::set('mail', $config);
            }
        }
    
        public function boot()
        {
            //
        }
    }</code></pre>



<p>Step:3&nbsp; Make routes in web.php</p>



<pre><code>Route::get('change-email-settings','MailController@viewForm');

Route::post('email-settings','MailController@create')-&gt;name('createConfiguration');

Route::get('send-mail','MailController@sendMail');</code></pre>



<p>Step:4 Now create a controller</p>



<pre><code>php artisan make:controller MailController</code></pre>



<p>Step:5 Write your code in app/http/Controller/MailController.php</p>



<pre><code><?php

    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use DB;
    use Config;
    use Mail;
    
    class MailController extends Controller
    {
        public function viewForm()
        {
            return view('mail.add');
        }
    
        public function create(Request $request)
        {
            $insert = $request->all();
            unset($insert['_token']);
            unset($insert['btn']);
            DB::table('mail')->insert($insert);
            return view('mail.add');
        }
    
        public function sendMail()
        {
            $content = "<html>";
    
            $content .= "<head>";
            $content .= 	"<title>Test Template</title>";
            $content .= "</head>";
    
            $content .= "<body>";
            $content .= 	"<p>This is Test Template</p>";
            $content .= "</body>";
    
            $content .= "</html>";
    
            $mailTo = "FROM_MAIL_ADDRESS";
            Mail::send(array(),array(), function($message) use ($content,$mailTo)
            {
                $message->to($mailTo)
                        ->subject('Test Dynamic SMTP Config')
                        ->from(Config::get('mail.from.address'),Config::get('mail.from.name'))
                        ->setBody($content, 'text/html');
                echo 'Mail Sent Successfully';
            });
        }
    }</code></pre>



<p>Step: 6 Now create a blade file,name it according to your convenience</p>



<pre><code><!DOCTYPE html>
    <html>
    <head>
        <title>Change Email Configuration</title>
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-lg-6 m-auto">
                    <h2 class="ml-5">Change Email Configurations</h2>
                    <form method="POST" action="{{ route('createConfiguration') }}">
                        @csrf
                        <label>Driver:</label>
                        <input type="text" name="driver" class="form-control"><br>
                        <label>Host:</label>
                        <input type="text" name="host" class="form-control"><br>
                        <label>Port:</label>
                        <input type="text" name="port" class="form-control"><br>
                        <label>From Address:</label>
                        <input type="text" name="from_address" class="form-control"><br>
                        <label>From Name:</label>
                        <input type="text" name="from_name" class="form-control"><br>
                        <label>Encryption:</label>
                        <input type="text" name="encryption" class="form-control"><br>
                        <label>Username:</label>
                        <input type="text" name="username" class="form-control"><br>
                        <label>Password:</label>
                        <input type="password" name="password" class="form-control"><br>
                        <input type="submit" name="btn" class="btn btn-primary"><br><br>
                    </form>
                </div>
            </div>
        </div>
    </body>
    </html></code></pre>



<p>Hit a url as shown below to fill form and add new SMTP details</p>



<pre><code>localhost:8000/change-email-settings</code></pre>



<p>Hit a url as shown below to send mail</p>



<pre><code>localhost:8000/send-mail</code></pre>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/">Sending Mail with Dynamic SMTP configuration</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/sending-mail-with-dynamic-smtp-configuration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Export CSV file in Laravel Example</title>
		<link>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 22 Dec 2020 12:22:38 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17558</guid>

					<description><![CDATA[<p>In Laravel projects export csv and excel file from database more required. If you optate to exporting your data utilizing csv file in your projects version 5, 6 or 7 then here we make a simple step by step facile [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/">How to Export CSV file in Laravel Example</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In Laravel projects export csv and excel file from database more required. If you optate to exporting your data utilizing csv file in your projects version 5, 6 or 7 then here we make a simple step by step facile steps for export csv file utilizing php function not utilizing any library. In recent project we require to export the rows from the database in laravel but I checked in google more then sites utilizing library but if we engender csv utilizing php function then why we utilize any package. So guys lets start to export CSV Data in laravel example utilizing facile steps.</p>



<p>In first step you require to integrate a route in your web.php file.</p>



<h5 id="h-step-1-add-route">Step 1: Add Route</h5>



<pre><code>Route::get('/tasks', 'TaskController@exportCsv');
</code></pre>



<h5 id="h-step-2-in-blade-file">Step 2: In Blade File</h5>



<p>In this step add a export function in you js file to exporting data.</p>



<pre><code><script>
   function exportTasks(_this) {
      let _url = $(_this).data('href');
      window.location.href = _url;
   }
</script></code></pre>



<h5 id="h-step-4-in-your-controller">Step 4: In your Controller</h5>



<p>In last step you need to add a function to export rows in csv in laravel 5, 6 or 7 application. Here we get all projects but you can modify your code which you want to export you can add in column and tasks.</p>



<pre><code>public function exportCsv(Request $request)
{
   $fileName = 'tasks.csv';
   $tasks = Task::all();

        $headers = array(
            "Content-type"        =&gt; "text/csv",
            "Content-Disposition" =&gt; "attachment; filename=$fileName",
            "Pragma"              =&gt; "no-cache",
            "Cache-Control"       =&gt; "must-revalidate, post-check=0, pre-check=0",
            "Expires"             =&gt; "0"
        );

        $columns = array('Title', 'Assign', 'Description', 'Start Date', 'Due Date');

        $callback = function() use($tasks, $columns) {
            $file = fopen('php://output', 'w');
            fputcsv($file, $columns);

            foreach ($tasks as $task) {
                $row['Title']  = $task-&gt;title;
                $row['Assign']    = $task-&gt;assign-&gt;name;
                $row['Description']    = $task-&gt;description;
                $row['Start Date']  = $task-&gt;start_at;
                $row['Due Date']  = $task-&gt;end_at;

                fputcsv($file, array($row['Title'], $row['Assign'], $row['Description'], $row['Start Date'], $row['Due Date']));
            }

            fclose($file);
        };

        return response()-&gt;stream($callback, 200, $headers);
    }</code></pre>



<p>i hope you like this article.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/">How to Export CSV file in Laravel Example</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-export-csv-file-in-laravel-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MAGENTO 2: CHANGING PRODUCT ATTRIBUTE TYPE</title>
		<link>https://www.meghrajtechnosoft.com/magento-2-changing-product-attribute-type/</link>
					<comments>https://www.meghrajtechnosoft.com/magento-2-changing-product-attribute-type/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 08 Dec 2020 13:01:27 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17546</guid>

					<description><![CDATA[<p>In&#160;Magento 2, once we create an attribute type, we cannot change it by configuring the admin, but it is possible to change the attribute type programmatically. For example, let us assume the following – an attribute called “size”, the input [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/magento-2-changing-product-attribute-type/">MAGENTO 2: CHANGING PRODUCT ATTRIBUTE TYPE</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In&nbsp;<a href="https://www.dckap.com/magento-services/magento-development-services.htm" target="_blank" rel="noopener">Magento 2</a>, once we create an attribute type, we cannot change it by configuring the admin, but it is possible to change the attribute type programmatically.</p>



<p>For example, let us assume the following – an attribute called “size”, the input type of that attribute as “Text” and approximately 3000 products in the store. It is also assumed that we have already entered various attribute values like ‘small’, ‘medium’ and ‘large’, for, say, 1000 products.</p>



<p>At a later point in time, we begin to feel that the current ‘text’ attribute type is cumbersome and time-consuming. We would, instead, prefer to have a ‘dropdown’ attribute type. This drop down will be used to choose the values ‘S’ or ‘M’ or ‘L’ instead of typing the same in the ‘text’ attribute type.</p>



<h4 id="h-magento-2-changing-product-attribute-type"><strong>Magento 2: Changing Product Attribute Type</strong></h4>



<p>Admin does not allow you to change the attribute type once it is created and values have been entered. But as mentioned above we can achieve this programmatically.We have to do this without losing the existing attribute values that (in the above example) have been entered for 1000 products.</p>



<p>When the attribute is in “Text”, the product value of this attribute is stored in the “catalog_product_entity_varchar”, but when we change the attribute type as “Dropdown”, the product value will be stored in “catalog_product_entity_int”.</p>



<p>By using the below code we can change the product attribute type from text box to drop down in a short time without losing the existing values.</p>



<p>Place this code in the root directory of Magento 2 files and execute it.</p>



<pre><code><?php
error_reporting(1);
ini_set('max_execution_time', 0);
 
use \Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$url = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');
$mediaurl= $storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
$state = $objectManager->get('\Magento\Framework\App\State');
$state->setAreaCode('frontend');
 
// Attribute Id that we need to change
$attributeId = 162;  
 
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
 
// Get the product values that are already stored in the database for given attribute
$catalog_product_entity_varchar = $resource->getTableName('catalog_product_entity_varchar');
$attribute_values = $connection->fetchAll("SELECT DISTINCT attribute_id, value FROM $catalog_product_entity_varchar where attribute_id = $attributeId");
 
if(!empty($attribute_values)) {
 
          foreach ($attribute_values as $_attribute_values) {
 
                     $attribute_values = $connection->fetchRow("SELECT count(*) as cnt FROM `eav_attribute_option` where attribute_id = $attributeId;");
                     $count = $attribute_values['cnt'] + 1;
                     // Insert the product values as an option for a given attribute
                    $eav_attribute_option = $resource->getTableName('eav_attribute_option');
                    $sql = "insert into $eav_attribute_option(option_id, attribute_id, sort_order) values (null, $attributeId, $count)";
                     try {
                               $resp = $connection->query($sql);    
                    } catch (Exception $e) {
                              echo '<pre>';  print_r($e->getMessage());
                    }
     
                    $lastInsertId = $connection->lastInsertId();
 
                    $eav_attribute_option_value = $resource->getTableName('eav_attribute_option_value');
                    $sql = "insert into $eav_attribute_option_value(value_id, option_id, store_id, value) values (null, $lastInsertId, 0, '$_attribute_values[value]')";
                    try {
                              $resp = $connection->query($sql);    
                    } catch (Exception $e) {
                              echo '<pre>';  print_r($e->getMessage());
                    }
 
                    $sql = "insert into $eav_attribute_option_value(value_id, option_id, store_id, value) values (null, $lastInsertId, 1, '$_attribute_values[value]')";
                    try {
                              $resp = $connection->query($sql);    
                    } catch (Exception $e) {
                              echo '<pre>';  print_r($e->getMessage());
                    }
          }
}
 
$catalog_product_entity_varchar = $resource->getTableName('catalog_product_entity_varchar');
$attribute_values = $connection->fetchAll("SELECT * FROM $catalog_product_entity_varchar where attribute_id = $attributeId");
 
if(!empty($attribute_values)) {
          foreach ($attribute_values as $_attribute_values) {
 
                    // Get the option id for the specific product
                    $option_values = $connection->fetchRow("SELECT * FROM `eav_attribute_option` as eao INNER JOIN `eav_attribute_option_value` as eaov on eao.option_id = eaov.option_id WHERE eao.attribute_id = $attributeId and eaov.store_id = 1 and eaov.value = '$_attribute_values[value]'");
     
                    if(!empty($option_values)) {
                              $catalog_product_entity_int = $resource->getTableName('catalog_product_entity_int');
                              $product_values_exist = $connection->fetchRow("SELECT value_id FROM $catalog_product_entity_int WHERE attribute_id = $attributeId and entity_id = $_attribute_values[entity_id]");
 
                              if(empty($product_values_exist)) {
                                        $sql = "insert into $catalog_product_entity_int(value_id, attribute_id, store_id, entity_id, value) values (null, $attributeId, 0, $_attribute_values[entity_id], $option_values[option_id])";
                                        try {
                                                 $resp = $connection->query($sql);    
                                        } catch (Exception $e) {
                                                  echo '<pre>';  print_r($e->getMessage());
                                        }
 
                              } else {
                                        $sql = "Update $catalog_product_entity_int set value = $option_values[option_id] WHERE attribute_id = $attributeId and entity_id = $_attribute_values[entity_id]";
                                        try {
                                                  $resp = $connection->query($sql);    
                                        } catch (Exception $e) {
                                                  echo '<pre>';  print_r($e->getMessage());
                                        }
                              }
                    }
          }
}
 
// Change the attribute type to dropdown
$eav_attribute = $resource->getTableName('eav_attribute');
$sql = "UPDATE $eav_attribute SET `backend_type` = 'int', `frontend_input` = 'select', `source_model` = 'Magento\\\Eav\\\Model\\\Entity\\\Attribute\\\Source\\\Table' WHERE `attribute_id` = $attributeId";
try {
          $resp = $connection->query($sql);
} catch (Exception $e) {
          echo '<pre>';  print_r($e->getMessage());
}
 
$catalog_eav_attribute = $resource->getTableName('catalog_eav_attribute');
$sql = "UPDATE $catalog_eav_attribute SET `is_filterable` = 1, is_comparable = 1, is_visible_on_front = 1, is_html_allowed_on_front = 1, is_filterable_in_search = 1, used_in_product_listing = 1 WHERE `attribute_id` = $attributeId";
try {
          $resp = $connection->query($sql);
} catch (Exception $e) {
          echo '<pre>';  print_r($e->getMessage());
}</code></pre>



<h4><strong>How To Execute This Code?</strong></h4>



<p><strong>Step 1</strong>&nbsp;– Copy the above code and paste the same in a new file called sample.php in the Magento 2 root directory.</p>



<p><strong>Step 2</strong>&nbsp;– Execute the sample.php file by entering the browser URL along with the file name (example –&nbsp;www.yourdomainname.com/sample.php)</p>



<p><strong>Step 3</strong>&nbsp;– Once the above code is executed, please do not forget to reindex and also clear all the cache.</p>



<p>Hope the blog and code were useful. Feel free to let us know your comments and feedback.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/magento-2-changing-product-attribute-type/">MAGENTO 2: CHANGING PRODUCT ATTRIBUTE TYPE</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/magento-2-changing-product-attribute-type/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Get Order Information From Order ID in Magento 2 (Updated 2020)</title>
		<link>https://www.meghrajtechnosoft.com/get-order-information-from-order-id-in-magento-2-updated-2020/</link>
					<comments>https://www.meghrajtechnosoft.com/get-order-information-from-order-id-in-magento-2-updated-2020/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 08 Dec 2020 12:54:36 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17544</guid>

					<description><![CDATA[<p>In this code snippet, we will see how to fetch order information such as order items, payment, customer, billing, and shipping details from order id. You can get order id at the checkout success page from the checkout session object. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/get-order-information-from-order-id-in-magento-2-updated-2020/">Get Order Information From Order ID in Magento 2 (Updated 2020)</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this code snippet, we will see how to fetch order information such as order items, payment, customer, billing, and shipping details from order id. You can get order id at the checkout success page from the checkout session object.</p>



<h4 id="h-get-order-information-from-order-id-using-repository">Get Order Information From Order ID using Repository</h4>



<p>Magento 2 recommended using Repository to get the entity data. Below is the code snippet to get order information from the order id using the order repository.</p>



<pre><code><?php
Class Codextblog {
 
protected $orderRepository;
 
public function __construct(
    \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
){
    $this->orderRepository = $orderRepository;
}
 
public function MyFunction() 
{
   $orderId = 2;
   $order = $this->orderRepository->get($orderId);
   echo $order->getIncrementId();
   echo $order->getGrandTotal();
   echo $order->getSubtotal();
 
   //fetch whole payment information
   print_r($order->getPayment()->getData());
  
    
   //fetch customer information
   echo $order->getCustomerId();
   echo $order->getCustomerEmail();
   echo $order->getCustomerFirstname();
   echo $order->getCustomerLastname();
 
   //fetch whole billing information
   print_r($order->getBillingAddress()->getData());
  
   //Or fetch specific billing information
   echo $order->getBillingAddress()->getCity();
   echo $order->getBillingAddress()->getRegionId();
   echo $order->getBillingAddress()->getCountryId();
  
   //fetch whole shipping information
   print_r($order->getShippingAddress()->getData());
  
   //Or fetch specific shipping information
   echo $order->getShippingAddress()->getCity();
   echo $order->getShippingAddress()->getRegionId();
   echo $order->getShippingAddress()->getCountryId();   
}
}</code></pre>



<p><strong>Note:</strong>&nbsp;For the demonstrated purpose we have used Objectmanager.Codextblog never recommend the direct use of ObjectManager.One should always use a constructor method to&nbsp;<a href="http://dev.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/" target="_blank" rel="noreferrer noopener">instant an object</a>.</p>



<pre><code><?php
$orderid = 2;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch whole order information
print_r($order->getData());
 
//Or fetch specific information
echo $order->getIncrementId();
echo $order->getGrandTotal();
echo $order->getSubtotal();
?></code></pre>



<h4 id="h-get-order-items-information">Get Order Items Information</h4>



<pre><code><?php
$orderid = 2;
 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//Loop through each item and fetch data
foreach ($order->getAllItems() as $item)
{
   //fetch whole item information
   print_r($item->getData());
 
   //Or fetch specific item information
   echo $item->getId();
   echo $item->getProductType();
   echo $item->getQtyOrdered();
   echo $item->getPrice(); 
     
}
?></code></pre>



<h4 id="h-get-order-payment-information">Get Order Payment Information</h4>



<pre><code><?php
$orderid = 2;
 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch whole payment information
print_r($order->getPayment()->getData());
 
//Or fetch specific payment information
echo $order->getPayment()->getAmountPaid();
echo $order->getPayment()->getMethod();
echo $order->getPayment()->getAdditionalInformation('method_title');
?></code></pre>



<h4 id="h-get-order-customer-information">Get Order Customer Information</h4>



<pre><code><?php
$orderid = 2;
 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch customer information
echo $order->getCustomerId();
echo $order->getCustomerEmail();
echo $order->getCustomerFirstname();
echo $order->getCustomerLastname();
?></code></pre>



<h4 id="h-get-order-shipping-and-billing-information">Get Order Shipping And Billing Information</h4>



<pre><code><?php
$orderid = 2;
 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch whole billing information
print_r($order->getBillingAddress()->getData());
 
//Or fetch specific billing information
echo $order->getBillingAddress()->getCity();
echo $order->getBillingAddress()->getRegionId();
echo $order->getBillingAddress()->getCountryId();
 
//fetch whole shipping information
print_r($order->getShippingAddress()->getData());
 
//Or fetch specific shipping information
echo $order->getShippingAddress()->getCity();
echo $order->getShippingAddress()->getRegionId();
echo $order->getShippingAddress()->getCountryId();
 
?></code></pre>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/get-order-information-from-order-id-in-magento-2-updated-2020/">Get Order Information From Order ID in Magento 2 (Updated 2020)</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/get-order-information-from-order-id-in-magento-2-updated-2020/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Instantiate a Model in Magento 2</title>
		<link>https://www.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 08 Dec 2020 12:49:20 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17542</guid>

					<description><![CDATA[<p>We all know that in Magento 1 We can easily instantiate model using&#160;Mage::getModel&#160;and&#160;Mage::getSingleton&#160;methods. But instantiate a model in Magento 2 something different. In Magento 2 we can instantiate a model using&#160;Object Manager. Yes, you heard it correctly, ObjectManager is a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/">How to Instantiate a Model in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We all know that in Magento 1 We can easily instantiate model using&nbsp;<strong>Mage::getModel</strong>&nbsp;and&nbsp;<strong>Mage::getSingleton</strong>&nbsp;methods. But instantiate a model in Magento 2 something different.</p>



<p>In Magento 2 we can instantiate a model using&nbsp;<strong>Object Manager</strong>. Yes, you heard it correctly, ObjectManager is a replacement for getModel and getSingleton Method.</p>



<p>There are two approaches you can invoke ObjectManager in Magento 2 to instantiate a model or to get the model collection.</p>



<h4 id="h-approach-1-using-objectmanager-directly-anywhere">Approach 1: Using ObjectManager Directly anywhere</h4>



<p>Let’s say we want to get product collection in our Magento 2 custom module phtml file. You can get this using below code.</p>



<pre><code><?php 
 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
 $productCollection->addAttributeToSelect('*');
 $productCollection->load();
 foreach ($productCollection as $product) {
    echo "<pre>";
    print_r($product->getData());     
     
}</code></pre>



<h4>Approach 2: Inject model into Constructor and instantiate</h4>



<p>Second and recommended approach of instantiating a model in Magento 2 is using a constructor. To get product collection in your custom phtml file, You need to create a block file inject the product model into the constructor of that block file.<br>&nbsp;<br><strong>Step 1: Create Block.php file</strong><br>For example our block file Index.php is under&nbsp;<code>app/code/Codextblog/Pcollection/Block/Index</code></p>



<pre><code><?php
namespace Codextblog\Pcollection\Block\Index;
class Index extends \Magento\Framework\View\Element\Template {
 
protected $_productCollectionFactory;
 
public function __construct(
    \Magento\Backend\Block\Template\Context $context,
    \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
    array $data = [] 
) 
   {
    $this->_productCollectionFactory = $productCollectionFactory;    
    parent::__construct($context, $data);
   }
   public function getProductCollection()
    {
        $collection = $this->_productCollectionFactory->create();
        $collection->addAttributeToSelect('*');
        return $collection;
    }
}</code></pre>



<p><strong>Step 2: Call getProductCollection in your phtml file</strong><br>For example our phtml file Index.phtml is under&nbsp;<code>app/code/Codextblog/Pcollection/view/frontend/templates</code></p>



<pre><code><?php
$pCollection = $block->getProductCollection();
foreach ($pCollection as $product) {
    echo "<pre>";
    print_r($product->getData());     
     
}</code></pre>



<p>This is how you can get product collection in your custom phtml file.<br>&nbsp;</p>



<h3>Which Approach to use?</h3>



<p>Well, it is a very tedious task to go with approach 2 to just get product collection. But as per&nbsp;<a href="http://devdocs.magento.com/guides/v2.0/extension-dev-guide/object-manager.html" target="_blank" rel="noopener">Magento Official doc</a>, you should always use constructor method to instantiate a model in Magento 2 to maintain the implementation of Dependency Injection.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/">How to Instantiate a Model in Magento 2</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-instantiate-a-model-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Install Different PHP (5.6, 7.0 and 7.1) Versions in Ubuntu</title>
		<link>https://www.meghrajtechnosoft.com/how-to-install-different-php-5-6-7-0-and-7-1-versions-in-ubuntu/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-install-different-php-5-6-7-0-and-7-1-versions-in-ubuntu/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 07 Dec 2020 08:06:07 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17473</guid>

					<description><![CDATA[<p>PHP&#160;(recursive acronym for&#160;PHP: Hypertext Preprocessor) is an open source, popular general-purpose scripting language that is widely-used and best suited for developing websites and web-based applications. It is a server-side scripting language that can be embedded in HTML. Currently, there are [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-install-different-php-5-6-7-0-and-7-1-versions-in-ubuntu/">How to Install Different PHP (5.6, 7.0 and 7.1) Versions in Ubuntu</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>PHP</strong>&nbsp;(recursive acronym for&nbsp;<strong>PHP: Hypertext Preprocessor</strong>) is an open source, popular general-purpose scripting language that is widely-used and best suited for developing websites and web-based applications. It is a server-side scripting language that can be embedded in HTML.</p>



<p>Currently, there are three supported versions of&nbsp;<strong>PHP</strong>, i.e&nbsp;<strong>PHP 5.6</strong>,&nbsp;<strong>7.0</strong>&nbsp;and&nbsp;<strong>7.1</strong>. Meaning&nbsp;<strong>PHP 5.3</strong>,&nbsp;<strong>5.4</strong>&nbsp;and&nbsp;<strong>5.5</strong>&nbsp;have all reached end of life; they are no longer supported with security updates.</p>



<p>In this article, we will explain how to install all the supported versions of&nbsp;<strong>PHP</strong>&nbsp;in&nbsp;<strong>Ubuntu</strong>&nbsp;and its derivatives with most requested PHP extensions for both&nbsp;<strong>Apache</strong>&nbsp;and&nbsp;<strong>Nginx</strong>&nbsp;web servers using a&nbsp;<strong>Ondřej Surý PPA</strong>. We will also explain how to set default version of PHP to be used on the Ubuntu system.</p>



<p>Note that&nbsp;<strong>PHP 7.x</strong>&nbsp;is the supported stable version in the Ubuntu software repositories, you can confirm this by running the&nbsp;apt command&nbsp;below.</p>



<pre><code>$sudo apt show php
OR
$ sudo apt show php -a</code></pre>



<pre><code>Package: php
Version: 1:7.0+35ubuntu6
Priority: optional
Section: php
Source: php-defaults (35ubuntu6)
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 11.3 kB
Depends: php7.0
Supported: 5y
Download-Size: 2,832 B
APT-Sources: http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
Description: server-side, HTML-embedded scripting language (default)
 PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
 open source general-purpose scripting language that is especially suited
 for web development and can be embedded into HTML.
 .
 This package is a dependency package, which depends on Debian's default
 PHP version (currently 7.0).</code></pre>



<p>To install the default PHP version from the Ubuntu software repositories, use the command below.</p>



<pre><code>$ sudo apt install php</code><pre>



<h3 id="h-install-php-5-6-7-0-7-1-on-ubuntu-using-ppa"><strong>Install PHP (5.6, 7.0, 7.1) on Ubuntu Using PPA</strong></h3>



<p><strong>1.</strong>&nbsp;First start by adding&nbsp;<strong>Ondřej Surý PPA</strong>&nbsp;to install different versions of PHP –&nbsp;<strong>PHP 5.6</strong>,&nbsp;<strong>PHP 7.0</strong>&nbsp;and&nbsp;<strong>PHP 7.1</strong>&nbsp;on Ubuntu system.</p>



<pre><code>$ sudo apt install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="885" height="706" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Add-PPA-in-Ubuntu-1.png" alt="" class="wp-image-17484" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Add-PPA-in-Ubuntu-1.png 885w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Add-PPA-in-Ubuntu-1-300x239.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Add-PPA-in-Ubuntu-1-768x613.png 768w" sizes="(max-width: 885px) 100vw, 885px" /></figure>



<p><strong>2.</strong>&nbsp;Next, update the system as follows.</p>



<pre><code>$ sudo apt-get update</code></pre>



<p><strong>3.</strong>&nbsp;Now install different supported versions of PHP as follows.</p>



<h3 id="h-for-apache-web-server">For Apache Web Server</h3>



<pre><code>$ sudo apt install php5.6   [PHP 5.6]
$ sudo apt install php7.0   [PHP 7.0]
$ sudo apt install php7.1   [PHP 7.1]
$ sudo apt install php7.2   [PHP 7.2]
$ sudo apt install php7.3   [PHP 7.3]</code></pre>



<h3 id="h-for-nginx-web-server">For Nginx Web Server</h3>



<pre><code>$ sudo apt install php5.6-fpm   [PHP 5.6]
$ sudo apt install php7.0-fpm   [PHP 7.0]
$ sudo apt install php7.1-fpm   [PHP 7.1]
$ sudo apt install php7.2-fpm   [PHP 7.2]
$ sudo apt install php7.3-fpm   [PHP 7.3]</code></pre>



<p><strong>4.</strong>&nbsp;To install any PHP modules, simply specify the PHP version and use the auto-completion functionality to view all modules as follows.</p>



<pre><code>------------ press Tab key for auto-completion ------------ 
$ sudo apt install php5.6 
$ sudo apt install php7.0 
$ sudo apt install php7.1
$ sudo apt install php7.2
$ sudo apt install php7.3 </code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="762" height="266" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Search-PHP-Modules.png" alt="" class="wp-image-17476" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Search-PHP-Modules.png 762w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Search-PHP-Modules-300x105.png 300w" sizes="(max-width: 762px) 100vw, 762px" /></figure>



<p><strong>5.</strong>&nbsp;Now you can install most required PHP modules from the list..</p>



<pre><code>------------ Install PHP Modules ------------
$ sudo apt install php5.6-cli php5.6-xml php5.6-mysql 
$ sudo apt install php7.0-cli php7.0-xml php7.0-mysql 
$ sudo apt install php7.1-cli php7.1-xml php7.1-mysql
$ sudo apt install php7.2-cli php7.2-xml php7.2-mysql 
$ sudo apt install php7.3-cli php7.3-xml php7.3-mysql  </code><pre>



<p><strong>6.</strong>&nbsp;Finally, verify your default PHP version used on your system like this.</p>



<pre><code>$ php -v </code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="803" height="266" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png" alt="" class="wp-image-17477" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png 803w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-300x99.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-768x254.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></figure>



<h3 id="h-set-default-php-version-in-ubuntu">Set Default PHP Version in Ubuntu</h3>



<p><strong>7.</strong>&nbsp;You can set the default PHP version to be used on the system with the&nbsp;<strong>update-alternatives</strong>&nbsp;command, after setting it, check the PHP version to confirm as follows.</p>



<pre><code>------------ Set Default PHP Version 5.6 ------------
$ sudo update-alternatives --set php /usr/bin/php5.6</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="803" height="266" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png" alt="" class="wp-image-17477" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png 803w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-300x99.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-768x254.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></figure>



<pre><code>------------ Set Default PHP Version 7.0 ------------
$ sudo update-alternatives --set php /usr/bin/php7.0</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="803" height="266" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png" alt="" class="wp-image-17477" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu.png 803w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-300x99.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Set-PHP-5.6-in-Ubuntu-768x254.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></figure>



<pre><code>------------ Set Default PHP Version 7.1 ------------
$ sudo update-alternatives --set php /usr/bin/php7.1</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="804" height="244" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/pppSet-PHP-7.0-in-Ubuntu.png" alt="" class="wp-image-17475" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/pppSet-PHP-7.0-in-Ubuntu.png 804w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/pppSet-PHP-7.0-in-Ubuntu-300x91.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/pppSet-PHP-7.0-in-Ubuntu-768x233.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



<p><strong>8.</strong>&nbsp;To set the PHP version that will work with&nbsp;<strong>Apache</strong>&nbsp;web server, use the commands below. First disable the current version with the&nbsp;<strong>a2dismod</strong>&nbsp;command and then enable the one you want with the&nbsp;<strong>a2enmod</strong>&nbsp;command.</p>



<pre><code>$ sudo a2dismod php7.0
$ sudo a2enmod php7.1
$ sudo systemctl restart apache2</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="623" height="323" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Enable-Disable-PHP-Modules-for-Apache.png" alt="" class="wp-image-17482" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Enable-Disable-PHP-Modules-for-Apache.png 623w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/Enable-Disable-PHP-Modules-for-Apache-300x156.png 300w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<p><strong>9.</strong>&nbsp;After switching from one version to another, you can find your PHP configuration file, by running the command below.</p>



<pre><code>------------ For PHP 5.6 ------------
$ sudo update-alternatives --set php /usr/bin/php5.6
$ php -i | grep "Loaded Configuration File"

------------ For PHP 7.0 ------------
$ sudo update-alternatives --set php /usr/bin/php7.0
$ php -i | grep "Loaded Configuration File"

------------ For PHP 7.1 ------------
$ sudo update-alternatives --set php /usr/bin/php7.1
$ php -i | grep "Loaded Configuration File"

------------ For PHP 7.2 ------------
$ sudo update-alternatives --set php /usr/bin/php7.2
$ php -i | grep "Loaded Configuration File"

------------ For PHP 7.3 ------------
$ sudo update-alternatives --set php /usr/bin/php7.3
$ php -i | grep "Loaded Configuration File"</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="804" height="420" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/aaFind-PHP-Configuration-File.png" alt="" class="wp-image-17478" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/aaFind-PHP-Configuration-File.png 804w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/aaFind-PHP-Configuration-File-300x157.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2020/12/aaFind-PHP-Configuration-File-768x401.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure>



<p>In this article, we showed how to install all the supported versions of PHP in Ubuntu and its derivatives. If you have any queries or thoughts to share, do so via the feedback form below.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-install-different-php-5-6-7-0-and-7-1-versions-in-ubuntu/">How to Install Different PHP (5.6, 7.0 and 7.1) Versions in Ubuntu</a> appeared first on <a rel="nofollow" href="https://www.meghrajtechnosoft.com">MeghRaj TechnoSoft - Web, App, E-commerce Development  Agency In India.</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.meghrajtechnosoft.com/how-to-install-different-php-5-6-7-0-and-7-1-versions-in-ubuntu/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
