<?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>Magento &#8211; MeghRaj TechnoSoft &#8211; Web, App, E-commerce Development  Agency In India.</title>
	<atom:link href="https://www.meghrajtechnosoft.com/magento/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>Magento &#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 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>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>What does unsafe-perm in npm actually do?</title>
		<link>https://www.meghrajtechnosoft.com/what-does-unsafe-perm-in-npm-actually-do/</link>
					<comments>https://www.meghrajtechnosoft.com/what-does-unsafe-perm-in-npm-actually-do/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 07 Dec 2020 08:20:04 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Node.JS]]></category>
		<category><![CDATA[NPM]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17487</guid>

					<description><![CDATA[<p>I’ve routinely been directed to what feels like a magic fix to issues when installing items over NPM. The issue that I’ve most recently encountered occurs in two different OS’s; Windows and Elementary. When attempting to install&#160;Sindre Sorhus’ Pure ZSH [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/what-does-unsafe-perm-in-npm-actually-do/">What does unsafe-perm in npm actually do?</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>I’ve routinely been directed to what feels like a magic fix to issues when installing items over NPM. The issue that I’ve most recently encountered occurs in two different OS’s; Windows and Elementary. When attempting to install&nbsp;<a href="https://github.com/sindresorhus/pure" target="_blank" rel="noreferrer noopener">Sindre Sorhus’ Pure ZSH theme</a>&nbsp;both in Ubuntu WSL and Elementary Loki, I have issues with not having permissions.</p>



<p>The solution seems to be almost the same in both cases.</p>



<pre><code>npm config set unsafe-perm true</code></pre>



<p>What exactly is this doing? Is it ‘unsafe’?</p>



<p>Let’s start with&nbsp;<a href="https://duckduckgo.com/?q=npm+config+set+unsafe-perm+true&amp;t=canonical&amp;ia=qa" target="_blank" rel="noreferrer noopener">a search</a>. So there is a config setting allowed in the&nbsp;<code>package.json</code>&nbsp;that actually can set this per package. But wait,&nbsp;<a href="https://docs.npmjs.com/misc/config" target="_blank" rel="noreferrer noopener">it’s always true unless using root</a>. I never run as&nbsp;<code>root</code>, or with&nbsp;<code>sudo</code>&nbsp;privileges unless I am forced to. Let’s take a look through the&nbsp;<a href="https://github.com/npm/cli" target="_blank" rel="noreferrer noopener">source code</a></p>



<blockquote class="wp-block-quote"><p>Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.</p></blockquote>



<blockquote class="wp-block-quote"><p>If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.</p></blockquote>



<pre><code>function loadUid(cb) {
  // if we're not in unsafe-perm mode, then figure out who
  // to run stuff as.  Do this first, to support `npm update npm -g`
  if (!this.get('unsafe-perm')) {
    getUid(this.get('user'), this.get('group'), cb);
  } else {
    process.nextTick(cb);
  }
}</code></pre>



<p>In other words, if we set&nbsp;<code>unsafe-perm</code>&nbsp;to always true, we will stop getting the user and the group the command was ran as and we will over-load the defaults.</p>



<pre><code>'unsafe-perm': process.platform === 'win32' ||
                     process.platform === 'cygwin' ||
                     !(process.getuid &amp;&amp; process.setuid &amp;&amp;
                       process.getgid &amp;&amp; process.setgid) ||
process.getuid() !== 0,</code></pre>



<p>It’s starting to make a bit more sense. This issue that I’m facing is that the permissions my current user has are unable to create the symlinks that are being asked by the program. By setting&nbsp;<code>unsafe-perm</code>&nbsp;to&nbsp;<code>true</code>&nbsp;will force&nbsp;<code>NPM</code>&nbsp;to attempt to always run within the context of the running script.</p>



<p>I suppose that this isn’t ‘unsafe’ but it does force the package installer to never drop into user and group switching when installing apps. It’s possible then you may end up having the code run as ‘root’ when installing (which could then be considered ‘unsafe’);</p>



<p>This goes all the way back to&nbsp;<a href="https://github.com/npm/cli/commit/021750a5bf0c1024916c0a497763cb2d2da78e46" target="_blank" rel="noreferrer noopener">February 7th, 2011</a>!<br>Initially this would cause the app to either Error out when&nbsp;<code>false</code>&nbsp;or to&nbsp;<a href="https://github.com/npm/cli/commit/52e3e88feb75c1e4c5e05771e2f4e67be27015ab" target="_blank" rel="noreferrer noopener">toggle the user and group</a>.</p>



<p>But finally,&nbsp;<a href="https://github.com/npm/cli/commit/dae3259fd17866c189c5e8b3a7968f515b1af4ca" target="_blank" rel="noreferrer noopener">we reach the reasoning for this code</a>&nbsp;(and still it’s not what many may expect).</p>



<blockquote class="wp-block-quote"><p>You can’t please everyone.</p></blockquote>



<blockquote class="wp-block-quote"><p>Don’t try to be secure if it’ll fail.&nbsp;</p><p>If someone really wants to encourage this all the time, then they can do<br><code>npm config set unsafe-perm false</code>&nbsp;explicitly.&nbsp;</p><p>In the npm 1.0 future, it will probably require sudo for global<br>installing no matter what, and use this behavior for local installing.<br>Since so many people have npm installing in their home dir, requiring<br>sudo is causing more trouble than it’s worth.</p></blockquote>



<p><em>Boom</em></p>



<p>This was added to help installing files into ‘safe’ locations without&nbsp;<code>sudo</code>.<br>So I think that I may have the answer?</p>



<blockquote class="wp-block-quote"><p>Use this sparingly; probably bad to set globally for all running scripts. If the user is running as&nbsp;<code>root</code>&nbsp;it may cause the app to force changes that could extend beyond what a running script should have. Never run as&nbsp;<code>root</code>&nbsp;and it will be&nbsp;<code>true</code>&nbsp;by default. Use&nbsp;<code>sudo</code>&nbsp;otherwise. It’s not a magic bullet.</p></blockquote>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/what-does-unsafe-perm-in-npm-actually-do/">What does unsafe-perm in npm actually do?</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/what-does-unsafe-perm-in-npm-actually-do/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Send Product Images in Order Transaction Mail to Customers in Magento 2</title>
		<link>https://www.meghrajtechnosoft.com/how-to-send-product-images-in-order-transaction-mail-to-customers-in-magento-2/</link>
					<comments>https://www.meghrajtechnosoft.com/how-to-send-product-images-in-order-transaction-mail-to-customers-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 07 Dec 2020 08:01:14 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.meghrajtechnosoft.com/?p=17466</guid>

					<description><![CDATA[<p>Getting in touch with clients using Email is an inexpensive and widely used form of highly effective business communication compared to others communication channels. Out of the box, Magento comes with built-in functionality to notify customers of each and every [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-send-product-images-in-order-transaction-mail-to-customers-in-magento-2/">How to Send Product Images in Order Transaction Mail to Customers 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>Getting in touch with clients using Email is an inexpensive and widely used form of highly effective business communication compared to others communication channels. Out of the box, Magento comes with built-in functionality to notify customers of each and every order status like order, invoice, shipment and credit memo. Generally, this Email is made up of various details like customer information, ordered products, subtotal and purchase amount, but it doesn’t contain product images that’s why it is difficult to identify the product from the product list. One of our clients suggested us to add functionality of including product thumbnail image to Email, so when there is a bulk order or thousands of products in an Email, it becomes easier for their customers to identify the products they are looking for.</p>



<p>After spending some time to develop such functionality, finally, we came out with a tiny piece of code. Here I am sharing the easiest way to&nbsp;<strong><em>add product images in all transactional Emails sent to customers in Magento 2</em></strong>.</p>



<p>Just paste the following code to default.phtml file available on below path.<br><strong>app/design/frontend/[theme name]/Magento Sales/templates/email/items/order</strong></p>



<pre><code>	<?php
$_item = $block->getItem();
$_order = $_item->getOrder();
 
$imageSize = (int)$block->getConfig('sales_email/imageconfig/image_resize');
if($imageSize <=10)
 $imageSize = 135;
$_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
if($childProd = current($_item->getChildrenItems()))
{
        $productImage = $_imagehelper->init($childProd->getProduct(), 'category_page_list', array('height' => $imageSize , 'width'=> $imageSize))->getUrl();
}
else
{
        $productImage = $_imagehelper->init($_item->getProduct(), 'category_page_list', array('height' => $imageSize , 'width'=> $imageSize))->getUrl();
}
 
?></code></pre>



<p>And add the image tag like below under the hood of product name.</p>



<pre><code>	
<?php if($block->getConfig('sales_email/imageconfig/enabled')):?>
            <p class="sku">
                <img src="<?=$productImage?>" title="<?= $block->escapeHtml($_item->getName()) ?>" alt="<?= $block->escapeHtml($_item->getName()) ?>" />
            </p>
<?php endif;?></code></pre>



<p>Once you have implemented above code successfully, it will automatically identify and send product image to each &amp; every order transactional mail that are done via Magento 2 environment. Now just clear the cache and you are ready to go.<br>Let the stars below to shine and if you face any issue while implementing code, I will be glad to help you.<br>Happy Mailing!.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.meghrajtechnosoft.com/how-to-send-product-images-in-order-transaction-mail-to-customers-in-magento-2/">How to Send Product Images in Order Transaction Mail to Customers 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-send-product-images-in-order-transaction-mail-to-customers-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
