<?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>admin &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<atom:link href="https://www.meghrajtechnosoft.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.meghrajtechnosoft.com</link>
	<description></description>
	<lastBuildDate>Tue, 23 May 2023 11:37:07 +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>admin &#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 Implement WellSaid Labs TTS API In Laravel?</title>
		<link>https://www.meghrajtechnosoft.com/how-to-implement-wellsaid-labs-tts-api-in-laravel/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-implement-wellsaid-labs-tts-api-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 23 May 2023 11:10:21 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=18213</guid>

					<description><![CDATA[<p>WellSaid Labs text-to-speech API service allows you to augment existing applications with a life-like synthetic voice. Step 1:&#160; First, we have to create an account on https://wellsaidlabs.com website. Step 2: After Sign-up, go to the https://developer.wellsaidlabs.com/#!/ link and you have [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-implement-wellsaid-labs-tts-api-in-laravel/">How to Implement WellSaid Labs TTS API 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>WellSaid Labs text-to-speech API service allows you to augment existing applications with a life-like synthetic voice.</p>



<p><strong>Step 1:</strong>&nbsp; First, we have to create an account on <a href="https://wellsaidlabs.com" target="_blank" rel="noopener">https://wellsaidlabs.com</a> website.</p>



<p><strong>Step 2:</strong> After Sign-up, go to the <a href="https://developer.wellsaidlabs.com/#!/" target="_blank" rel="noopener">https://developer.wellsaidlabs.com/#!/</a> link and you have to log in with your account.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="975" height="503" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-4.png" alt="" class="wp-image-18214" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-4.png 975w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-4-300x155.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-4-768x396.png 768w" sizes="(max-width: 975px) 100vw, 975px" /></figure>



<p><strong>Step 3:</strong> Click on the below WellSaid Labs TTS API’s section:</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="975" height="506" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-5.png" alt="" class="wp-image-18215" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-5.png 975w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-5-300x156.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-5-768x399.png 768w" sizes="(max-width: 975px) 100vw, 975px" /></figure>



<p><strong>Step 4:</strong> The next step in using this service is requesting access via the&nbsp;<code>Subscribe</code>&nbsp;link on our developer portal. Once approved, you will have access to the WellSaid Labs TTS API through the use of an API key.</p>



<p><strong>Step 5:</strong> You can use all or any of these available speakers with the given id from the WellSaid Labs TTS API’s details page.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="580" height="355" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-7.png" alt="" class="wp-image-18217" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-7.png 580w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-7-300x184.png 300w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>..and more</strong></p>



<p><strong>Step 6:</strong> After getting the API key, you can use as per the given example:</p>



<p><strong><u>Index.blade.php</u></strong></p>



<code><pre><html>
<body>
<div style="text-align: center;">
<select name="user_name" id="user_name">
		<option value="3">Alana B.</option>
		<option value="4" selected="">Ramona J.</option>
		.....
		<option value="95">Greg G.</option>
	</select><br><br>

<textarea rows="8" name="decription" id="decription" placeholder="enter text here..."></textarea><br>
	<div id="audio_output"></div><br>
	<input type="button" class="get-clip" name="audio_clip" value="Get Clip">
</div>
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.js" type="text/javascript"></script>
<script>

$(document).ready(function(){
	$(document).on('click','.get-clip',function() {
		var id = $('#user_name').val();
		var text = $('#decription').val();
      		$.ajax({
        			type:'post',
       			 url:"{{ route('wave.audio-clip') }}",
			data:{'text': text, 'speaker_id' : id, '_token': "{{ csrf_token() }}"},
			dataType: 'html',
        			success:function(data){
$('#audio_output').html('<audio id="audioclip" controls=""><source src="'+data+'" type="audio/mpeg"></audio>');
          			}
    		});
	});
});	
</script>
</pre></code>



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



<code><pre>Route::get('audio-test', '\Wave\Http\Controllers\AudioTestController@audio');

Route::post('audio', '\Wave\Http\Controllers\AudioTestController@audio_clip')
&gt;name('wave.audio-clip');
</pre></code>



<p><strong>AudioTestController.php</strong></p>



<code><pre><?php

namespace Wave\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AudioTestController extends Controller
{

	public function audio(){
		return view('index');
	}

	public function audio_clip(Request $request){
        		$ch = curl_init();
       		 $postData = [
            		'text' => $request->text,
           		 'speaker_id' => $request->speaker_id
       		 ];

        curl_setopt($ch, CURLOPT_URL, 'https://api.wellsaidlabs.com/v1/tts/stream');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$headers = array();
           $headers[] = 'Your API Key';
           $headers[] = 'Accept: audio/mpeg';
           $headers[] = 'Content-Type: application/json';
           curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

           $result = curl_exec($ch);
           if (curl_errno($ch)) {
                echo 'Error:' . curl_error($ch);
            }
           $filename = time();
           $file_path = public_path("$filename.mp3");
           file_put_contents($file_path, $result);

           curl_close($ch);

           echo env('APP_URL').$filename.'.mp3';
    }

</pre></code>



<p><strong>Step 7:</strong> Run the above Laravel example.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-implement-wellsaid-labs-tts-api-in-laravel/">How to Implement WellSaid Labs TTS API 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/how-to-implement-wellsaid-labs-tts-api-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to delete a user in custom Artisan Command line in Laravel?</title>
		<link>https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 18 May 2023 11:39:08 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=18200</guid>

					<description><![CDATA[<p>Laravel&#160;is a full-stack framework that offers a lot of artisan commands to automate various actions, like creating a controller, seeding the database, and starting the server. However, when you build custom solutions, you have your own special needs, which could [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/">How to delete a user in custom Artisan Command line 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><strong><u>Laravel</u></strong>&nbsp;is a full-stack framework that offers a lot of artisan commands to automate various actions, like creating a controller, seeding the database, and starting the server. However, when you build custom solutions, you have your own special needs, which could include a new command. Laravel doesn’t limit you to only its commands; you can create your own in a few steps.</p>



<p>Here are the steps for how to create a new artisan command.</p>



<p><strong>Step 1: Create a new Laravel application</strong></p>



<pre class="wp-block-code"><code>Laravel new custom</code></pre>



<p><strong>Step 2: Create a command</strong></p>



<p>Use the&nbsp;<code><strong>make:command</strong></code><strong>&nbsp;command</strong>&nbsp;to create a new command. Simply pass in the command name, like so:</p>



<pre class="wp-block-code"><code>php artisan make:command RemoveUser</code></pre>



<p>The command creates a file named&nbsp;<code><strong>RemoveUser.php</strong></code>, named after the command name, in a newly created&nbsp;<code><strong>Commands</strong></code>&nbsp;directory in the&nbsp;<code><strong>Console</strong></code>&nbsp;folder.</p>



<p>The generated file contains the configurations of the newly created command that are easy to understand and edit.</p>



<p><strong>Step 3: Customize command</strong></p>



<p>First, set the command signature. This is what would be put after&nbsp;<code><strong>php artisan</strong></code>&nbsp;to run the command. In this example, we will use&nbsp;<code><strong>remove:user</strong></code>, so the command will be accessible by running:</p>



<pre class="wp-block-code"><code>php artisan make:command RemoveUser</code></pre>



<p>To do this, update the&nbsp;<code>＄<strong>signature</strong></code>&nbsp;property of the command, like this:</p>



<pre class="wp-block-code"><code>Protected $signature = ‘remove:user’ {id};</code></pre>



<p>Next, set up a suitable description that would show up when&nbsp;<code><strong>php artisan list</strong></code>&nbsp;displays the command with other commands.</p>



<p>To do this, update the&nbsp;<code><strong>＄description</strong></code>&nbsp;property to match this:</p>



<pre class="wp-block-code"><code>Protected $description = ‘Remove user all Data’;</code></pre>



<p>Finally, in the&nbsp;<code><strong>handle()</strong></code>&nbsp;method, perform whatever action you intend it to perform. In this example, the number of users on the platform is echoed.</p>



<code><pre>public function handle(){
        $userId = $this->argument('id');
	  $delete[]=explode($usereId);	
        foreach($delete as $id){
        DB::table('users')->whereIn(id, $id)->delete();

        $this->info('Delete users successfully!');
        }</pre></code>



<p><strong>Step 4: Test command</strong></p>



<p>In the terminal, run the command to see the number of users in your database.</p>



<pre class="wp-block-code"><code>php artisan remove:user</code></pre>



<p>Now, when&nbsp;<code><strong>php artisan remove:user 1</strong></code>&nbsp;is run, you should see something like this:</p>



<div class="wp-block-image"><figure class="alignleft size-large is-resized"><img loading="lazy" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2.png" alt="" class="wp-image-18202" width="867" height="522" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2.png 869w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2-300x181.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-2-768x462.png 768w" sizes="(max-width: 867px) 100vw, 867px" /></figure></div>



<div class="wp-block-image"><figure class="alignleft size-large"><img loading="lazy" width="867" height="526" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3.png" alt="" class="wp-image-18203" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3.png 867w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3-300x182.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-3-768x466.png 768w" sizes="(max-width: 867px) 100vw, 867px" /></figure></div>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/">How to delete a user in custom Artisan Command line 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/how-to-delete-a-user-in-custom-artisan-command-line-in-laravel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Install Magento 2.4.6 on Ubuntu 22.04</title>
		<link>https://www.meghrajtechnosoft.com/how-to-install-magento-2-4-6-on-ubuntu-22-04/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-install-magento-2-4-6-on-ubuntu-22-04/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 08 May 2023 06:23:00 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=18084</guid>

					<description><![CDATA[<p>Magento Open Source 2.4.6 introduces support for PHP 8.2. PHP 8.1 remains fully supported, but support for PHP 7.4 has been removed. It includes significant performance and scalability enhancements. GraphQL operations for bulk cart operations and category tree rendering responses [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-install-magento-2-4-6-on-ubuntu-22-04/">How to Install Magento 2.4.6 on Ubuntu 22.04</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 Open Source 2.4.6 introduces support for PHP 8.2. PHP 8.1 remains fully supported, but support for PHP 7.4 has been removed. It includes significant performance and scalability enhancements. GraphQL operations for bulk cart operations and category tree rendering responses have been optimised.</p>



<p>This release includes over quality fixes and enhancements. Core Composer dependencies and third-party libraries have been upgraded to the latest versions that are compatible with PHP 8.2.</p>



<p>In this blog we will show you how to install the Open Source version of <strong>Magento 2.4.6</strong> on Ubuntu 22.04 OS.</p>



<p>Before starting the installation, you can check the system requirements for installing Magento 2.4.6.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-1.png" alt="" class="wp-image-18092" width="938" height="800" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-1.png 938w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-1-300x256.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image-1-768x655.png 768w" sizes="(max-width: 938px) 100vw, 938px" /></figure>



<p><strong>Prerequisites to be followed before installation:</strong><strong></strong></p>



<p><strong>1.Update and upgrade your operating system i.e., Ubuntu 22.04.</strong></p>



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



<p><strong>2. Install Apache</strong></p>



<p> 2.1 Add following commands to install Apache</p>



<pre><code>sudo apt install apache2</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="602" height="616" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_12T06_27_37_995Z.png" alt="" class="wp-image-18195" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_12T06_27_37_995Z.png 602w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_12T06_27_37_995Z-293x300.png 293w" sizes="(max-width: 602px) 100vw, 602px" /></figure>



<p>2.2 Check your version of Apache being installed</p>



<pre><code>sudo apache2ctl -v</code></pre>



<p>2.3 Run following command to check whether apache2 is enabled or not.</p>



<pre><code>systemctl is-enabled apache2</code></pre>



<p><strong>3.Install nginx web server</strong></p>



<p>&nbsp;&nbsp;&nbsp;Adobe Commerce supports nginx 1.18 (or the <a href="https://nginx.org/en/linux_packages.html#mainline" class="rank-math-link" target="_blank" rel="noopener">latest mainline version</a>).&nbsp;</p>



<pre><code># sudo apt install nginx</code></pre>



<p><strong>4.Install PHP and and configure php-fpm.</strong></p>



<p>&nbsp;&nbsp;Adobe Commerce and Magento Open Source require several <a href="https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/prerequisites/php-settings.html?lang=en" target="_blank" rel="noopener">PHP extensions</a> to function properly.</p>



<p>&nbsp;&nbsp;In addition to these extensions, you must also install and configure the php-fpm extension if</p>



<p>&nbsp;&nbsp;&nbsp;you are using nginx.&nbsp;</p>



<p>4.1. Install php-fpm and php-cli.</p>



<pre><code>sudo apt-get -y install php7.2-fpm php7.2-cli</code></pre>



<p> 4.2. Open the php.ini files in an editor.</p>



<pre><code>vim /etc/php/7.2/fpm/php.ini
vim /etc/php/7.2/cli/php.ini</code></pre>



<p> 4.3. Edit both files to match the following lines.</p>



<pre><code>memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On</code></pre>



<p>4.4. Save and exit the editor.</p>



<p>4.5. Restart the php-fpm service.</p>



<pre><code>sudo systemctl restart php7.2-fpm</code></pre>



<p><strong>5. Install MYSQL 8 ,phpmyadmin and create a database.</strong></p>



<p> 5.1 To install MySQL, run the following command from a terminal prompt.</p>



<pre><code>sudo apt install mysql-server</code></pre>



<p>5.2 Then, run following command.</p>



<pre><code>mysql_secure_installation</code></pre>



<p>5.3 To install phpmyadmin</p>



<pre><code>sudo apt install -y phpmyadmin</code></pre>



<p>When prompted to choose a web server, hit <strong>TAB</strong>, then <strong>ENTER</strong> to select <strong>apache2</strong> as shown in the screenshot below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="658" height="335" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/phpmyadmin_setup.jpg" alt="" class="wp-image-18174" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/phpmyadmin_setup.jpg 658w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/phpmyadmin_setup-300x153.jpg 300w" sizes="(max-width: 658px) 100vw, 658px" /></figure>



<p>When prompted to configure a database for your <strong>phpMyAdmin</strong> package, choose Yes and press <strong>ENTER</strong> to proceed.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="633" height="379" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_database_for_phpmyadmin.jpg" alt="" class="wp-image-18175" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_database_for_phpmyadmin.jpg 633w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_database_for_phpmyadmin-300x180.jpg 300w" sizes="(max-width: 633px) 100vw, 633px" /></figure>



<p>Enter a strong password for the <strong>phpMyAdmin</strong> package. Press <strong>TAB</strong> and <strong>ENTER</strong> to proceed.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="623" height="320" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_password_for_phpmyadmin.jpg" alt="" class="wp-image-18177" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_password_for_phpmyadmin.jpg 623w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/configure_password_for_phpmyadmin-300x154.jpg 300w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<p>Repeat the same password to finalize the installation process. Press <strong>TAB</strong> and <strong>ENTER</strong> to continue.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="613" height="248" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/confirm_password_for_phpmyadmin.jpg" alt="" class="wp-image-18178" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/confirm_password_for_phpmyadmin.jpg 613w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/confirm_password_for_phpmyadmin-300x121.jpg 300w" sizes="(max-width: 613px) 100vw, 613px" /></figure>



<p>Use the <strong>a2enconf</strong> command to enable the new configuration file created by the phpMyAdmin..</p>



<pre><code>sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf</code></pre>



<p>then, restart Apache to load the new configuration file.</p>



<pre><code>sudo systemctl restart apache2</code></pre>



<p>&nbsp;5.3 Start the database server daemon, and also enable it to start it automatically with the next boot with the following command.</p>



<pre><code># systemctl start mysql
# systemctl enable mysql</code></pre>



<p> 5.4 After database server being installed, log into the MySQL prompt.</p>



<pre><code>#  mysql -u root -p</code></pre>



<p> 5.5 Enter the following commands in the order shown to create a database instance named&nbsp;<code>magento</code>&nbsp;with username <code>magento</code>&nbsp;.</p>



<pre><code>create database magento;
create user 'magento'@'localhost' IDENTIFIED BY
GRANT ALL ON magento.* TO 'magento'@'localhost';
flush privileges;</code></pre>



<p> 5.6 Enter&nbsp;<code>exit</code>&nbsp;to quit the command prompt.</p>



<p> 5.7  Navigate to the URL below in a web browser to test the installation. Replace 127.0.0.1 or Localhost with the correct domain name or public IP address of your server.</p>



<p>http://127.0.0.1/phpmyadmin</p>



<p>Then enter the credentials of the user you&#8217;ve just created to log in.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="410" height="432" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-50-29.png" alt="" class="wp-image-18183" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-50-29.png 410w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-50-29-285x300.png 285w" sizes="(max-width: 410px) 100vw, 410px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="531" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-51-04-1024x531.png" alt="" class="wp-image-18184" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-51-04-1024x531.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-51-04-300x156.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-51-04-768x398.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Screenshot-from-2023-05-11-12-51-04.png 1365w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p> 5.8 Verify the database.</p>



<pre><code>mysql -u magento -p</code></pre>



<p><strong>6. Installing Elasticsearch.</strong></p>



<p>6.1 Import the Elasticsearch GPG key.</p>



<pre><code># wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg</code></pre>



<p>6.2 Add the Elasticsearch repository.</p>



<pre><code># echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list</code></pre>



<p>6.3 Update the&nbsp;<code>apt</code>&nbsp;package manager and install Elasticsearch.</p>



<pre><code># sudo apt update &amp;&amp; apt install elasticsearch</code></pre>



<p>6.4 After that start and enable the service.</p>



<pre><code># sudo systemctl start elasticsearch
# sudo systemctl enable elasticsearch</code></pre>



<p>6.5 Open the elasticsearch.yml file.</p>



<pre><code>sudo nano /etc/elasticsearch/elasticsearch.yml</code></pre>



<p>6.6 And replace this setting with&nbsp;false.</p>



<pre><code># enable security features
xpack.security.enabled: false</code></pre>



<p>6.7 After that, you should restart elasticsearch service for the configuration.</p>



<pre><code># sudo systemctl restart elasticsearch.service</code></pre>



<p> 6.8 To verify your Elasticsearch working.</p>



<pre><code>curl -XGET 'localhost:9200'</code></pre>



<p> 6.9  It would look like this, if Elasticsearch is working properly:</p>



<pre><code>{
  "name" : "Z0S2B05",
  "cluster_name" : "elasticsearch_myname",
  "cluster_uuid" : "V-kpikRJQHudN-Wzdt-IrQ",
  "version" : {
    "number" : "6.8.7",
    "build_flavor" : "oss",
    "build_type" : "tar",
    "build_hash" : "c63e621",
    "build_date" : "2020-02-26T14:38:01.193138Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.2",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"x</code></pre>



<p><strong>7.</strong> <strong>Install PHP 8.1 and Related Modules</strong></p>



<p>Add following command for update PHP and to check its version.</p>



<pre><code>sudo apt update
php -v</code></pre>



<p>You will receive output like this:</p>



<pre><code>PHP 8.1.2 (cli) (built: Apr  7 2022 17:46:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies
</code></pre>



<p>You can also install more than one package at a time. Here are a few suggestions of the most common modules you will most likely want to install:</p>



<pre><code>sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath
sudo apt install php8.1 php8.1-cli php8.1-common libapache2-mod-php8.1php8.1-mysql php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-soap php8.1-intl php8.1-gd php8.1-zip</code></pre>



<p><strong>This command will install the following modules:</strong></p>



<ul><li>php8.1-cli &#8211; command interpreter, useful for testing PHP scripts from a shell or performing general shell scripting tasks</li><li>php8.1-common &#8211; documentation, examples, and common modules for PHP</li><li>php8.1-mysql &#8211; for working with MySQL databases</li><li>php8.1-zip &#8211; for working with compressed files</li><li>php8.1-gd &#8211; for working with images</li><li>php8.1-mbstring &#8211; used to manage non-ASCII strings</li><li>php8.1-curl &#8211; lets you make HTTP requests in PHP</li><li>php8.1-xml &#8211; for working with XML data</li><li>php8.1-bcmath &#8211; used when working with precision floats</li></ul>



<p><strong>8.For installing Composer.</strong></p>



<p>8.1 For downloading the Composer, use the following command:</p>



<pre><code># curl -sS https://getcomposer.org/installer | php</code></pre>



<p>8.2 Move the composer file to the /usr/local/bin path.</p>



<pre><code># mv composer.phar  /usr/local/bin/composer</code></pre>



<p>8.3 Assign execute permission.</p>



<pre><code># chmod +x   /usr/local/bin/composer</code></pre>



<p>8.4 Verify the composer version installed.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="584" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T06_51_09_067Z-1024x584.png" alt="" class="wp-image-18163" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T06_51_09_067Z-1024x584.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T06_51_09_067Z-300x171.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T06_51_09_067Z-768x438.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T06_51_09_067Z.png 1184w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>9.Install Magento 2.4.6.</strong></p>



<p> 9.1 Mostly it is recommended to install Magento using <strong>Marketplace</strong> by creating access key.</p>



<p>        For generating access key go to:</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  My Profile&gt;Marketplace&gt;My Products&gt;Access Keys:</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="980" height="478" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/My_Account-980x478-1.png" alt="" class="wp-image-18104" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/My_Account-980x478-1.png 980w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/My_Account-980x478-1-300x146.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/My_Account-980x478-1-768x375.png 768w" sizes="(max-width: 980px) 100vw, 980px" /></figure>



<p>        Run following command to download Magento 2.4.6.</p>



<pre><code># composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6
 /var/www/html/magento2</code></pre>



<p class="has-text-align-left">Username: Your Public Key:e6161608af9152b013f07ad3e1f8b9a2</p>



<p class="has-text-align-left">Password: Your Private Key:4cde0d7054178296e40fe105b4f650b1</p>



<p>9.2 Navigate to Magento directory and change mode of cache and static content folder.</p>



<pre><code>find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +</code></pre>



<p> 9.3 Now change the Ownership of Magento Directory to Web server user and also permission.</p>



<pre><code># chown -R www-data:www-data /var/www/html/magento2
# chmod -R 755 /var/www/html/magento2</code></pre>



<p>9.4 Create the user and go to the magento 2 directory.</p>



<pre><code>cd /var/www/html/</code></pre>



<p>9.5  Run following command to disable magento module.</p>



<pre><code>sudo php bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}</code></pre>



<p> 9.6 Then, install Magento using composer command.</p>



<pre><code># sudo php bin/magento setup:install \
--base-url=http://your-domain.com \
--db-host=localhost \
--db-name=magentodb \
--db-user=magentouser \
--db-password=MyPassword \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@your-domain.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1</code></pre>



<p>9.7  After installation you will see Magento admin link.</p>



<pre><code>[SUCCESS]: Magento Admin URI: /admin_o07lew</code></pre>



<p><strong>10. Change DocumentRoot To Pub</strong></p>



<p>10.1 If you are installing Magento locally, you can add</p>



<pre><code>sudo nano /etc/apache2/sites-available/magento2.conf</code></pre>



<p>10.2 Modify file as shown below</p>



<p>Remove &#8216;#&#8217; from server name.</p>



<pre><code><virtualhost *:80="">
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/magento2/pub
         ServerName magento2
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<directory "="" var="" www="" html"="">
AllowOverride all
</directory>
</virtualhost></code></pre>



<p>10.3 Restart Apache for the changes to take effect.</p>



<p>You can add <strong>domain.com.</strong> Then you have to update <strong>hosts</strong> file at <strong>/etc/hosts</strong> with</p>



<pre><code>sudo nano /etc/hosts</code></pre>



<p>Add this&nbsp; below in localhost</p>



<p>127.0.0.1 localhost</p>



<p>127.0.0.1 &nbsp; magento2</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="558" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_52_47_242Z-1-1024x558.png" alt="" class="wp-image-18142" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_52_47_242Z-1-1024x558.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_52_47_242Z-1-300x163.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_52_47_242Z-1-768x418.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_52_47_242Z-1.png 1366w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>To save the above file <strong>&nbsp;Ctrl + o </strong>and then<strong> Press Enter </strong>&nbsp;and Close it with <strong>&nbsp;Ctrl + x</strong>.</p>



<p>10.4 Configure Elasticsearch</p>



<p>Start editing the main <strong>elasticsearch.yml</strong> configuration file. Open it using <strong>nano </strong>or your preferred text editor</p>



<pre><code>sudo nano /etc/elasticsearch/elasticsearch.yml</code></pre>



<p>Remove the <strong>#</strong> character at the beginning of the lines for <strong>node.name</strong> and <strong>cluster.name</strong> to uncomment them, and then change their values. Your first configuration changes in the<strong> /etc/elasticsearch/elasticsearch.yml</strong> file will look like this</p>



<p>node.name: &#8220;My First Node&#8221;</p>



<p>cluster.name: my-application</p>



<p>Then, search for the line that contains network.host, uncomment it, and change the value to 0.0.0.0</p>



<p>Set the network host to 0.0.0.0 to listen on all interfaces and make it available publicly,</p>



<p>network.host: 127.0.0.1 or localhost</p>



<p>http.port: 9200</p>



<p><strong>11. Configure Nginx web server for Magento 2.4.6.</strong></p>



<p>11.1 Navigate to etc/nginx/conf.d  directory and run following command to create a configuration file for Magento installation.</p>



<pre><code># sudo nano /etc/nginx/conf.d/magento2.conf</code></pre>



<p>Then add following content:</p>



<pre><code>upstream fastcgi_backend {
  server  unix:/run/php/php8.1-fpm.sock;
}

server {

  listen 80;
  server_name your-domain.com www.your-domain.com;
  set $MAGE_ROOT /var/www/magento2;
  include /var/www/magento2/nginx.conf.sample;
}</code></pre>



<p>11.2 Save file and exit.</p>



<p>11.3 Restart Nginx web server.</p>



<p><strong>12.Magento 2.4.6 Application.</strong></p>



<p>12.1 Below code is required for developer mode.</p>



<pre><code>sudo php bin/magento deploy:mode:set developer
sudo a2enmod rewrite</code></pre>



<p>12.2. After Install Magento Run the following command  To Get Homepage And  Admin in Root Directory.</p>



<pre><code>sudo chown -R www-data:www-data /var/www/html/magento2/
sudo chmod -R 777 var pub 
sudo chmod -R 755 /var/www/html/magento2/
sudo a2ensite magento2.conf
sudo systemctl restart apache2
sudo a2enmod rewrite
sudo php bin/magento indexer:reindex
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento cache:flush
sudo chmod -R 777 *</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="467" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Homepage_magento2-2-1024x467.png" alt="" class="wp-image-18167" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Homepage_magento2-2-1024x467.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Homepage_magento2-2-300x137.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Homepage_magento2-2-768x350.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/Homepage_magento2-2.png 1221w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>12.3 Also for admin authorisation .</p>



<pre><code>sudo php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth
sudo php bin/magento module:disable Magento_TwoFactorAuth</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="405" height="450" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_00_42_025Z.png" alt="" class="wp-image-18165" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_00_42_025Z.png 405w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T05_00_42_025Z-270x300.png 270w" sizes="(max-width: 405px) 100vw, 405px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="476" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T07_07_26_912Z-1024x476.png" alt="" class="wp-image-18170" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T07_07_26_912Z-1024x476.png 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T07_07_26_912Z-300x139.png 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T07_07_26_912Z-768x357.png 768w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/image_2023_05_11T07_07_26_912Z.png 1362w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>13.</strong> <strong>To install sample data for Magento 2.</strong></p>



<p>13.1 To install the sample data, run the below command.</p>



<pre><code>sudo php bin/magento sampledata:deploy
sudo php bin/magento indexer:reindex
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento c:f
sudo chmod -R 777 *</code></pre>



<p>13.2 Sample data will fill your website with some products, categories and images so your website will look like this:</p>



<p></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="783" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data1.jpg" alt="" class="wp-image-18160" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data1.jpg 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data1-300x229.jpg 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data1-768x587.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="787" src="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data2.jpg" alt="" class="wp-image-18161" srcset="https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data2.jpg 1024w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data2-300x231.jpg 300w, https://www.meghrajtechnosoft.com/wp-content/uploads/2023/05/sample-data2-768x590.jpg 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Well done! refresh your website and enjoy your new Magento 2.4.6&nbsp; installation with sample data.</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-install-magento-2-4-6-on-ubuntu-22-04/">How to Install Magento 2.4.6 on Ubuntu 22.04</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-magento-2-4-6-on-ubuntu-22-04/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>How to detect Operating System on running website using JavaScript ?</title>
		<link>https://www.meghrajtechnosoft.com/how-to-detect-operating-system-on-running-website-using-javascript/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-detect-operating-system-on-running-website-using-javascript/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 05 Jan 2021 08:14:14 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17707</guid>

					<description><![CDATA[<p>To detect the operating system on running website, one can simply use navigator.appVersion or navigator.userAgent property.The Navigator app Version or userAgent property is a read-only property and it returns a string which represents the operating system information of the browser. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-detect-operating-system-on-running-website-using-javascript/">How to detect Operating System on running website using JavaScript ?</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>To detect the operating system on running website, one can simply use navigator.appVersion or navigator.userAgent property.<br>The Navigator app Version or userAgent property is a read-only property and it returns a string which represents the operating system information of the browser.</p>



<p><strong>Syntax : Operating System can be detected by either ways</strong></p>



<pre><code>navigator.appVersion</code></pre>



<pre><code>navigator.userAgent</code></pre>



<p><strong>Embed this script in your code </strong></p>



<pre><code><script type="text/javascript">
/*mac os detaction*/
      var system =  document.getElementById("boom_body");
      if (navigator.userAgent.indexOf('Mac OS X') != -1) {
            system.className += "mac_os"; 
          } else {
            system.className += "windows_os"; 
          }
</script></code></pre>



<p></p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-detect-operating-system-on-running-website-using-javascript/">How to detect Operating System on running website using JavaScript ?</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-detect-operating-system-on-running-website-using-javascript/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>
	</channel>
</rss>
