<?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>Solution Archives - WEB4PRO</title>
	<atom:link href="https://web4pro.net/blog-news/category/solution-blog/feed/" rel="self" type="application/rss+xml" />
	<link>https://web4pro.net/blog-news/category/solution-blog/</link>
	<description></description>
	<lastBuildDate>Thu, 11 Jan 2024 15:47:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2023/04/07085114/favicon-32x32-1.png</url>
	<title>Solution Archives - WEB4PRO</title>
	<link>https://web4pro.net/blog-news/category/solution-blog/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>5 Great Email Template Builders for Your Creative Emails</title>
		<link>https://web4pro.net/blog-news/5-great-email-template-builders-for-your-creative-emails/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 21:05:22 +0000</pubDate>
				<category><![CDATA[Explore Technology]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[email builders]]></category>
		<category><![CDATA[email templates]]></category>
		<category><![CDATA[guide]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=9594</guid>

					<description><![CDATA[Find out what are the best email builders in the market in 2020.]]></description>
										<content:encoded><![CDATA[
<p>Whether you are already running your email marketing strategy or you are just looking for the right email template tool, we’ve got you covered. In this article, we are going to share thoughts on what email builder to choose for creating perfect emails and why you need to consider online email template builder as a platform for making them.</p>



<p>Let’s start from the beginning.</p>



<p><strong>Why do you need email marketing?</strong></p>



<p>If you are running an online business, one of the ways to attract customers to your store is to let them subscribe to your email newsletter. This allows you to remind your customers about your brand, communicate with current and new customers, present them with your initiatives, and make more sales.</p>



<p>Sending plain emails became more common for personal communication. However, brands that sell products to hundreds of people need to be more creative now. That’s why, if you want to stand up from the crowd and present your products or services in the best possible way, you can use stylish email templates.</p>



<p><strong>What are the email templates?</strong></p>



<p>It is a ready HTML version of an email that allows you to create your own unique email design and apply it for your email marketing campaigns.</p>



<div class="post-nav-block">
<ul>
<li><a class="nav-post" href="#how">How to Create an Email Template?</a></li>
<li><a class="nav-post" href="#Builder">What to Expect From Email Template Builder?</a></li>
<li><a class="nav-post" href="#Choose">What Online Email Builder to Choose?</a></li>
<li><a class="nav-post" href="#BEE">BEE Free</a></li>
<li><a class="nav-post" href="#Mailton">Mailton</a></li>
<li><a class="nav-post" href="#TOPOL">TOPOL</a></li>
<li><a class="nav-post" href="#Chamaileon">Chamaileon</a></li>
<li><a class="nav-post" href="#Mosaico">Mosaico</a></li>
</ul>
</div>



<h2 class="wp-block-heading"><a id="how"></a>How to Create an Email Template?</h2>



<p>You’ve come to the point that you need an email template. How can you get it?</p>



<ol class="wp-block-list">
<li><strong>Create your HTML template.</strong> You can create a template from scratch in HTML. In this case, you’ll need to have some programming skills. If it sounds interesting to you, there are plenty of tutorials, for example, check the <a href="https://webdesign.tutsplus.com/articles/build-an-html-email-template-from-scratch--webdesign-12770" target="_blank" rel="noreferrer noopener">Tuts course</a> from Envato. However, it can be time-consuming, which is the first concern for most business owners, web designers, and marketing specialists.</li>



<li><strong>Use online email template builders.</strong> Here we’ve come to the easiest way to get the desired email. There are many email builders on the market that allow editing the ready professional design. They all have something in common and also are different in features and interfaces. The last one is crucial if you edit your emails on your own or if you lack time.</li>
</ol>



<p>But before we consider the five best options that exist now, let’s observe what to expect from an online email template builder.</p>



<h2 class="wp-block-heading"><a id="Builder"></a>What to Expect From an Online Email Template Builder?</h2>



<p>Before choosing a specific builder, you need to look at several criteria that will make your work easier. The price range is not the crucial point; however, we recommend you to look at the subscription plans if you need to create lots of emails.</p>



<ol class="wp-block-list">
<li><strong>Your email builder should have the list of the main functions:</strong>
<ol class="wp-block-list">
<li>Friendly user interface (drag-and-drop editor);</li>



<li>Email template library (also emails for special occasions, such as Christmas, Black Friday, Halloween will be a plus);</li>



<li>Compatibility with popular email clients, such as Gmail, Yahoo, Outlook.</li>



<li>Responsiveness for different desktop and mobile devices;</li>



<li>Quick email preview option to test the result before sending it.</li>
</ol>
</li>



<li><strong>The online builder should be fast and convenient.</strong> You can use pre-made templates and edit their layout in minutes with the drag-and-drop feature. You can also play around with blocks by adding images, buttons, text, and changing the order of blocks and get the unique email.</li>



<li><strong>The builder should not be heavy (bulky).</strong> This is an online tool, so you don’t need to install additional software to work with your template. It will autosave your sessions, and allow you to edit it later and re-use your template another time.</li>



<li><strong>It should allow keeping the branded design of your emails.</strong> With a flexible email builder, you can re-use the same templates and use designs again and again. This will save you time and allow you to create the same brand appearance for every email.</li>
</ol>



<p>Now you are aware of some recommended traits of a good email building tool. We hope it will help you to choose the most useful one. Let’s move to a short review of the tools available on the market.</p>



<h2 class="wp-block-heading"><a id="Choose"></a>What Online Email Builder to Choose?</h2>



<p>Take a look at the list of useful email builders that can help you to create excellent newsletters. They have some features in common and serve the same purpose. But they differ depending on the goals, the scale, and the level of technical skills you have. We suggest choosing the most appropriate one for your specific priorities and test each one to select the most comfortable solution.</p>



<h3 class="wp-block-heading"><a id="BEE"></a><a href="https://beefree.io/" target="_blank" rel="noreferrer noopener">BEE Free</a></h3>



<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="1024" height="471" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344-1024x471.jpg" alt="BEE Free" class="wp-image-9595" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344-1024x471.jpg 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344-300x138.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344-640x294.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344-768x353.jpg 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082613/joxi_screenshot_1584547197344.jpg 1342w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is a freemium email editor. This is a product of MailUp Group. It allows you to create and edit the template in a free plan and offers extended functionality in the premium package.</p>



<h4 class="wp-block-heading">Pricing &amp; Plans</h4>



<p>It includes 3 different plans in one, called <strong>BEE Pro</strong>:</p>



<ul class="wp-block-list">
<li>freelance &#8211; $15/m,</li>



<li>team &#8211; $25/m,</li>



<li>agency &#8211; $45/m.</li>
</ul>



<p>That means the editor is helpful for teams and allows them to assign roles, control the work done, and add/remove notes. It may suit advanced project teams.</p>



<p>The third package available is called <strong>BEE Plugin</strong>. It allows embedding an email or landing page in SaaS apps.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="424" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699-1024x424.png" alt="BEE Free" class="wp-image-9596" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699-1024x424.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699-300x124.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699-640x265.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699-768x318.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082612/joxi_screenshot_1584547839699.png 1361w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Distinct Features</h4>



<p>The drag-and-drop editor is quite simple and allows you to create an email from scratch in about <strong>20 minutes</strong>. The free plan allows exporting the file in HTML format. You can choose among 120 ready email templates.</p>



<h2 class="wp-block-heading"><a id="Mailton"></a><a href="https://mailton.io/" target="_blank" rel="noreferrer noopener">Mailton</a></h2>



<figure class="wp-block-image"><img decoding="async" width="1024" height="526" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03-1024x526.png" alt="Mailton" class="wp-image-9597" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03-1024x526.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03-300x154.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03-640x329.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03-768x395.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082611/03.png 1362w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Mailton is a creative space for crafting your emails. It is our new product, and we are glad to launch it for your convenience after ten years of releasing our email templates on the Envato market. Our Mailton allows for editing the layout of the email, saving it for later, export in HTML, Mailchimp and Campaign Monitor versions, and use for email marketing campaigns. Each template has 20 modules. Our goal was to make it simple, flexible, and useful for creating various types of emails.</p>



<h4 class="wp-block-heading">Pricing &amp; Plans</h4>



<p>The <strong>price for the subscription</strong> is equal to a price for the cup of coffee, which is $5/m or $20 for six months. All packages give an unlimited number of templates, professional support, and flexibility in the creation process.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="471" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866-1024x471.png" alt="Mailton" class="wp-image-9598" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866-1024x471.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866-300x138.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866-640x294.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866-768x353.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082609/joxi_screenshot_1584621781866.png 1338w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Distinct Features</h4>



<p>Mailton builder mode has a user-friendly interface, drag-and-drop functionality, and responsive design. You can create and export an email template in <strong>less than 15 minutes</strong>. Use one of the 85 ready templates and launch a successful email campaign!</p>



<p>We think Mailton is an affordable online tool, and it lets you spend more time on creativity and prepare your email campaign with ease and calm. <a href="https://mailton.io/" target="_blank" rel="noreferrer noopener">Drop in</a> to test in for free and form your opinion.</p>



<h3 class="wp-block-heading"><a id="TOPOL"></a><a href="https://topol.io/" target="_blank" rel="noreferrer noopener">TOPOL</a></h3>



<figure class="wp-block-image"><img decoding="async" width="1024" height="447" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165-1024x447.png" alt="TOPOL" class="wp-image-9599" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165-1024x447.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165-300x131.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165-640x279.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165-768x335.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082608/joxi_screenshot_1584625921165.png 1345w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Topol is a drag-and-drop email template editor with 7 pre-made templates, free and premium packages, and a few unique features.</p>



<h4 class="wp-block-heading">Pricing &amp; Plans</h4>



<p>The price range is the following:</p>



<ul class="wp-block-list">
<li><strong>Free plan</strong> with limited features</li>



<li>$7/m per <strong>premium plan</strong></li>



<li>$20/m per <strong>plugin plan</strong></li>
</ul>



<h4 class="wp-block-heading">Distinct Features</h4>



<p>You can insert GIFs, videos from Vimeo and YouTube in a link format, and they will be appropriately displayed in your emails. Also, you can download your email templates as ZIP-files to use them later or send them as test emails.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="371" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174-1024x371.png" alt="TOPOL" class="wp-image-9600" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174-1024x371.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174-300x109.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174-640x232.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174-768x278.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082607/joxi_screenshot_1584627126174.png 1349w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Among other options this email builder offers, is the export of HTML file, however, without full editing mode, except the ability to edit images and text. The time for creating an email from scratch is about <strong>20 minutes.</strong></p>



<h3 class="wp-block-heading"><a id="Chamaileon"></a><a href="https://chamaileon.io/" target="_blank" rel="noreferrer noopener">Chamaileon</a></h3>



<figure class="wp-block-image"><img decoding="async" width="1024" height="471" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320-1024x471.png" alt="Chamaileon" class="wp-image-9601" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320-1024x471.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320-300x138.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320-640x294.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320-768x353.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082606/joxi_screenshot_1584719470320.png 1341w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>This platform is perfect for working in teams. It offers deep customization options to use the editor, plus it has 100 ready-to-use templates and around 1000 modules to create, edit, and send unique emails to customers.</p>



<h4 class="wp-block-heading">Pricing &amp; Plans</h4>



<p>There are several plans available:</p>



<ul class="wp-block-list">
<li>The free plan (5 exports/m)</li>



<li>Premium package $20/m</li>



<li>Enterprise package (price by request)</li>
</ul>



<h4 class="wp-block-heading">Distinct Features</h4>



<p>The interface is similar to a simple CMS admin panel. You can also choose among creating an email template from scratch, use a ready version, or import your template in HTML format to edit it in the builder. There is a block with elements to add/edit for the template.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="470" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376-1024x470.png" alt="Chamaileon" class="wp-image-9602" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376-1024x470.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376-300x138.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376-640x293.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376-768x352.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082605/joxi_screenshot_1584721083376.png 1352w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Using the buttons in the upper panel, you can export, preview your template, and send a test email. The time needed for creating and exporting the email is up to <strong>40 minutes.</strong></p>



<h3 class="wp-block-heading"><a id="Mosaico"></a><a href="https://mosaico.io/" target="_blank" rel="noreferrer noopener">Mosaico</a></h3>



<figure class="wp-block-image"><img decoding="async" width="1024" height="469" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633-1024x469.jpg" alt="Mosaico" class="wp-image-9603" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633-1024x469.jpg 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633-300x137.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633-640x293.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633-768x352.jpg 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082604/joxi_screenshot_1584723527633.jpg 1348w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is a <strong>free open source</strong> email template editor created by VOXmail. It differs from other email builders because it has only two drafts that you can use as a base to create email templates.</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="472" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176-1024x472.png" alt="Mosaico" class="wp-image-9604" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176-1024x472.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176-300x138.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176-640x295.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176-768x354.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082603/joxi_screenshot_1584724364176.png 1349w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Distinct Features</h4>



<p>The menu of the editor is simple, you can click on the block, and it will automatically be added to the email body. In the menu tabs, you can also edit the content part, change the style of the text, background color, images, paragraph, and buttons. As Mosaico is free and open-source, you can’t store your email templates, images, and files. It is also limited in features, and you can create only a basic version of an email template. Still, if you need simple emails, this builder will be okay for you. The time required to create an email from scratch is <strong>25 minutes</strong>.</p>



<p><strong>After the review, let’s summarize and compare all the solutions in one table:</strong></p>



<figure class="wp-block-image"><img decoding="async" width="629" height="422" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082602/Screenshot_40.png" alt="1" class="wp-image-9625" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082602/Screenshot_40.png 629w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2020/04/07082602/Screenshot_40-300x201.png 300w" sizes="(max-width: 629px) 100vw, 629px" /></figure>



<p>We showed solutions that are similar to each other, but you can look into details and differences and choose the one that is good for you. We will be very glad if you share your experience working with these emails or our email builder Mailton, and write us on our contact form below.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Magento 2.3 Logout Bug</title>
		<link>https://web4pro.net/blog-news/magento-2-3-logout-bug/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 25 Feb 2020 15:04:56 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=9533</guid>

					<description><![CDATA[Check how to avoid the Magento 2.3 logout bug with our solution.]]></description>
										<content:encoded><![CDATA[
<p>When analyzing server logs from Magento 2.3.3, an error message of this kind was found:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="2019/11/26 16:03:05 [error] 19565#0: *114206 FastCGI sent in stderr: &quot;PHP message: PHP Fatal error:  Uncaught TypeError: strpos() expects parameter 1 to be string, null given in /home/magento/www/vendor/magento/module-theme/Controller/Result/JsFooterPlugin.php:44
Stack trace:
#0 /home/magento/www/vendor/magento/module-theme/Controller/Result/JsFooterPlugin.php(44): strpos(NULL, '&lt;/body') #1 /home/magento/www/vendor/magento/framework/Interception/Interceptor.php(121): Magento\Theme\Controller\Result\JsFooterPlugin-&gt;beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor))
#2 /home/magento/www/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Response\Http\Interceptor-&gt;Magento\Framework\Interception\{closure}()
#3 /home/magento/www/generated/code/Magento/Framework/App/Response/Http/Interceptor.php(26): Magento\Framework\App\Response\Http\Interceptor-&gt;___callPlugins('sendResponse', Array, Array)
#4 /home/magento/www/vendor/magento/framework/App/Bootstrap.php(262): Magento\Framework\App\Response\Http\Interceptor-&gt;sendResponse()&quot; while reading response header from upstream, client: 127.0.0.1," style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #AE81FF">2019</span><span style="color: #F8F8F2">/</span><span style="color: #AE81FF">11</span><span style="color: #F8F8F2">/</span><span style="color: #AE81FF">26</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">16</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">03</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">05</span><span style="color: #F8F8F2"> [</span><span style="color: #E6DB74">error</span><span style="color: #F8F8F2">] </span><span style="color: #AE81FF">19565</span><span style="color: #F8F8F2">#</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">: *</span><span style="color: #AE81FF">114206</span><span style="color: #F8F8F2"> FastCGI sent in stderr: &quot;PHP message: PHP Fatal error:  Uncaught TypeError: strpos() expects parameter </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> to be string, null given in /home/magento/www/vendor/magento/module-theme/Controller/Result/JsFooterPlugin.php:</span><span style="color: #AE81FF">44</span></span>
<span class="line"><span style="color: #F8F8F2">Stack trace:</span></span>
<span class="line"><span style="color: #88846F">#0 /home/magento/www/vendor/magento/module-theme/Controller/Result/JsFooterPlugin.php(44): strpos(NULL, &#39;&lt;/body&#39;) #1 /home/magento/www/vendor/magento/framework/Interception/Interceptor.php(121): Magento\Theme\Controller\Result\JsFooterPlugin-&gt;beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#2 /home/magento/www/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Response\Http\Interceptor-&gt;Magento\Framework\Interception\{closure}()</span></span>
<span class="line"><span style="color: #88846F">#3 /home/magento/www/generated/code/Magento/Framework/App/Response/Http/Interceptor.php(26): Magento\Framework\App\Response\Http\Interceptor-&gt;___callPlugins(&#39;sendResponse&#39;, Array, Array)</span></span>
<span class="line"><span style="color: #88846F">#4 /home/magento/www/vendor/magento/framework/App/Bootstrap.php(262): Magento\Framework\App\Response\Http\Interceptor-&gt;sendResponse()&quot; while reading response header from upstream, client: 127.0.0.1,</span></span></code></pre></div>



<p>We needed to identify the reason for the error and fix it. To do this, we had to analyze the code of the Magento core.</p>



<h2 class="wp-block-heading">Analyzing the Code of the Magento Core</h2>



<p>Starting in version 2.3.2, the following plugin was added in the Theme module in etc/fronted/di.xml.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;type name=&quot;Magento\Framework\App\Response\Http&quot;&gt;
    &lt;plugin name=&quot;result-js-footer&quot; type=&quot;Magento\Theme\Controller\Result\JsFooterPlugin&quot;/&gt;

&lt;/type&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">type</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Magento\Framework\App\Response\Http&quot;</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">plugin</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;result-js-footer&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">type</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Magento\Theme\Controller\Result\JsFooterPlugin&quot;</span><span style="color: #F92672">/&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">type</span><span style="color: #F92672">&gt;</span></span></code></pre></div>



<p>The code of this plugin looks as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="declare(strict_types=1);
namespace Magento\Theme\Controller\Result;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Response\Http;
/**
 * Plugin for putting all js to footer.
 */
class JsFooterPlugin
{
    private const XML_PATH_DEV_MOVE_JS_TO_BOTTOM = 'dev/js/move_script_to_bottom';
    /**
     * @var ScopeConfigInterface
     */
    private $scopeConfig;
    /**
     * @param ScopeConfigInterface $scopeConfig
     */
    public function __construct(ScopeConfigInterface $scopeConfig)
    {
        $this-&gt;scopeConfig = $scopeConfig;
    }
    /**
     * Put all javascript to footer before sending the response.
     *
     * @param Http $subject
     * @return void
     */
    public function beforeSendResponse(Http $subject)
    {
        $content = $subject-&gt;getContent();
        $script = [];
        if (strpos($content, '&lt;/body') !== false) { if ($this-&gt;scopeConfig-&gt;isSetFlag(
                self::XML_PATH_DEV_MOVE_JS_TO_BOTTOM,
                ScopeInterface::SCOPE_STORE
            )
            ) {
                $pattern = '#&lt;script[^&gt;]* (?&lt;!text/x-magento-template.)&gt;.*?&lt;/script&gt;#is';
                $content = preg_replace_callback(
                    $pattern,
                    function ($matchPart) use (&amp;$script) {
                        $script[] = $matchPart[0];
                        return '';
                    },
                    $content
                );
                $subject-&gt;setContent(
                    str_replace('&lt;/body', implode(&quot;\n&quot;, $script) . &quot;\n&lt;/body&quot;, $content)
                );
            }
        }
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">declare</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">strict_types</span><span style="color: #F92672">=</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F92672">namespace</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">Magento\Theme\Controller\Result</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F92672">use</span><span style="color: #F8F8F2"> Magento\Framework\App\Config\</span><span style="color: #66D9EF; font-style: italic">ScopeConfigInterface</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F92672">use</span><span style="color: #F8F8F2"> Magento\Store\Model\</span><span style="color: #66D9EF; font-style: italic">ScopeInterface</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F92672">use</span><span style="color: #F8F8F2"> Magento\Framework\App\Response\</span><span style="color: #66D9EF; font-style: italic">Http</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * Plugin for putting all js to footer.</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">JsFooterPlugin</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">private</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">const</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">XML_PATH_DEV_MOVE_JS_TO_BOTTOM</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;dev/js/move_script_to_bottom&#39;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">ScopeConfigInterface</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">private</span><span style="color: #F8F8F2"> $scopeConfig;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">ScopeConfigInterface</span><span style="color: #88846F"> $scopeConfig</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">ScopeConfigInterface</span><span style="color: #F8F8F2"> $scopeConfig)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">scopeConfig </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $scopeConfig;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * Put all javascript to footer before sending the response.</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Http</span><span style="color: #88846F"> $subject</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">void</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">beforeSendResponse</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">Http</span><span style="color: #F8F8F2"> $subject)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        $content </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getContent</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        $script </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">strpos</span><span style="color: #F8F8F2">($content, </span><span style="color: #E6DB74">&#39;&lt;/body&#39;</span><span style="color: #F8F8F2">) </span><span style="color: #F92672">!==</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">) { </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">scopeConfig</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isSetFlag</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">XML_PATH_DEV_MOVE_JS_TO_BOTTOM</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #66D9EF; font-style: italic">ScopeInterface</span><span style="color: #F92672">::</span><span style="color: #AE81FF">SCOPE_STORE</span></span>
<span class="line"><span style="color: #F8F8F2">            )</span></span>
<span class="line"><span style="color: #F8F8F2">            ) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $pattern </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;#&lt;script[^&gt;]* (?&lt;!text/x-magento-template.)&gt;.*?&lt;/script&gt;#is&#39;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">                $content </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">preg_replace_callback</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                    $pattern,</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> ($matchPart) </span><span style="color: #F92672">use</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">&amp;</span><span style="color: #F8F8F2">$script) {</span></span>
<span class="line"><span style="color: #F8F8F2">                        $script[] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $matchPart[</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">                    },</span></span>
<span class="line"><span style="color: #F8F8F2">                    $content</span></span>
<span class="line"><span style="color: #F8F8F2">                );</span></span>
<span class="line"><span style="color: #F8F8F2">                $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setContent</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF">str_replace</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;&lt;/body&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF">implode</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&quot;</span><span style="color: #AE81FF">\n</span><span style="color: #E6DB74">&quot;</span><span style="color: #F8F8F2">, $script) </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&quot;</span><span style="color: #AE81FF">\n</span><span style="color: #E6DB74">&lt;/body&quot;</span><span style="color: #F8F8F2">, $content)</span></span>
<span class="line"><span style="color: #F8F8F2">                );</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>As you can see, its purpose is to transfer JavaScript to the footer, if the shop administrator has enabled this. The error arises in the strpos function, since the $content variable is null. Let&#8217;s determine when this happens, and why.</p>



<p>There is also the Amazon Payment module in the Magento core, which requires the Amazon Login module to function, which is responsible for logging in using Amazon. If a user logs in using Amazon, this is noted in the session. Starting in Magento 2.3.1, the module unchecks this box if the user logs out of Magento. This was implemented using an asynchronous request, which is made when the user gets through the logout page. The controller Amazon\Login\Controller\Logout\Index is responsible for this, which looks as follows.<br>class Index extends \Magento\Framework\App\Action\Action</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="{
    /**
     * @var JsonFactory
     */
    private $jsonFactory;
    /**
     * @var Session
     */
    private $sessionHelper;
    /**
     * @param Context     $context
     * @param JsonFactory $jsonFactory
     * @param Session     $sessionHelper
     */
    public function __construct(Context $context, JsonFactory $jsonFactory, Session $sessionHelper)
    {
        parent::__construct($context);
        $this-&gt;jsonFactory   = $jsonFactory;
        $this-&gt;sessionHelper = $sessionHelper;
    }
    public function execute()
    {
        $this-&gt;sessionHelper-&gt;setIsAmazonLoggedIn(false);
        return $this-&gt;jsonFactory-&gt;create();
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">JsonFactory</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">private</span><span style="color: #F8F8F2"> $jsonFactory;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Session</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">private</span><span style="color: #F8F8F2"> $sessionHelper;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Context</span><span style="color: #88846F">     $context</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">JsonFactory</span><span style="color: #88846F"> $jsonFactory</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Session</span><span style="color: #88846F">     $sessionHelper</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">Context</span><span style="color: #F8F8F2"> $context, </span><span style="color: #66D9EF; font-style: italic">JsonFactory</span><span style="color: #F8F8F2"> $jsonFactory, </span><span style="color: #66D9EF; font-style: italic">Session</span><span style="color: #F8F8F2"> $sessionHelper)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #66D9EF; font-style: italic">parent</span><span style="color: #F92672">::</span><span style="color: #A6E22E">__construct</span><span style="color: #F8F8F2">($context);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">jsonFactory   </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $jsonFactory;</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">sessionHelper </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $sessionHelper;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">execute</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">sessionHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setIsAmazonLoggedIn</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">jsonFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>As you can see, the execute method of the controller returns an object of the type \Magento\Framework\Controller\Result\Json. In theory, we should have passed JSON to the front end, which should have been generated by the method.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="/**
 * Render content
 *
 * @param HttpResponseInterface|ResponseInterface $response
 * @return $this
 */
public function renderResult(ResponseInterface $response)
{
    $this-&gt;applyHttpHeaders($response);
    return $this-&gt;render($response);
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * Render content</span></span>
<span class="line"><span style="color: #88846F"> *</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">HttpResponseInterface</span><span style="color: #88846F">|</span><span style="color: #66D9EF; font-style: italic">ResponseInterface</span><span style="color: #88846F"> $response</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> $this</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">renderResult</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">ResponseInterface</span><span style="color: #F8F8F2"> $response)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">applyHttpHeaders</span><span style="color: #F8F8F2">($response);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">render</span><span style="color: #F8F8F2">($response);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>This method, in turn, calls the protected method render, which looks as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="/**
 * {@inheritdoc}
 */
protected function render(HttpResponseInterface $response)
{
    $this-&gt;translateInline-&gt;processResponseBody($this-&gt;json, true);
    $response-&gt;setHeader('Content-Type', 'application/json', true);
    $response-&gt;setBody($this-&gt;json);
    return $this;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * {</span><span style="color: #F92672">@inheritdoc</span><span style="color: #88846F">}</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">render</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">HttpResponseInterface</span><span style="color: #F8F8F2"> $response)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">translateInline</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">processResponseBody</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">json, </span><span style="color: #AE81FF">true</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    $response</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setHeader</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;Content-Type&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">&#39;application/json&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #AE81FF">true</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    $response</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setBody</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">json);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>The problem is that $this-&gt;json is NULL. One of two methods could have initialized it:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="/**
 * Set json data
 *
 * @param mixed $data
 * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
 * @param array $options Additional options used during encoding
 * @return $this
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
public function setData($data, $cycleCheck = false, $options = [])
{
    if ($data instanceof \Magento\Framework\DataObject) {
        $data = $data-&gt;toArray();
    }
    $this-&gt;json = $this-&gt;serializer-&gt;serialize($data);
    return $this;
}
/**
 * @param string $jsonData
 * @return $this
 */
public function setJsonData($jsonData)
{
    $this-&gt;json = (string)$jsonData;
    return $this;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * Set json data</span></span>
<span class="line"><span style="color: #88846F"> *</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">mixed</span><span style="color: #88846F"> $data</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">boolean</span><span style="color: #88846F"> $cycleCheck Optional; whether or not to check for object recursion; off by default</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">array</span><span style="color: #88846F"> $options Additional options used during encoding</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> $this</span></span>
<span class="line"><span style="color: #88846F"> * @SuppressWarnings(PHPMD.UnusedFormalParameter)</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">setData</span><span style="color: #F8F8F2">($data, $cycleCheck </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">, $options </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [])</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($data </span><span style="color: #F92672">instanceof</span><span style="color: #F8F8F2"> \Magento\Framework\</span><span style="color: #66D9EF; font-style: italic">DataObject</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $data </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $data</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">toArray</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">json </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">serializer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">serialize</span><span style="color: #F8F8F2">($data);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">string</span><span style="color: #88846F"> $jsonData</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> $this</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">setJsonData</span><span style="color: #F8F8F2">($jsonData)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">json </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">string</span><span style="color: #F8F8F2">)$jsonData;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>However, this was not done in the controller Amazon\Login\Controller\Logout\Index, since this controller does not need to pass any data to the front end. There&#8217;s something else we should mention. PHP has historically been a language with weak typing data. This means that in versions prior to PHP 7, if the type of the variables entered didn&#8217;t match what was declared, the most that would happen would be the function would throw a warning and return an empty or false value. This means that the code of the beforeSendResponse method could process without fatal errors. It&#8217;s the same in versions starting with PHP 7, except for the statement declare(strict_types = 1). This statement includes more strict data type control and throws a TypeError instead of automatically converting variables and throwing a warning. The conversion could have been processed in this method using try{}catch{}, but there is no such processing in this version. Using strict type control is the current Magento policy, and most core classes in Magento 2.3 contain this statement. However, developers of third-party modules, including Amazon, do not always abide by this policy.</p>



<p>Either way, this error should not exist. It can be fixed using a plugin:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;type name=&quot;Magento\Framework\App\Response\Http&quot;&gt;
    &lt;plugin name=&quot;fix-amazon-logout&quot; type=&quot;Web4pro\All\Model\Plugin&quot; sortOrder=&quot;20&quot;/&gt;
&lt;/type&gt;

public function afterGetContent($subject,$content){
    if(!$content){
        $content = &quot;&quot;;
    }
    return $content;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">type</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Magento\Framework\App\Response\Http&quot;</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">plugin</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;fix-amazon-logout&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">type</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Web4pro\All\Model\Plugin&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">sortOrder</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;20&quot;</span><span style="color: #F92672">/&gt;</span></span>
<span class="line"><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">type</span><span style="color: #F92672">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">afterGetContent</span><span style="color: #F8F8F2">($subject,$content){</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2">(</span><span style="color: #F92672">!</span><span style="color: #F8F8F2">$content){</span></span>
<span class="line"><span style="color: #F8F8F2">        $content </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&quot;&quot;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $content;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is CMS? A Guide with Definition, Costs, and Top Options for 2020</title>
		<link>https://web4pro.net/blog-news/what-is-cms-guide-for-2020/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 05 Nov 2019 15:18:51 +0000</pubDate>
				<category><![CDATA[Explore Technology]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[guide]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=9284</guid>

					<description><![CDATA[Explore what is CMS, and also learn about 7 most popular eCommerce platforms for starting a business.]]></description>
										<content:encoded><![CDATA[<p>What is CMS? A lot of people may work with WordPress for a long time, but only some of them know it’s a content management system (a.k.a CMS).</p>
<p>Today we’ll explain it to you.</p>
<h2>Content Management System (Definition)</h2>
<p>In a word, a <strong>CMS</strong> is an online platform that allows you to create, edit, and share digital content. You don’t need to know HTML, CSS, or any programming language to do the basic site. Just select a CMS, install it, and start making use of it to build your desired website.</p>
<p>With a CMS, creating a website is like a piece of cake.</p>
<h2>How Does CMS Work?</h2>
<p>Let’s take a look at the best features of a CMS.</p>
<h3>CMS Website Features</h3>
<p>The interface of a typical CMS includes the following features:</p>
<ul>
<li>a user dashboard to manage websites.</li>
<li>themes and templates to design websites quickly.</li>
<li>plugins and integrations to add functionalities and capabilities.</li>
<li>content management capabilities like the editor and media library.</li>
<li>search engine optimization (SEO) tools to ensure the web ranks well in search engine results pages.</li>
<li>Additional functionalities like a website builder to customize sites.</li>
</ul>
<p>Let’s start at the top.</p>
<h4>User Dashboard</h4>
<p>A user dashboard is the entry point to a CMS. It’s where you can access all the features of your CMS and gain insights into its performance quickly.</p>
<p>From the user dashboard, you can access your back end on both mobile and desktop, edit pages, publish content, install plugins, track website performance, and other activities.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/magento-2-demo-features/" target="_self" rel="noopener" data-wpel-link="internal">Magento 2 Demo Features: Overview</a></li>
</ul>
</div>
</div>
<h4>Themes &amp; Templates</h4>
<p>A CMS gives you the freedom to design a website and customize its appearance. Some content management systems may offer a few dozen themes, but others may contain hundreds of them.</p>
<p>Templates are often designed for specific industries like travel, writer, eCommerce, restaurants, etc. Each theme has a complete website structure and navigation menus. Just choose any theme that fits your goal and start the design process.</p>
<h4>Plugins &amp; Integrations</h4>
<p>You can install plugins to your site for specific purposes. For example, if you want to check the keyword density and SEO level of your content, you can install <a href="https://yoast.com/wordpress/plugins/seo/" target="_blank" rel="noopener">Yoast SEO</a>. Content management systems like WordPress support many types of plugins.</p>
<p>With CMS, you can install the <a href="https://analytics.google.com/analytics/web/provision/#/provision" target="_blank" rel="noopener">Google Analytics</a> plugin to track site performance. Also, you can make use of other integrations such as social media, payment processing, SEO tools, popups, etc.</p>
<h4>Content Management</h4>
<p>Think about the storage of a CMS like a series of folders, which allows you to upload text, links, videos, and images. You can even edit content within the CMS, like deleting unnecessary videos or cropping photos before publishing them to the site.</p>
<h4>SEO</h4>
<p>Most content management systems offer SEO tools to boost your website’s chances of ranking well in search engines like Google. These tools include:</p>
<ul>
<li>Automatic meta tag creation.</li>
<li>Sitemap generation.</li>
<li>Places to add content descriptions.</li>
<li>Accelerated mobile pages.</li>
</ul>
<h4>Additional Functionality</h4>
<p>Besides all the above features, a good CMS also contains additional functionality. Once you’ve created a post, you can post content immediately or schedule it to publish whenever you want. Thanks to that, you can put all the articles together into a content calendar and use CMS to share them.</p>
<p>A CMS allows you to add more users to your website. This feature is useful when you don’t have much time to control your site and want to assign someone to take charge of this task. Free to choose any role for them you want, like a subscriber or a contributor.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/website-launch-checklist-step-step-process/" target="_self" rel="noopener" data-wpel-link="internal">Website Launch Checklist: The Step by Step Process</a></li>
</ul>
</div>
</div>
<h2>7 Most Popular Content Management Systems</h2>
<p>WordPress, Joomla, Drupal, Shopify, Squarespace, Wix, and Magento are the most common names in the CMS industry. Let’s find out more about each of these.</p>
<h3>WordPress</h3>
<p><img decoding="async" class="alignnone size-large wp-image-9289" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1-1024x599.png" alt="WordPress: BuiltWith Statistics" width="1024" height="599" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1-1024x599.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1-300x176.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1-640x375.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1-768x450.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082759/1.png 1259w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/cms/WordPress" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 60.4%.</li>
<li><strong>Total live sites:</strong> 27,021,750.</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 341,364.</li>
<li><strong>Most popular sites using WordPress:</strong> TechCrunch, The New Yorker, BBC America.</li>
<li><strong>Price:</strong> Free.</li>
</ul>
<p><a href="https://wordpress.org/" target="_blank" rel="noopener">WordPress</a> currently powers over one-third of existing websites on the Internet. It’s an open-source CMS, meaning anyone can use and modify it for free. Using WordPress, you can build many things, such as eCommerce stores, blogs, online courses, social communities, etc. This powerful CMS also offers a massive library of themes as well as plugins.</p>
<h3>Joomla</h3>
<p><img decoding="async" class="alignnone size-large wp-image-9291" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2-1024x594.png" alt="Joomla: BuiltWith Statistics" width="1024" height="594" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2-1024x594.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2-300x174.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2-640x371.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2-768x446.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082758/2.png 1263w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/cms/Joomla!" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 5.7%.</li>
<li><strong>Total live sites:</strong> 1,857,666.</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 20,128.</li>
<li><strong>Most popular sites using Joomla:</strong> Harvard University, The Hill, Linux, MTV Greece.</li>
<li><strong>Price:</strong> Free.</li>
</ul>
<p><a href="https://www.joomla.org/" target="_blank" rel="noopener">Joomla</a> is the second most well-known CMS. It’s also open-source, but more advanced than WordPress. Some of Joomla’s best features include flexibility for different content types and multilingual support.</p>
<h3>Drupal</h3>
<p><img decoding="async" class="alignnone size-large wp-image-9292" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3-1024x595.png" alt="Drupal: BuiltWith Statistics" width="1024" height="595" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3-1024x595.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3-300x174.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3-640x372.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3-768x446.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082757/3.png 1260w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/cms/Drupal" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 4.7%.</li>
<li><strong>Total live sites:</strong> 651,648.</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 28,916.</li>
<li><strong>Most popular sites using Drupal:</strong> Tesla, The Economist, Australian Government.</li>
<li><strong>Price:</strong> Free.</li>
</ul>
<p><a href="https://www.drupal.org/" target="_blank" rel="noopener">Drupal</a> offers lockdown security. That’s why it’s the common choice for government institutions and other security-conscious players. Besides, Drupal provides access controls, custom content types and views, and taxonomies for handling lots of content.</p>
<h3>Shopify</h3>
<p><img decoding="async" class="alignnone size-large wp-image-9293" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4-1024x599.png" alt="Shopify: BuiltWith Statistics" width="1024" height="599" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4-1024x599.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4-300x176.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4-640x375.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4-768x449.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082756/4.png 1261w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/shop/Shopify" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 2.7%.</li>
<li><strong>Total live sites:</strong> 1,187,578.</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 23,448.</li>
<li><strong>Most popular sites using Shopify:</strong> Gymshark, Fashion Nova, Taylor Stitch.</li>
<li><strong>Price:</strong> Start at $29/mo.</li>
</ul>
<p><a href="https://www.shopify.com/" target="_blank" rel="noopener">Shopify</a> is a CMS designed specifically for eCommerce store owners. It offers an easy way to add, list, edit, and organize products with a streamlined CMS. Keyword tags, multiple variants for each product, and the facility to drag and drop product images are available as well.</p>
<h3>Squarespace</h3>
<p><img decoding="async" class="size-large wp-image-9294 alignnone" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5-1024x595.png" alt="Squarespace: BuiltWith Statistics" width="1024" height="595" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5-1024x595.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5-300x174.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5-640x372.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5-768x446.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082755/5.png 1260w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/cms/Squarespace" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 2.7%.</li>
<li><strong>Total live sites:</strong> 2,001,701.</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 9,252.</li>
<li><strong>Most popular sites using Squarespace:</strong> Big Human, UberEats, Cornell Creme.</li>
<li><strong>Price:</strong> Start at $16/mo.</li>
</ul>
<p><a href="https://www.squarespace.com/" target="_blank" rel="noopener">Squarespace</a> offers one single interface where you can change the content, tweak design styles, add custom CSS, set up analytics, etc. This CMS also allows you to drag and drop elements to create a website design you want.</p>
<h3>Wix</h3>
<h3><img decoding="async" class="size-large wp-image-9306 alignnone" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7-1024x574.png" alt="Wix: BuiltWith Statistics" width="1024" height="574" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7-1024x574.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7-300x168.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7-640x359.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7-768x431.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082752/image7.png 1262w" sizes="(max-width: 1024px) 100vw, 1024px" /></h3>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/cms/Wix" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 1.9%</li>
<li><strong>Total live sites:</strong> 3,800,881</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 6,009</li>
<li><strong>Most popular sites using Wix:</strong> Vintique, Good Feeling Goods, Tobias Becs.</li>
<li><strong>Price:</strong> Start at $10/mo.</li>
</ul>
<p><a href="https://ru.wix.com/" target="_blank" rel="noopener">Wix</a> is an ideal CMS for beginners who want to create a website from pre-built templates and don’t want to customize things too much. Wix also provides eCommerce functionalities, but they aren’t as flexible as what you can do with Shopify.</p>
<h3>Magento</h3>
<p><img decoding="async" class="alignnone size-large wp-image-9296" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6-1024x604.png" alt="Magento: BuiltWith Statistics" width="1024" height="604" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6-1024x604.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6-300x177.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6-640x377.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6-768x453.png 768w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/11/07082754/6.png 1267w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p style="text-align: center;">Source: <a href="https://trends.builtwith.com/shop/Magento" target="_blank" rel="noopener">BuiltWith</a></p>
<ul>
<li><strong>Market share:</strong> 1.8%</li>
<li><strong>Total live sites:</strong> 280,595</li>
<li><strong>Usage distribution in the top 1 million sites:</strong> 12,080</li>
<li><strong>Most popular sites using Magento:</strong> Coca Cola, Ford, Olympus, Warby Parker.</li>
<li><strong>Price:</strong> Free, but a full-featured Magento eCommerce is also available.</li>
</ul>
<p><a href="https://magento.com/" target="_blank" rel="noopener">Magento</a> CMS allows you to create new pages, blocks, and widgets for your online store. You can choose specific layout designs and templates to design your designed site. It’s a feature-rich CMS that you should take a look at.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/choosing-a-cms-platform-for-your-store-in-2020/" target="_self" rel="noopener" data-wpel-link="internal">Choosing a CMS Platform for Your Store in 2020</a></li>
</ul>
</div>
</div>
<h2>Benefits of CMS</h2>
<p>With a CMS, you can save a great deal of time in building a site and have more energy to create high-quality content. The last part of this article will show you the best advantages of using a CMS.</p>
<h3>Fits any Type and Size of Business</h3>
<p>Most content management systems support an easy-to-use interface and ready-made themes. This gives people with little or no-technical skills the ability to build their website and sell online or share knowledge of the world.</p>
<p>For tech-savvy users, they can add codes to the custom CSS to further customize their sites. Also, they can upgrade their CMS or hosting plan to experience advanced features like different storage levels and premium SEO tools.</p>
<h3>Wide Range of Integrations</h3>
<p>A CMS often comes with intuitive content management integrations with third-party tools. Let’s say you’re using WordPress for content management and HubSpot CRM. If you install and use the HubSpot WordPress plugin, you can easily group your contacts into lists and track every interaction they’ve had across your site. The benefits also cover built-in analytics, simple email automation, etc.</p>
<h3>Flexible Management and Enhanced Control</h3>
<p>All content management systems offer an easy way to manage content. You can:</p>
<ul>
<li>Set up categories, tags, links, and widgets to organize your content.</li>
<li>Add text, images, videos, audios, etc. to posts and pages.</li>
<li>Approve and delete comments or reply to comments instantly.</li>
<li>Allow others to manage content and control your CMS.</li>
<li>Schedule content to publish it at any time you want.</li>
</ul>
<p>You can get these done by going into different CMS features like Posts, Pages, Media Library, etc.</p>
<h3>Optimized Development Resources and Costs</h3>
<p>If you don’t use a CMS, you may have to hire front-end developers to make changes to your site or back-end developers to integrate an app to your site. Once you decide to install a CMS, everything goes smoothly. Non-tech employees can manage content without involving the development personnel. Using a CMS undoubtedly helps save your resources of all types.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Magento OE 1.9.4.2, Magento CE 1.14.4.2, and Their Compatibility with Different Versions of PHP</title>
		<link>https://web4pro.net/blog-news/magento-1-and-their-compatibility-with-php/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Thu, 03 Oct 2019 09:01:00 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=9191</guid>

					<description><![CDATA[Check how to avoid incompatibility issues with PHP 5 in two Magento packages.]]></description>
										<content:encoded><![CDATA[
<p>Magento 1 was developed back before PHP 5 was used. In all versions, including the latest Magento Open Source 1.9.4.2 and Magento Commerce 1.13.4.2, a check is done for PHP 5.3 at the entry point of index.php. This means that all of the code of the core, as well as the code of custom extensions, must be compatible with PHP 5.3. This official resource declares PHP compatibility: <a href="https://docs.magento.com/m1/ce/user_guide/magento/system-requirements.html" target="_blank" rel="noopener">https://docs.magento.com/m1/ce/user_guide/magento/system-requirements.html</a></p>



<p>However, incompatibility with PHP 5 was discovered when analyzing the latest versions of Magento Open Source 1.9.2.4 and Magento Commerce 1.14.4.2. Below we will take a look at the reason for these incompatibilities.</p>



<div class="ufy-block">
  <div class="ufy-block__wrapper">
    <p class="ufy-block__label">Useful for you:</p>
    <ul class="ufy-block__list">
      <li class="ufy-block__item"><a href="https://web4pro.net/blog-news/migration-magento-1-to-magento-2/" target="_self" rel="noopener" data-wpel-link="internal">Magento 2.x Age is Coming: The End of Official Magento 1.x Support is November 2018</a></li>
      <li><a href="https://web4pro.net/question/check-magento-version-and-perform-update/" target="_self" rel="noopener" data-wpel-link="internal">How to Migrate Magento 1 to Magento 2 with Data Migration Tool</a></li>
    </ul>
  </div>
</div>



<h2 class="wp-block-heading">Analysis of Incompatibility Issues with PHP 5</h2>



<p>Magento has the core class Mage_Core_Helper_Data, in which a method for getting a random string is implemented, getRandomString(). Its implementation in OE and CE before 1.9.4.2 and 1.14.4.2 looked as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function getRandomString($len, $chars = null)
    {
        if (is_null($chars)) {
            $chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS;
        }
        for ($i = 0, $str = '', $lc = strlen($chars)-1; $i &lt; $len; $i  ) {
            $str .= $chars[mt_rand(0, $lc)];
        }
        return $str;
    }" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">getRandomString</span><span style="color: #F8F8F2">($len, $chars </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_null</span><span style="color: #F8F8F2">($chars)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $chars </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_LOWERS</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_UPPERS</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_DIGITS</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">for</span><span style="color: #F8F8F2"> ($i </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $str </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">, $lc </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">strlen</span><span style="color: #F8F8F2">($chars)</span><span style="color: #F92672">-</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">; $i </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> $len; $i  ) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $str </span><span style="color: #F92672">.=</span><span style="color: #F8F8F2"> $chars[</span><span style="color: #66D9EF">mt_rand</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $lc)];</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $str;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span></code></pre></div>



<p>In the latest Magento versions that we mentioned earlier, this method was released differently:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function getRandomString($len, $chars = null)
    {
        if (is_null($chars)) {
            $chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS;
        }
        for ($i = 0, $str = '', $lc = strlen($chars)-1; $i &lt; $len; $i  ) {
            $str .= $chars[random_int(0, $lc)];
        }
        return $str;
    }" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">getRandomString</span><span style="color: #F8F8F2">($len, $chars </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_null</span><span style="color: #F8F8F2">($chars)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $chars </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_LOWERS</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_UPPERS</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">self</span><span style="color: #F92672">::</span><span style="color: #AE81FF">CHARS_DIGITS</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">for</span><span style="color: #F8F8F2"> ($i </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $str </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">, $lc </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">strlen</span><span style="color: #F8F8F2">($chars)</span><span style="color: #F92672">-</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">; $i </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> $len; $i  ) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $str </span><span style="color: #F92672">.=</span><span style="color: #F8F8F2"> $chars[</span><span style="color: #A6E22E">random_int</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $lc)];</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $str;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span></code></pre></div>



<p>As you can see, the only difference is one function: they replaced mt_rand with random_int. Therein lies the problem: the random_int function was added in PHP 7, but PHP 5 doesn&#8217;t support it. Consequently, if this method is called in PHP 5 when generating a page or executing any other code, it will lead to a fatal unknown function call error. Magento still declares compatibility starting with version 5.3 in the index.php file, which is incorrect based on what we&#8217;ve stated above.</p>



<p><strong>Why did Magento replace the function in this method?</strong> It&#8217;s most likely because the behavior of the mt_rand function was changed in PHP 7.2. Developers wanted to keep the behavior of the getRandomString method as close as possible to its behavior in previous versions. In so doing, PHP 5 support was virtually discontinued for the sake of supporting PHP 7.2. Naturally, the logical solution to this problem is upgrading the version of PHP on your server to version 7. But in some cases, this can cause problems in custom modules that are incompatible with PHP 7. Many custom modules were written before PHP 7 existed and are no longer updated. It&#8217;s also not possible to fix encoded modules that are bound to certain PHP versions. So how do we solve this problem?</p>



<h2 class="wp-block-heading">Solution</h2>



<p>In these cases, the solution could be to copy the file app/code/core/Mage/Core/functions.php to app/code/local/Mage/Core/functions.php and add the following code:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="if (!is_callable('RandomCompat_intval')) {
    /**
     * Cast to an integer if we can, safely.
     *
     * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
     * (non-inclusive), it will sanely cast it to an int. If you it's equal to
     * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
     * lose precision, so the &lt;= and =&gt; operators might accidentally let a float
     * through.
     *
     * @param int|float $number    The number we want to convert to an int
     * @param bool      $fail_open Set to true to not throw an exception
     *
     * @return float|int
     * @psalm-suppress InvalidReturnType
     *
     * @throws TypeError
     */
    function RandomCompat_intval($number, $fail_open = false)
    {
        if (is_int($number) || is_float($number)) {
            $number  = 0;
        } elseif (is_numeric($number)) {
            /** @psalm-suppress InvalidOperand */
            $number  = 0;
        }
        /** @var int|float $number */
        if (
            is_float($number)
            &amp;&amp;
            $number &gt; ~PHP_INT_MAX
            &amp;&amp;
            $number &lt; PHP_INT_MAX
        ) {
            $number = (int) $number;
        }
        if (is_int($number)) {
            return (int) $number;
        } elseif (!$fail_open) {
            throw new TypeError(
                'Expected an integer.'
            );
        }
        return $number;
    }
}
if (!is_callable('random_int')) {

    /**
     * Fetch a random integer between $min and $max inclusive
     *
     * @param int $min
     * @param int $max
     *
     * @throws Exception
     *
     * @return int
     */
    function random_int($min, $max)
    {
        /**
         * Type and input logic checks
         *
         * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
         * (non-inclusive), it will sanely cast it to an int. If you it's equal to
         * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
         * lose precision, so the &lt;= and =&gt; operators might accidentally let a float
         * through.
         */
        try {
            /** @var int $min */
            $min = RandomCompat_intval($min);
        } catch (TypeError $ex) {
            throw new TypeError(
                'random_int(): $min must be an integer'
            );
        }
        try {
            /** @var int $max */
            $max = RandomCompat_intval($max);
        } catch (TypeError $ex) {
            throw new TypeError(
                'random_int(): $max must be an integer'
            );
        }
        /**
         * Now that we've verified our weak typing system has given us an integer,
         * let's validate the logic then we can move forward with generating random
         * integers along a given range.
         */
        if ($min &gt; $max) {
            throw new Error(
                'Minimum value must be less than or equal to the maximum value'
            );
        }
        if ($max === $min) {
            return (int) $min;
        }
        /**
         * Initialize variables to 0
         *
         * We want to store:
         * $bytes =&gt; the number of random bytes we need
         * $mask =&gt; an integer bitmask (for use with the &amp;) operator
         *          so we can minimize the number of discards
         */
        $attempts = $bits = $bytes = $mask = $valueShift = 0;
        /** @var int $attempts */
        /** @var int $bits */
        /** @var int $bytes */
        /** @var int $mask */
        /** @var int $valueShift */
        /**
         * At this point, $range is a positive number greater than 0. It might
         * overflow, however, if $max - $min &gt; PHP_INT_MAX. PHP will cast it to
         * a float and we will lose some precision.
         *
         * @var int|float $range
         */
        $range = $max - $min;
        /**
         * Test for integer overflow:
         */
        if (!is_int($range)) {
            /**
             * Still safely calculate wider ranges.
             * Provided by @CodesInChaos, @oittaa
             *
             * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435
             *
             * We use ~0 as a mask in this case because it generates all 1s
             *
             * @ref https://eval.in/400356 (32-bit)
             * @ref http://3v4l.org/XX9r5  (64-bit)
             */
            $bytes = PHP_INT_SIZE;
            /** @var int $mask */
            $mask = ~0;
        } else {
            /**
             * $bits is effectively ceil(log($range, 2)) without dealing with
             * type juggling
             */
            while ($range &gt; 0) {
                if ($bits % 8 === 0) {
                      $bytes;
                }
                  $bits;
                $range &gt;&gt;= 1;
                /** @var int $mask */
                $mask = $mask &lt;&lt; 1 | 1; } $valueShift = $min; } /** @var int $val */ $val = 0; /** * Now that we have our parameters set up, let's begin generating * random integers until one falls between $min and $max */ /** @psalm-suppress RedundantCondition */ do { /** * The rejection probability is at most 0.5, so this corresponds * to a failure probability of 2^-128 for a working RNG */ if ($attempts &gt; 128) {
                throw new Exception(
                    'random_int: RNG is broken - too many rejections'
                );
            }
            /**
             * Let's grab the necessary number of random bytes
             */
            $randomByteString = random_bytes($bytes);
            /**
             * Let's turn $randomByteString into an integer
             *
             * This uses bitwise operators (&lt;&lt; and |) to build an integer * out of the values extracted from ord() * * Example: [9F] | [6D] | [32] | [0C] =&gt;
             *   159   27904   3276800   201326592 =&gt;
             *   204631455
             */
            $val &amp;= 0;
            for ($i = 0; $i &lt; $bytes;   $i) {
                $val |= ord($randomByteString[$i]) &lt;&lt; ($i * 8); } /** @var int $val */ /** * Apply mask */ $val &amp;= $mask; $val  = $valueShift;   $attempts; /** * If $val overflows to a floating point number, * ... or is larger than $max, * ... or smaller than $min, * then try again. */ } while (!is_int($val) || $val &gt; $max || $val &lt; $min);
        return (int) $val;
    }
}
if (!is_callable('random_bytes')) {
    /**
     * Powered by ext/mcrypt (and thankfully NOT libmcrypt)
     *
     * @ref https://bugs.php.net/bug.php?id=55169
     * @ref https://github.com/php/php-src/blob/c568ffe5171d942161fc8dda066bce844bdef676/ext/mcrypt/mcrypt.c#L1321-L1386
     *
     * @param int $bytes
     *
     * @throws Exception
     *
     * @return string
     */
    function random_bytes($bytes)
    {
        try {
            /** @var int $bytes */
            $bytes = RandomCompat_intval($bytes);
        } catch (TypeError $ex) {
            throw new TypeError(
                'random_bytes(): $bytes must be an integer'
            );
        }
        if ($bytes &lt; 1) {
            throw new Error(
                'Length must be greater than 0'
            );
        }
        /** @var string|bool $buf */
        $buf = @mcrypt_create_iv((int) $bytes, (int) MCRYPT_DEV_URANDOM);
        if (
            is_string($buf)
            &amp;&amp;
            RandomCompat_strlen($buf) === $bytes
        ) {
            /**
             * Return our random entropy buffer here:
             */
            return $buf;
        }
        /**
         * If we reach here, PHP has failed us.
         */
        throw new Exception(
            'Could not gather sufficient random data'
        );
    }
}
if (!is_callable('RandomCompat_strlen')) {
    if (
        defined('MB_OVERLOAD_STRING')
        &amp;&amp;
        ((int) ini_get('mbstring.func_overload')) &amp; MB_OVERLOAD_STRING
    ) {
        /**
         * strlen() implementation that isn't brittle to mbstring.func_overload
         *
         * This version uses mb_strlen() in '8bit' mode to treat strings as raw
         * binary rather than UTF-8, ISO-8859-1, etc
         *
         * @param string $binary_string
         *
         * @throws TypeError
         *
         * @return int
         */
        function RandomCompat_strlen($binary_string)
        {
            if (!is_string($binary_string)) {
                throw new TypeError(
                    'RandomCompat_strlen() expects a string'
                );
            }
            return (int) mb_strlen($binary_string, '8bit');
        }
    } else {
        /**
         * strlen() implementation that isn't brittle to mbstring.func_overload
         *
         * This version just used the default strlen()
         *
         * @param string $binary_string
         *
         * @throws TypeError
         *
         * @return int
         */
        function RandomCompat_strlen($binary_string)
        {
            if (!is_string($binary_string)) {
                throw new TypeError(
                    'RandomCompat_strlen() expects a string'
                );
            }
            return (int) strlen($binary_string);
        }
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_callable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;RandomCompat_intval&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * Cast to an integer if we can, safely.</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)</span></span>
<span class="line"><span style="color: #88846F">     * (non-inclusive), it will sanely cast it to an int. If you it&#39;s equal to</span></span>
<span class="line"><span style="color: #88846F">     * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats</span></span>
<span class="line"><span style="color: #88846F">     * lose precision, so the &lt;= and =&gt; operators might accidentally let a float</span></span>
<span class="line"><span style="color: #88846F">     * through.</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F">|</span><span style="color: #F92672">float</span><span style="color: #88846F"> $number    The number we want to convert to an int</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">bool</span><span style="color: #88846F">      $fail_open Set to true to not throw an exception</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">float</span><span style="color: #88846F">|</span><span style="color: #F92672">int</span></span>
<span class="line"><span style="color: #88846F">     * @psalm-suppress InvalidReturnType</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_intval</span><span style="color: #F8F8F2">($number, $fail_open </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_int</span><span style="color: #F8F8F2">($number) </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">is_float</span><span style="color: #F8F8F2">($number)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $number  </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">elseif</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_numeric</span><span style="color: #F8F8F2">($number)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** @psalm-suppress InvalidOperand */</span></span>
<span class="line"><span style="color: #F8F8F2">            $number  </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F">|</span><span style="color: #F92672">float</span><span style="color: #88846F"> $number */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #66D9EF">is_float</span><span style="color: #F8F8F2">($number)</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">&amp;&amp;</span></span>
<span class="line"><span style="color: #F8F8F2">            $number </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">~</span><span style="color: #66D9EF">PHP_INT_MAX</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">&amp;&amp;</span></span>
<span class="line"><span style="color: #F8F8F2">            $number </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">PHP_INT_MAX</span></span>
<span class="line"><span style="color: #F8F8F2">        ) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $number </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) $number;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_int</span><span style="color: #F8F8F2">($number)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) $number;</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">elseif</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #F8F8F2">$fail_open) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;Expected an integer.&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $number;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_callable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;random_int&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * Fetch a random integer between $min and $max inclusive</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $min</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $max</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Exception</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">random_int</span><span style="color: #F8F8F2">($min, $max)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * Type and input logic checks</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)</span></span>
<span class="line"><span style="color: #88846F">         * (non-inclusive), it will sanely cast it to an int. If you it&#39;s equal to</span></span>
<span class="line"><span style="color: #88846F">         * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats</span></span>
<span class="line"><span style="color: #88846F">         * lose precision, so the &lt;= and =&gt; operators might accidentally let a float</span></span>
<span class="line"><span style="color: #88846F">         * through.</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">try</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $min */</span></span>
<span class="line"><span style="color: #F8F8F2">            $min </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_intval</span><span style="color: #F8F8F2">($min);</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">catch</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2"> $ex) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;random_int(): $min must be an integer&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">try</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $max */</span></span>
<span class="line"><span style="color: #F8F8F2">            $max </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_intval</span><span style="color: #F8F8F2">($max);</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">catch</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2"> $ex) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;random_int(): $max must be an integer&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * Now that we&#39;ve verified our weak typing system has given us an integer,</span></span>
<span class="line"><span style="color: #88846F">         * let&#39;s validate the logic then we can move forward with generating random</span></span>
<span class="line"><span style="color: #88846F">         * integers along a given range.</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($min </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> $max) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Error</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;Minimum value must be less than or equal to the maximum value&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($max </span><span style="color: #F92672">===</span><span style="color: #F8F8F2"> $min) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) $min;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * Initialize variables to 0</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * We want to store:</span></span>
<span class="line"><span style="color: #88846F">         * $bytes =&gt; the number of random bytes we need</span></span>
<span class="line"><span style="color: #88846F">         * $mask =&gt; an integer bitmask (for use with the &amp;) operator</span></span>
<span class="line"><span style="color: #88846F">         *          so we can minimize the number of discards</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        $attempts </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $bits </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $bytes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $mask </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $valueShift </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $attempts */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $bits */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $bytes */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $mask */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $valueShift */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * At this point, $range is a positive number greater than 0. It might</span></span>
<span class="line"><span style="color: #88846F">         * overflow, however, if $max - $min &gt; PHP_INT_MAX. PHP will cast it to</span></span>
<span class="line"><span style="color: #88846F">         * a float and we will lose some precision.</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F">|</span><span style="color: #F92672">float</span><span style="color: #88846F"> $range</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        $range </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $max </span><span style="color: #F92672">-</span><span style="color: #F8F8F2"> $min;</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * Test for integer overflow:</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_int</span><span style="color: #F8F8F2">($range)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">             * Still safely calculate wider ranges.</span></span>
<span class="line"><span style="color: #88846F">             * Provided by @CodesInChaos, @oittaa</span></span>
<span class="line"><span style="color: #88846F">             *</span></span>
<span class="line"><span style="color: #88846F">             * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435</span></span>
<span class="line"><span style="color: #88846F">             *</span></span>
<span class="line"><span style="color: #88846F">             * We use ~0 as a mask in this case because it generates all 1s</span></span>
<span class="line"><span style="color: #88846F">             *</span></span>
<span class="line"><span style="color: #88846F">             * @ref https://eval.in/400356 (32-bit)</span></span>
<span class="line"><span style="color: #88846F">             * @ref http://3v4l.org/XX9r5  (64-bit)</span></span>
<span class="line"><span style="color: #88846F">             */</span></span>
<span class="line"><span style="color: #F8F8F2">            $bytes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">PHP_INT_SIZE</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $mask */</span></span>
<span class="line"><span style="color: #F8F8F2">            $mask </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">~</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">             * $bits is effectively ceil(log($range, 2)) without dealing with</span></span>
<span class="line"><span style="color: #88846F">             * type juggling</span></span>
<span class="line"><span style="color: #88846F">             */</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">while</span><span style="color: #F8F8F2"> ($range </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($bits </span><span style="color: #F92672">%</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">8</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">===</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">                      $bytes;</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                  $bits;</span></span>
<span class="line"><span style="color: #F8F8F2">                $range </span><span style="color: #F92672">&gt;&gt;=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $mask */</span></span>
<span class="line"><span style="color: #F8F8F2">                $mask </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $mask </span><span style="color: #F92672">&lt;&lt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">; } $valueShift </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $min; } </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $val */</span><span style="color: #F8F8F2"> $val </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">; </span><span style="color: #88846F">/** * Now that we have our parameters set up, let&#39;s begin generating * random integers until one falls between $min and $max */</span><span style="color: #F8F8F2"> </span><span style="color: #88846F">/** @psalm-suppress RedundantCondition */</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">do</span><span style="color: #F8F8F2"> { </span><span style="color: #88846F">/** * The rejection probability is at most 0.5, so this corresponds * to a failure probability of 2^-128 for a working RNG */</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($attempts </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">128</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Exception</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #E6DB74">&#39;random_int: RNG is broken - too many rejections&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">                );</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">             * Let&#39;s grab the necessary number of random bytes</span></span>
<span class="line"><span style="color: #88846F">             */</span></span>
<span class="line"><span style="color: #F8F8F2">            $randomByteString </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">random_bytes</span><span style="color: #F8F8F2">($bytes);</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">             * Let&#39;s turn $randomByteString into an integer</span></span>
<span class="line"><span style="color: #88846F">             *</span></span>
<span class="line"><span style="color: #88846F">             * This uses bitwise operators (&lt;&lt; and |) to build an integer * out of the values extracted from ord() * * Example: [9F] | [6D] | [32] | [0C] =&gt;</span></span>
<span class="line"><span style="color: #88846F">             *   159   27904   3276800   201326592 =&gt;</span></span>
<span class="line"><span style="color: #88846F">             *   204631455</span></span>
<span class="line"><span style="color: #88846F">             */</span></span>
<span class="line"><span style="color: #F8F8F2">            $val </span><span style="color: #F92672">&amp;=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">for</span><span style="color: #F8F8F2"> ($i </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">; $i </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> $bytes;   $i) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $val </span><span style="color: #F92672">|=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">ord</span><span style="color: #F8F8F2">($randomByteString[$i]) </span><span style="color: #F92672">&lt;&lt;</span><span style="color: #F8F8F2"> ($i </span><span style="color: #F92672">*</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">8</span><span style="color: #F8F8F2">); } </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $val */</span><span style="color: #F8F8F2"> </span><span style="color: #88846F">/** * Apply mask */</span><span style="color: #F8F8F2"> $val </span><span style="color: #F92672">&amp;=</span><span style="color: #F8F8F2"> $mask; $val  </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $valueShift;   $attempts; </span><span style="color: #88846F">/** * If $val overflows to a floating point number, * ... or is larger than $max, * ... or smaller than $min, * then try again. */</span><span style="color: #F8F8F2"> } </span><span style="color: #F92672">while</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_int</span><span style="color: #F8F8F2">($val) </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> $val </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> $max </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> $val </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> $min);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) $val;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_callable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;random_bytes&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">     * Powered by ext/mcrypt (and thankfully NOT libmcrypt)</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * @ref https://bugs.php.net/bug.php?id=55169</span></span>
<span class="line"><span style="color: #88846F">     * @ref https://github.com/php/php-src/blob/c568ffe5171d942161fc8dda066bce844bdef676/ext/mcrypt/mcrypt.c#L1321-L1386</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $bytes</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">Exception</span></span>
<span class="line"><span style="color: #88846F">     *</span></span>
<span class="line"><span style="color: #88846F">     * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">string</span></span>
<span class="line"><span style="color: #88846F">     */</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">random_bytes</span><span style="color: #F8F8F2">($bytes)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">try</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span><span style="color: #88846F"> $bytes */</span></span>
<span class="line"><span style="color: #F8F8F2">            $bytes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_intval</span><span style="color: #F8F8F2">($bytes);</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">catch</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2"> $ex) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;random_bytes(): $bytes must be an integer&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($bytes </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Error</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #E6DB74">&#39;Length must be greater than 0&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">            );</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> </span><span style="color: #F92672">string</span><span style="color: #88846F">|</span><span style="color: #F92672">bool</span><span style="color: #88846F"> $buf */</span></span>
<span class="line"><span style="color: #F8F8F2">        $buf </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">@</span><span style="color: #66D9EF">mcrypt_create_iv</span><span style="color: #F8F8F2">((</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) $bytes, (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) </span><span style="color: #66D9EF">MCRYPT_DEV_URANDOM</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #66D9EF">is_string</span><span style="color: #F8F8F2">($buf)</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">&amp;&amp;</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #A6E22E">RandomCompat_strlen</span><span style="color: #F8F8F2">($buf) </span><span style="color: #F92672">===</span><span style="color: #F8F8F2"> $bytes</span></span>
<span class="line"><span style="color: #F8F8F2">        ) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">             * Return our random entropy buffer here:</span></span>
<span class="line"><span style="color: #88846F">             */</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $buf;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * If we reach here, PHP has failed us.</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Exception</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;Could not gather sufficient random data&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">        );</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_callable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;RandomCompat_strlen&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #66D9EF">defined</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;MB_OVERLOAD_STRING&#39;</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">&amp;&amp;</span></span>
<span class="line"><span style="color: #F8F8F2">        ((</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) </span><span style="color: #66D9EF">ini_get</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;mbstring.func_overload&#39;</span><span style="color: #F8F8F2">)) </span><span style="color: #F92672">&amp;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">MB_OVERLOAD_STRING</span></span>
<span class="line"><span style="color: #F8F8F2">    ) {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * strlen() implementation that isn&#39;t brittle to mbstring.func_overload</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * This version uses mb_strlen() in &#39;8bit&#39; mode to treat strings as raw</span></span>
<span class="line"><span style="color: #88846F">         * binary rather than UTF-8, ISO-8859-1, etc</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">string</span><span style="color: #88846F"> $binary_string</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_strlen</span><span style="color: #F8F8F2">($binary_string)</span></span>
<span class="line"><span style="color: #F8F8F2">        {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_string</span><span style="color: #F8F8F2">($binary_string)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #E6DB74">&#39;RandomCompat_strlen() expects a string&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">                );</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) </span><span style="color: #66D9EF">mb_strlen</span><span style="color: #F8F8F2">($binary_string, </span><span style="color: #E6DB74">&#39;8bit&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">         * strlen() implementation that isn&#39;t brittle to mbstring.func_overload</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * This version just used the default strlen()</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #F92672">string</span><span style="color: #88846F"> $binary_string</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span></span>
<span class="line"><span style="color: #88846F">         *</span></span>
<span class="line"><span style="color: #88846F">         * </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #F92672">int</span></span>
<span class="line"><span style="color: #88846F">         */</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">RandomCompat_strlen</span><span style="color: #F8F8F2">($binary_string)</span></span>
<span class="line"><span style="color: #F8F8F2">        {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_string</span><span style="color: #F8F8F2">($binary_string)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">TypeError</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #E6DB74">&#39;RandomCompat_strlen() expects a string&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">                );</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">) </span><span style="color: #66D9EF">strlen</span><span style="color: #F8F8F2">($binary_string);</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Magento 2.2 Bug Preventing Users from Updating Their Passwords, and a Method for Fixing It</title>
		<link>https://web4pro.net/blog-news/magento-2-2-bug-and-a-method-for-fixing-it/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Thu, 29 Aug 2019 08:50:30 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8797</guid>

					<description><![CDATA[Learn how to fix the bug when updating the old password in Magento 2.2 from our case.]]></description>
										<content:encoded><![CDATA[
<p>There is a bug in Magento 2.2, starting with version 2.2.6, which prevents users from resetting their passwords if they forget them. When attempting to reset their passwords, users get an error message saying, &#8220;Something went wrong while saving the new password.&#8221;</p>



<p>The reason for this error was specified here: https://github.com/magento/magento2/issues/18256. The error was resolved in version 2.3, and it involved the sequence of operators responsible for clearing the session of the resetPassword method of the app/code/Magento/Customer/Model/AccountManagement.php class. People who are still using version 2.2.6 or 2.2.7 can install a patch, but there&#8217;s another way to fix this problem. You can fix the bug in the third-party module and in so doing avoid this error. We will examine how to do this.</p>



<h2 class="wp-block-heading">Eliminating the Bug in the Third-Party Module</h2>



<p>To eliminate the bug, we have to replace the app/code/Magento/Customer/Model/AccountManagement.php class in the Magento\Customer\Controller\Account\ResetPasswordPost controller, using a dependence-injection like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;type name=&quot;Magento\Customer\Controller\Account\ResetPasswordPost&quot;&gt;
 &lt;arguments&gt;
 &lt;argument name=&quot;accountManagement&quot;
 xsi:type=&quot;object&quot;&gt;Web4pro\Wholesale\Model\AccountManagement&lt;/argument&gt;
 &lt;/arguments&gt;
 &lt;/type&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">type</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Magento\Customer\Controller\Account\ResetPasswordPost&quot;</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">arguments</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">argument</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;accountManagement&quot;</span></span>
<span class="line"><span style="color: #F8F8F2"> xsi:</span><span style="color: #AE81FF">type</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;object&quot;</span><span style="color: #F92672">&gt;</span><span style="color: #AE81FF">Web4pro</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Wholesale</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Model</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">AccountManagement</span><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">argument</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">arguments</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">type</span><span style="color: #F92672">&gt;</span></span></code></pre></div>



<p></p>



<p>It&#8217;s not advised to redefine through preference, but since we only need to fix the problem within the limits of one controller call, this method will work. Another difficulty is that the majority of the methods and properties of the original class are private. Because of this, a given class will look like this:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="class AccountManagement extends \Magento\Customer\Model\AccountManagement
{
protected $customerRepository;
protected $credentialsValidator;
protected $customerRegistry;
protected $sessionManager;
protected $searchCriteriaBuilder;
protected $scopeConfig;
protected $dateTimeFactory;
protected $visitorCollectionFactory;
protected $saveHandler;
public function __construct(CustomerFactory $customerFactory, ManagerInterface $eventManager,
StoreManagerInterface $storeManager, Random $mathRandom, Validator $validator,
ValidationResultsInterfaceFactory $validationResultsDataFactory, AddressRepositoryInterface
$addressRepository, CustomerMetadataInterface $customerMetadataService, CustomerRegistry
$customerRegistry, PsrLogger $logger, Encryptor $encryptor, ConfigShare $configShare, StringHelper
$stringHelper, CustomerRepositoryInterface $customerRepository, ScopeConfigInterface $scopeConfig,
TransportBuilder $transportBuilder, DataObjectProcessor $dataProcessor, Registry $registry, CustomerViewHelper
$customerViewHelper, DateTime $dateTime, CustomerModel $customerModel, ObjectFactory $objectFactory,
ExtensibleDataObjectConverter $extensibleDataObjectConverter, CredentialsValidator $credentialsValidator =
null, DateTimeFactory $dateTimeFactory = null, AccountConfirmation $accountConfirmation = null,
SessionManagerInterface $sessionManager = null, SaveHandlerInterface $saveHandler = null, CollectionFactory
$visitorCollectionFactory = null, SearchCriteriaBuilder $searchCriteriaBuilder = null)
{
$this-&gt;customerRepository = $customerRepository;
$this-&gt;customerRegistry = $customerRegistry;
$this-&gt;sessionManager = $sessionManager;
$this-&gt;searchCriteriaBuilder = $searchCriteriaBuilder?:ObjectManager::getInstance()-
&gt;get(SearchCriteriaBuilder::class);
$this-&gt;credentialsValidator = $credentialsValidator?: ObjectManager::getInstance()-
&gt;get(CredentialsValidator::class);
$this-&gt;scopeConfig = $scopeConfig;

$this-&gt;dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()-
&gt;get(DateTimeFactory::class);
$this-&gt;visitorCollectionFactory = $visitorCollectionFactory?:ObjectManager::getInstance()-
&gt;get(CollectionFactory::class);
$this-&gt;saveHandler = $saveHandler?: ObjectManager::getInstance()-
&gt;get(SaveHandlerInterface::class);
parent::__construct($customerFactory, $eventManager, $storeManager, $mathRandom, $validator,
$validationResultsDataFactory, $addressRepository, $customerMetadataService, $customerRegistry, $logger,
$encryptor, $configShare, $stringHelper, $customerRepository, $scopeConfig, $transportBuilder, $dataProcessor,
$registry, $customerViewHelper, $dateTime, $customerModel, $objectFactory, $extensibleDataObjectConverter,
$credentialsValidator, $dateTimeFactory, $accountConfirmation, $sessionManager, $saveHandler,
$visitorCollectionFactory, $searchCriteriaBuilder);
}
public function resetPassword($email, $resetToken, $newPassword)
{
if (!$email) {
$customer = $this-&gt;matchCustomerByRpToken($resetToken);
$email = $customer-&gt;getEmail();
} else {
$customer = $this-&gt;customerRepository-&gt;get($email);
}
//Validate Token and new password strength
$this-&gt;validateResetPasswordToken($customer-&gt;getId(), $resetToken);
$this-&gt;credentialsValidator-&gt;checkPasswordDifferentFromEmail(
$email,
$newPassword
);
$this-&gt;checkPasswordStrength($newPassword);
//Update secure data
$customerSecure = $this-&gt;customerRegistry-&gt;retrieveSecureData($customer-&gt;getId());
$customerSecure-&gt;setRpToken(null);
$customerSecure-&gt;setRpTokenCreatedAt(null);
$customerSecure-&gt;setPasswordHash($this-&gt;createPasswordHash($newPassword));
$this-&gt;getAuthentication()-&gt;unlock($customer-&gt;getId());
$this-&gt;destroyCustomerSessions($customer-&gt;getId());
$this-&gt;sessionManager-&gt;destroy();
$this-&gt;customerRepository-&gt;save($customer);
return true;
}
protected function matchCustomerByRpToken($rpToken)
{
$this-&gt;searchCriteriaBuilder-&gt;addFilter(
'rp_token',
$rpToken
);
$this-&gt;searchCriteriaBuilder-&gt;setPageSize(1);
$found = $this-&gt;customerRepository-&gt;getList(
$this-&gt;searchCriteriaBuilder-&gt;create()
);
if ($found-&gt;getTotalCount() &gt; 1) {
//Failed to generated unique RP token
throw new ExpiredException(
new Phrase('Reset password token expired.')
);
}
if ($found-&gt;getTotalCount() === 0) {
//Customer with such token not found.
throw NoSuchEntityException::singleField(
'rp_token',

$rpToken
);
}
//Unique customer found.
return $found-&gt;getItems()[0];
}
protected function validateResetPasswordToken($customerId, $resetPasswordLinkToken)
{
if (empty($customerId) || $customerId &lt; 0) { //Looking for the customer. $customerId = $this-&gt;matchCustomerByRpToken($resetPasswordLinkToken)
-&gt;getId();
}
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
$params = ['fieldName' =&gt; 'resetPasswordLinkToken'];
throw new InputException(__('%fieldName is a required field.', $params));
}
$customerSecureData = $this-&gt;customerRegistry-&gt;retrieveSecureData($customerId);
$rpToken = $customerSecureData-&gt;getRpToken();
$rpTokenCreatedAt = $customerSecureData-&gt;getRpTokenCreatedAt();
if (!Security::compareStrings($rpToken, $resetPasswordLinkToken)) {
throw new InputMismatchException(__('Reset password token mismatch.'));
} elseif ($this-&gt;isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)) {
throw new ExpiredException(__('Reset password token expired.'));
}
return true;
}
/**
* Get authentication
*
* @return AuthenticationInterface
*/
protected function getAuthentication()
{
if (!($this-&gt;authentication instanceof \Magento\Customer\Model\AuthenticationInterface)) {
return \Magento\Framework\App\ObjectManager::getInstance()-&gt;get(
\Magento\Customer\Model\AuthenticationInterface::class
);
} else {
return $this-&gt;authentication;
}
}
protected function destroyCustomerSessions($customerId)
{
$sessionLifetime = $this-&gt;scopeConfig-&gt;getValue(
\Magento\Framework\Session\Config::XML_PATH_COOKIE_LIFETIME,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
$dateTime = $this-&gt;dateTimeFactory-&gt;create();
$activeSessionsTime = $dateTime-&gt;setTimestamp($dateTime-&gt;getTimestamp() - $sessionLifetime)
-&gt;format(DateTime::DATETIME_PHP_FORMAT);
/** @var \Magento\Customer\Model\ResourceModel\Visitor\Collection $visitorCollection */
$visitorCollection = $this-&gt;visitorCollectionFactory-&gt;create();
$visitorCollection-&gt;addFieldToFilter('customer_id', $customerId);
$visitorCollection-&gt;addFieldToFilter('last_visit_at', ['from' =&gt; $activeSessionsTime]);
$visitorCollection-&gt;addFieldToFilter('session_id', ['neq' =&gt; $this-&gt;sessionManager-&gt;getSessionId()]);
/** @var \Magento\Customer\Model\Visitor $visitor */
foreach ($visitorCollection-&gt;getItems() as $visitor) {

$sessionId = $visitor-&gt;getSessionId();
$this-&gt;saveHandler-&gt;destroy($sessionId);
}
}
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">AccountManagement</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">extends</span><span style="color: #F8F8F2"> \Magento\Customer\Model\</span><span style="color: #A6E22E; font-style: italic; text-decoration: underline">AccountManagement</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $customerRepository;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $credentialsValidator;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $customerRegistry;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $sessionManager;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $searchCriteriaBuilder;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $scopeConfig;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $dateTimeFactory;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $visitorCollectionFactory;</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $saveHandler;</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">CustomerFactory</span><span style="color: #F8F8F2"> $customerFactory, </span><span style="color: #66D9EF; font-style: italic">ManagerInterface</span><span style="color: #F8F8F2"> $eventManager,</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">StoreManagerInterface</span><span style="color: #F8F8F2"> $storeManager, </span><span style="color: #66D9EF; font-style: italic">Random</span><span style="color: #F8F8F2"> $mathRandom, </span><span style="color: #66D9EF; font-style: italic">Validator</span><span style="color: #F8F8F2"> $validator,</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">ValidationResultsInterfaceFactory</span><span style="color: #F8F8F2"> $validationResultsDataFactory, AddressRepositoryInterface</span></span>
<span class="line"><span style="color: #F8F8F2">$addressRepository, </span><span style="color: #66D9EF; font-style: italic">CustomerMetadataInterface</span><span style="color: #F8F8F2"> $customerMetadataService, CustomerRegistry</span></span>
<span class="line"><span style="color: #F8F8F2">$customerRegistry, </span><span style="color: #66D9EF; font-style: italic">PsrLogger</span><span style="color: #F8F8F2"> $logger, </span><span style="color: #66D9EF; font-style: italic">Encryptor</span><span style="color: #F8F8F2"> $encryptor, </span><span style="color: #66D9EF; font-style: italic">ConfigShare</span><span style="color: #F8F8F2"> $configShare, StringHelper</span></span>
<span class="line"><span style="color: #F8F8F2">$stringHelper, </span><span style="color: #66D9EF; font-style: italic">CustomerRepositoryInterface</span><span style="color: #F8F8F2"> $customerRepository, </span><span style="color: #66D9EF; font-style: italic">ScopeConfigInterface</span><span style="color: #F8F8F2"> $scopeConfig,</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">TransportBuilder</span><span style="color: #F8F8F2"> $transportBuilder, </span><span style="color: #66D9EF; font-style: italic">DataObjectProcessor</span><span style="color: #F8F8F2"> $dataProcessor, </span><span style="color: #66D9EF; font-style: italic">Registry</span><span style="color: #F8F8F2"> $registry, CustomerViewHelper</span></span>
<span class="line"><span style="color: #F8F8F2">$customerViewHelper, </span><span style="color: #66D9EF; font-style: italic">DateTime</span><span style="color: #F8F8F2"> $dateTime, </span><span style="color: #66D9EF; font-style: italic">CustomerModel</span><span style="color: #F8F8F2"> $customerModel, </span><span style="color: #66D9EF; font-style: italic">ObjectFactory</span><span style="color: #F8F8F2"> $objectFactory,</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">ExtensibleDataObjectConverter</span><span style="color: #F8F8F2"> $extensibleDataObjectConverter, </span><span style="color: #66D9EF; font-style: italic">CredentialsValidator</span><span style="color: #F8F8F2"> $credentialsValidator </span><span style="color: #F92672">=</span></span>
<span class="line"><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">DateTimeFactory</span><span style="color: #F8F8F2"> $dateTimeFactory </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">AccountConfirmation</span><span style="color: #F8F8F2"> $accountConfirmation </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">SessionManagerInterface</span><span style="color: #F8F8F2"> $sessionManager </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">SaveHandlerInterface</span><span style="color: #F8F8F2"> $saveHandler </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, CollectionFactory</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollectionFactory </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">SearchCriteriaBuilder</span><span style="color: #F8F8F2"> $searchCriteriaBuilder </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRepository </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $customerRepository;</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRegistry </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $customerRegistry;</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">sessionManager </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $sessionManager;</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">searchCriteriaBuilder </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $searchCriteriaBuilder</span><span style="color: #F92672">?:</span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-</span></span>
<span class="line"><span style="color: #F92672">&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">SearchCriteriaBuilder</span><span style="color: #F92672">::class</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">credentialsValidator </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $credentialsValidator</span><span style="color: #F92672">?:</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-</span></span>
<span class="line"><span style="color: #F92672">&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">CredentialsValidator</span><span style="color: #F92672">::class</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">scopeConfig </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $scopeConfig;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">dateTimeFactory </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $dateTimeFactory </span><span style="color: #F92672">?:</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-</span></span>
<span class="line"><span style="color: #F92672">&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">DateTimeFactory</span><span style="color: #F92672">::class</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">visitorCollectionFactory </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $visitorCollectionFactory</span><span style="color: #F92672">?:</span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-</span></span>
<span class="line"><span style="color: #F92672">&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">CollectionFactory</span><span style="color: #F92672">::class</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">saveHandler </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $saveHandler</span><span style="color: #F92672">?:</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-</span></span>
<span class="line"><span style="color: #F92672">&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">SaveHandlerInterface</span><span style="color: #F92672">::class</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">parent</span><span style="color: #F92672">::</span><span style="color: #A6E22E">__construct</span><span style="color: #F8F8F2">($customerFactory, $eventManager, $storeManager, $mathRandom, $validator,</span></span>
<span class="line"><span style="color: #F8F8F2">$validationResultsDataFactory, $addressRepository, $customerMetadataService, $customerRegistry, $logger,</span></span>
<span class="line"><span style="color: #F8F8F2">$encryptor, $configShare, $stringHelper, $customerRepository, $scopeConfig, $transportBuilder, $dataProcessor,</span></span>
<span class="line"><span style="color: #F8F8F2">$registry, $customerViewHelper, $dateTime, $customerModel, $objectFactory, $extensibleDataObjectConverter,</span></span>
<span class="line"><span style="color: #F8F8F2">$credentialsValidator, $dateTimeFactory, $accountConfirmation, $sessionManager, $saveHandler,</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollectionFactory, $searchCriteriaBuilder);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">resetPassword</span><span style="color: #F8F8F2">($email, $resetToken, $newPassword)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #F8F8F2">$email) {</span></span>
<span class="line"><span style="color: #F8F8F2">$customer </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">matchCustomerByRpToken</span><span style="color: #F8F8F2">($resetToken);</span></span>
<span class="line"><span style="color: #F8F8F2">$email </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $customer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEmail</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">} </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">$customer </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRepository</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">($email);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #88846F">//Validate Token and new password strength</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">validateResetPasswordToken</span><span style="color: #F8F8F2">($customer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getId</span><span style="color: #F8F8F2">(), $resetToken);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">credentialsValidator</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">checkPasswordDifferentFromEmail</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">$email,</span></span>
<span class="line"><span style="color: #F8F8F2">$newPassword</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">checkPasswordStrength</span><span style="color: #F8F8F2">($newPassword);</span></span>
<span class="line"><span style="color: #88846F">//Update secure data</span></span>
<span class="line"><span style="color: #F8F8F2">$customerSecure </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRegistry</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">retrieveSecureData</span><span style="color: #F8F8F2">($customer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getId</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">$customerSecure</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setRpToken</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">$customerSecure</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setRpTokenCreatedAt</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">$customerSecure</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setPasswordHash</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">createPasswordHash</span><span style="color: #F8F8F2">($newPassword));</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getAuthentication</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">unlock</span><span style="color: #F8F8F2">($customer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getId</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">destroyCustomerSessions</span><span style="color: #F8F8F2">($customer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getId</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">sessionManager</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">destroy</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRepository</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">save</span><span style="color: #F8F8F2">($customer);</span></span>
<span class="line"><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">true</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">matchCustomerByRpToken</span><span style="color: #F8F8F2">($rpToken)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">searchCriteriaBuilder</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addFilter</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #E6DB74">&#39;rp_token&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">$rpToken</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">searchCriteriaBuilder</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setPageSize</span><span style="color: #F8F8F2">(</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">$found </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRepository</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getList</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">searchCriteriaBuilder</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($found</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTotalCount</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #88846F">//Failed to generated unique RP token</span></span>
<span class="line"><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ExpiredException</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Phrase</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;Reset password token expired.&#39;</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($found</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTotalCount</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">===</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #88846F">//Customer with such token not found.</span></span>
<span class="line"><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">NoSuchEntityException</span><span style="color: #F92672">::</span><span style="color: #A6E22E">singleField</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #E6DB74">&#39;rp_token&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">$rpToken</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #88846F">//Unique customer found.</span></span>
<span class="line"><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $found</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getItems</span><span style="color: #F8F8F2">()[</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">validateResetPasswordToken</span><span style="color: #F8F8F2">($customerId, $resetPasswordLinkToken)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">empty</span><span style="color: #F8F8F2">($customerId) </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> $customerId </span><span style="color: #F92672">&lt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) { </span><span style="color: #88846F">//Looking for the customer. $customerId = $this-&gt;matchCustomerByRpToken($resetPasswordLinkToken)</span></span>
<span class="line"><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getId</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">is_string</span><span style="color: #F8F8F2">($resetPasswordLinkToken) </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">empty</span><span style="color: #F8F8F2">($resetPasswordLinkToken)) {</span></span>
<span class="line"><span style="color: #F8F8F2">$params </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [</span><span style="color: #E6DB74">&#39;fieldName&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;resetPasswordLinkToken&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">InputException</span><span style="color: #F8F8F2">(</span><span style="color: #A6E22E">__</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;%fieldName is a required field.&#39;</span><span style="color: #F8F8F2">, $params));</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F8F8F2">$customerSecureData </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">customerRegistry</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">retrieveSecureData</span><span style="color: #F8F8F2">($customerId);</span></span>
<span class="line"><span style="color: #F8F8F2">$rpToken </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $customerSecureData</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getRpToken</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">$rpTokenCreatedAt </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $customerSecureData</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getRpTokenCreatedAt</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF; font-style: italic">Security</span><span style="color: #F92672">::</span><span style="color: #A6E22E">compareStrings</span><span style="color: #F8F8F2">($rpToken, $resetPasswordLinkToken)) {</span></span>
<span class="line"><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">InputMismatchException</span><span style="color: #F8F8F2">(</span><span style="color: #A6E22E">__</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;Reset password token mismatch.&#39;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">} </span><span style="color: #F92672">elseif</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isResetPasswordLinkTokenExpired</span><span style="color: #F8F8F2">($rpToken, $rpTokenCreatedAt)) {</span></span>
<span class="line"><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ExpiredException</span><span style="color: #F8F8F2">(</span><span style="color: #A6E22E">__</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;Reset password token expired.&#39;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">true</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F">* Get authentication</span></span>
<span class="line"><span style="color: #88846F">*</span></span>
<span class="line"><span style="color: #88846F">* </span><span style="color: #F92672">@return</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">AuthenticationInterface</span></span>
<span class="line"><span style="color: #88846F">*/</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">getAuthentication</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">authentication </span><span style="color: #F92672">instanceof</span><span style="color: #F8F8F2"> \Magento\Customer\Model\</span><span style="color: #66D9EF; font-style: italic">AuthenticationInterface</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F92672">return</span><span style="color: #F8F8F2"> \Magento\Framework\App\</span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">\Magento\Customer\Model\</span><span style="color: #66D9EF; font-style: italic">AuthenticationInterface</span><span style="color: #F92672">::class</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">} </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">authentication;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">destroyCustomerSessions</span><span style="color: #F8F8F2">($customerId)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">$sessionLifetime </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">scopeConfig</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getValue</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">\Magento\Framework\Session\</span><span style="color: #66D9EF; font-style: italic">Config</span><span style="color: #F92672">::</span><span style="color: #AE81FF">XML_PATH_COOKIE_LIFETIME</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">\Magento\Store\Model\</span><span style="color: #66D9EF; font-style: italic">ScopeInterface</span><span style="color: #F92672">::</span><span style="color: #AE81FF">SCOPE_STORE</span></span>
<span class="line"><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">$dateTime </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">dateTimeFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">$activeSessionsTime </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $dateTime</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setTimestamp</span><span style="color: #F8F8F2">($dateTime</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTimestamp</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">-</span><span style="color: #F8F8F2"> $sessionLifetime)</span></span>
<span class="line"><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">format</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">DateTime</span><span style="color: #F92672">::</span><span style="color: #AE81FF">DATETIME_PHP_FORMAT</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> \Magento\Customer\Model\ResourceModel\Visitor\</span><span style="color: #66D9EF; font-style: italic">Collection</span><span style="color: #88846F"> $visitorCollection */</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollection </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">visitorCollectionFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addFieldToFilter</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;customer_id&#39;</span><span style="color: #F8F8F2">, $customerId);</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addFieldToFilter</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;last_visit_at&#39;</span><span style="color: #F8F8F2">, [</span><span style="color: #E6DB74">&#39;from&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $activeSessionsTime]);</span></span>
<span class="line"><span style="color: #F8F8F2">$visitorCollection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addFieldToFilter</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;session_id&#39;</span><span style="color: #F8F8F2">, [</span><span style="color: #E6DB74">&#39;neq&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">sessionManager</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSessionId</span><span style="color: #F8F8F2">()]);</span></span>
<span class="line"><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> \Magento\Customer\Model\</span><span style="color: #66D9EF; font-style: italic">Visitor</span><span style="color: #88846F"> $visitor */</span></span>
<span class="line"><span style="color: #F92672">foreach</span><span style="color: #F8F8F2"> ($visitorCollection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getItems</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $visitor) {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">$sessionId </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $visitor</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSessionId</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">saveHandler</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">destroy</span><span style="color: #F8F8F2">($sessionId);</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"></span></code></pre></div>



<div class="ufy-block">
  <div class="ufy-block__wrapper">
    <p class="ufy-block__label">Useful for you:</p>
    <ul class="ufy-block__list">
      <li class="ufy-block__item"><a href="https://web4pro.net/blog-news/magento-2-2-4-core-bug-saving-store-view-design-configuration-changes/" target="_self" rel="noopener" data-wpel-link="internal">Magento 2.2.4 Core Bug: Saving Store-View Design Configuration Changes</a></li>
      <li class="ufy-block__item"><a href="https://web4pro.net/blog-news/managing-the-magento-2-2-4-category-tree-checkbox-bug/" target="_self" rel="noopener" data-wpel-link="internal">Managing the Magento 2.2.4 Category Tree Checkbox Bug</a></li>
      <li class="ufy-block__item"><a href="https://web4pro.net/blog-news/magento-2-2-6-bug-saving-placeholder-image/" target="_self" rel="noopener" data-wpel-link="internal">Magento 2.2.6 Bug When Saving Placeholder Image</a></li>
    </ul>
  </div>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Upgrading Magento to 2.2.8 While Using Mageplaza Smtp Extension 1.2.9: Fixing Errors</title>
		<link>https://web4pro.net/blog-news/upgrading-magento-2-2-8-fixing-errors/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Thu, 20 Jun 2019 12:50:20 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8590</guid>

					<description><![CDATA[Check the solution for fixing the conflict between Magento 2.2.8 and Mageplaza Smtp extension.]]></description>
										<content:encoded><![CDATA[
<p>The Magento 2 era began on November 17, 2015, when Magento released the first version of its 2.0 line. Since then, Magento has been launching updates one after another, while sometimes supporting several branches at the same time. Magento 2.0 is no longer supported, but subsequent versions (2.1, 2.2, 2.3) still are. Magento supports several branches simultaneously because different systems have different requirements. For example, Magento 2.1 still supports PHP 5.6, whereas the minimum version of PHP for Magento 2.2 is 7.0.13 and for Magento 2.3 it&#8217;s 7.1.3.</p>



<p>It&#8217;s not always feasible for store owners to update to new versions. Moreover, stores usually contain third-party modules which, broadly speaking, shouldn&#8217;t conflict with new versions of Magento, although in reality they sometimes do. So even though Magento 2.3 was released on November 28, 2018, many store owners are still using version 2.2 and will be for quite a while.</p>



<p>On March 26, 2019, Magento released the three latest versions in each branch: 2.1.7, 2.2.8, and 2.3.1. We would like to discuss working with the extension for version 2.2.8.</p>



<h2 class="wp-block-heading">Background on the Mageplaza Smtp Extension</h2>



<p>Third-party extensions are often used for sending emails. One of these extensions is the module Mageplaza Smtp. This extension is free, which is why it&#8217;s popular. That being said, after upgrading the core to version 2.2.8 and the Mageplaza module to version 1.2.9, the site stopped sending emails. We will investigate why this happened.</p>



<p>Let’s analyze the Mageplaza Smtp module. It is embedded in Magento for sending emails, using the following plugin:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;type name=&quot;Magento\Framework\Mail\TransportInterface&quot;&gt;
    &lt;plugin name=&quot;mageplaza_mail_transport&quot; type=&quot;Mageplaza\Smtp\Mail\Transport&quot; sortOrder=&quot;1&quot; disabled=&quot;false&quot;/&gt;
&lt;/type&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">type</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Magento\Framework\Mail\TransportInterface&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #F92672">plugin</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;mageplaza_mail_transport&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">type</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Mageplaza\Smtp\Mail\Transport&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">sortOrder</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;1&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">disabled</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;false&quot;</span><span style="color: #F8F8F2">/&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #F92672">type</span><span style="color: #F8F8F2">&gt;</span></span></code></pre></div>



<p>We are interested in the constructor and only one method of this plugin:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function __construct(
    Mail $resourceMail,
    LogFactory $logFactory,
    Registry $registry,
    Data $helper,
    LoggerInterface $logger
)
{
    $this-&gt;resourceMail = $resourceMail;
    $this-&gt;logFactory = $logFactory;
    $this-&gt;registry = $registry;
    $this-&gt;helper = $helper;
    $this-&gt;logger = $logger;
}
/**
 * @param TransportInterface $subject
 * @param \Closure $proceed
 * @throws MailException
 * @throws \Zend_Exception
 */
public function aroundSendMessage(
    TransportInterface $subject,
    \Closure $proceed
)
{
    $this-&gt;_storeId = $this-&gt;registry-&gt;registry('mp_smtp_store_id');
    $message = $this-&gt;getMessage($subject);
    if ($this-&gt;resourceMail-&gt;isModuleEnable($this-&gt;_storeId) &amp;&amp; $message) {
        if ($this-&gt;helper-&gt;versionCompare('2.3.0')) {
            $message = \Zend\Mail\Message::fromString($message-&gt;getRawMessage());
        }
        $message = $this-&gt;resourceMail-&gt;processMessage($message, $this-&gt;_storeId);
        $transport = $this-&gt;resourceMail-&gt;getTransport($this-&gt;_storeId);
        try {
            if (!$this-&gt;resourceMail-&gt;isDeveloperMode($this-&gt;_storeId)) {
                $transport-&gt;send($message);
            }
            $this-&gt;emailLog($message);
        } catch (\Exception $e) {
            $this-&gt;emailLog($message, false);
            throw new MailException(new Phrase($e-&gt;getMessage()), $e);
        }
    } else {
        $proceed();
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">Mail</span><span style="color: #F8F8F2"> $resourceMail,</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">LogFactory</span><span style="color: #F8F8F2"> $logFactory,</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">Registry</span><span style="color: #F8F8F2"> $registry,</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">Data</span><span style="color: #F8F8F2"> $helper,</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">LoggerInterface</span><span style="color: #F8F8F2"> $logger</span></span>
<span class="line"><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $resourceMail;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">logFactory </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $logFactory;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">registry </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $registry;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">helper </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $helper;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">logger </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $logger;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #88846F">/**</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">TransportInterface</span><span style="color: #88846F"> $subject</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@param</span><span style="color: #88846F"> \</span><span style="color: #66D9EF; font-style: italic">Closure</span><span style="color: #88846F"> $proceed</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> </span><span style="color: #66D9EF; font-style: italic">MailException</span></span>
<span class="line"><span style="color: #88846F"> * </span><span style="color: #F92672">@throws</span><span style="color: #88846F"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Exception</span></span>
<span class="line"><span style="color: #88846F"> */</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">aroundSendMessage</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #66D9EF; font-style: italic">TransportInterface</span><span style="color: #F8F8F2"> $subject,</span></span>
<span class="line"><span style="color: #F8F8F2">    \</span><span style="color: #66D9EF; font-style: italic">Closure</span><span style="color: #F8F8F2"> $proceed</span></span>
<span class="line"><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">registry</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">registry</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;mp_smtp_store_id&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMessage</span><span style="color: #F8F8F2">($subject);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isModuleEnable</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId) </span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2"> $message) {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">helper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">versionCompare</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;2.3.0&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> \Zend\Mail\</span><span style="color: #66D9EF; font-style: italic">Message</span><span style="color: #F92672">::</span><span style="color: #A6E22E">fromString</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getRawMessage</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">processMessage</span><span style="color: #F8F8F2">($message, </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">        $transport </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTransport</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">try</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isDeveloperMode</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $transport</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">send</span><span style="color: #F8F8F2">($message);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">emailLog</span><span style="color: #F8F8F2">($message);</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">catch</span><span style="color: #F8F8F2"> (\</span><span style="color: #66D9EF; font-style: italic">Exception</span><span style="color: #F8F8F2"> $e) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">emailLog</span><span style="color: #F8F8F2">($message, </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">MailException</span><span style="color: #F8F8F2">(</span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Phrase</span><span style="color: #F8F8F2">($e</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMessage</span><span style="color: #F8F8F2">()), $e);</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">        $proceed();</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>As we can see, it checks the Magento version and executes additional code if the version is greater than or equal to 2.3.0.<strong>Why does this happen?</strong> Magento&#8217;s main library is Zend Framework. However, for historical reasons, Magento 2 contains both Zend Framework 1 classes and Zend Framework 2 classes. For a long time, Magento used Zend Framework 1 classes to send emails, but there was a transition to Zend Framework 2 classes in version 2.3.0. The use of Zend Framework 2 libraries were then added to version 2.2.8 as well.</p>



<p>It&#8217;s likely that the Mageplaza developer team didn&#8217;t know this when they released this version, so they created a check for version 2.3.0, which made the Mageplaza Smtp 1.2.9 extension incompatible with Magento 2.2.8. That being said, this conflict can be resolved.</p>



<h2 class="wp-block-heading">Solution for Compatibility Between Version 1.2.9 of the Mageplaza Smtp Module and Magento 2.2.8</h2>



<p>Let&#8217;s look at which other classes are checked for the version. These classes are Mageplaza\Smtp\Mail\Rse\Mail and Mageplaza\Smtp\Model\Log. In these classes, there is a check for version 2.3.0. Let&#8217;s rework the comparison to check for 2.2.8. The actual solution to this problem looks as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="di.xml

&lt;type name=&quot;Magentice\All\Model\Mail\Transport&quot;&gt;
    &lt;arguments&gt;
        &lt;argument name=&quot;resourceMail&quot; xsi:type=&quot;object&quot;&gt;Web4pro\All\Model\Mail&lt;/argument&gt;
    &lt;/arguments&gt;
&lt;/type&gt;
&lt;type name=&quot;Mageplaza\Smtp\Plugin\Message&quot;&gt;
    &lt;arguments&gt;
        &lt;argument name=&quot;resourceMail&quot; xsi:type=&quot;object&quot;&gt;Web4pro\All\Model\Mail&lt;/argument&gt;
    &lt;/arguments&gt;
&lt;/type&gt;
&lt;preference for=&quot;Mageplaza\Smtp\Mail\Transport&quot; type=&quot;Web4pro\All\Model\Mail\Transport&quot;/&gt;
&lt;type name=&quot;Mageplaza\Smtp\Model\Log&quot;&gt;
    &lt;plugin name=&quot;fix-mageplaz-228-incompability&quot; type=&quot;Web4pro\All\Model\Plugin&quot; sortOrder=&quot;20&quot;/&gt;
&lt;/type&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">di.xml</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">type</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Magentice\All\Model\Mail\Transport&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #F92672">arguments</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #F92672">argument</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;resourceMail&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">xsi:type</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;object&quot;</span><span style="color: #F8F8F2">&gt;Web4pro\All\Model\Mail&lt;/</span><span style="color: #F92672">argument</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;/</span><span style="color: #F92672">arguments</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #F92672">type</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">type</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Mageplaza\Smtp\Plugin\Message&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #F92672">arguments</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #F92672">argument</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;resourceMail&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">xsi:type</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;object&quot;</span><span style="color: #F8F8F2">&gt;Web4pro\All\Model\Mail&lt;/</span><span style="color: #F92672">argument</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;/</span><span style="color: #F92672">arguments</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #F92672">type</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">preference</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">for</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Mageplaza\Smtp\Mail\Transport&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">type</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Web4pro\All\Model\Mail\Transport&quot;</span><span style="color: #F8F8F2">/&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">type</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Mageplaza\Smtp\Model\Log&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #F92672">plugin</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;fix-mageplaz-228-incompability&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">type</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Web4pro\All\Model\Plugin&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">sortOrder</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;20&quot;</span><span style="color: #F8F8F2">/&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #F92672">type</span><span style="color: #F8F8F2">&gt;</span></span></code></pre></div>



<p>The classes will look as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="Web4pro\All\Model\Mail\Transport

class Transport extends \Mageplaza\Smtp\Mail\Transport
{
    public function aroundSendMessage(
        TransportInterface $subject,
        \Closure $proceed
    )
    {
        $this-&gt;_storeId = $this-&gt;registry-&gt;registry('mp_smtp_store_id');
        $message = $this-&gt;getMessage($subject);
        if ($this-&gt;resourceMail-&gt;isModuleEnable($this-&gt;_storeId) &amp;&amp; $message) {
            if ($this-&gt;helper-&gt;versionCompare('2.2.8')) {
                $message = \Zend\Mail\Message::fromString($message-&gt;getRawMessage());
            }
            $message = $this-&gt;resourceMail-&gt;processMessage($message, $this-&gt;_storeId);
            $transport = $this-&gt;resourceMail-&gt;getTransport($this-&gt;_storeId);
            try {
                if (!$this-&gt;resourceMail-&gt;isDeveloperMode($this-&gt;_storeId)) {
                    $transport-&gt;send($message);
                }
                $this-&gt;emailLog($message);
            } catch (\Exception $e) {
                $this-&gt;emailLog($message, false);
                throw new MailException(new Phrase($e-&gt;getMessage()), $e);
            }
        } else {
            $proceed();
        }
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #AE81FF">Web4pro</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">All</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Model</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Mail</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Transport</span></span>
<span class="line"></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">Transport</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">extends</span><span style="color: #F8F8F2"> \Mageplaza\Smtp\Mail\</span><span style="color: #A6E22E; font-style: italic; text-decoration: underline">Transport</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">aroundSendMessage</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #66D9EF; font-style: italic">TransportInterface</span><span style="color: #F8F8F2"> $subject,</span></span>
<span class="line"><span style="color: #F8F8F2">        \</span><span style="color: #66D9EF; font-style: italic">Closure</span><span style="color: #F8F8F2"> $proceed</span></span>
<span class="line"><span style="color: #F8F8F2">    )</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">registry</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">registry</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;mp_smtp_store_id&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMessage</span><span style="color: #F8F8F2">($subject);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isModuleEnable</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId) </span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2"> $message) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">helper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">versionCompare</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;2.2.8&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> \Zend\Mail\</span><span style="color: #66D9EF; font-style: italic">Message</span><span style="color: #F92672">::</span><span style="color: #A6E22E">fromString</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getRawMessage</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            $message </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">processMessage</span><span style="color: #F8F8F2">($message, </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">            $transport </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTransport</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">try</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resourceMail</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isDeveloperMode</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_storeId)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                    $transport</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">send</span><span style="color: #F8F8F2">($message);</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">emailLog</span><span style="color: #F8F8F2">($message);</span></span>
<span class="line"><span style="color: #F8F8F2">            } </span><span style="color: #F92672">catch</span><span style="color: #F8F8F2"> (\</span><span style="color: #66D9EF; font-style: italic">Exception</span><span style="color: #F8F8F2"> $e) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">emailLog</span><span style="color: #F8F8F2">($message, </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">MailException</span><span style="color: #F8F8F2">(</span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Phrase</span><span style="color: #F8F8F2">($e</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMessage</span><span style="color: #F8F8F2">()), $e);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">            $proceed();</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>This class redefines the around plugin from Mageplaza_Smtp.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="Web4pro\All\Model\Mail

class Mail extends \Mageplaza\Smtp\Mail\Rse\Mail
{
    public function processMessage($message, $storeId)
    {
        if (!isset($this-&gt;_returnPath[$storeId])) {
            $this-&gt;_returnPath[$storeId] = $this-&gt;smtpHelper-&gt;getSmtpConfig('return_path_email', $storeId);
        }
        if ($this-&gt;_returnPath[$storeId]) {
            if ($this-&gt;smtpHelper-&gt;versionCompare('2.3.0')) {
                $message-&gt;getHeaders()-&gt;addHeaders([&quot;Return-Path&quot; =&gt; $this-&gt;_returnPath[$storeId]]);
            } else if (method_exists($message, 'setReturnPath')) {
                $message-&gt;setReturnPath($this-&gt;_returnPath[$storeId]);
            }
        }
        if (!empty($this-&gt;_fromByStore) &amp;&amp;
            (($message instanceof \Zend\Mail\Message &amp;&amp; !$message-&gt;getFrom()-&gt;count()))
        ) {
            $message-&gt;setFrom($this-&gt;_fromByStore['email'], $this-&gt;_fromByStore['name']);
        }
        return $message;
    }
    public function getTransport($storeId)
    {
        if (null === $this-&gt;_transport) {
            if (!isset($this-&gt;_smtpOptions[$storeId])) {
                $configData = $this-&gt;smtpHelper-&gt;getSmtpConfig('', $storeId);
                $options = [
                    'host' =&gt; isset($configData['host']) ? $configData['host'] : '',
                    'port' =&gt; isset($configData['port']) ? $configData['port'] : ''
                ];
                if (isset($configData['authentication']) &amp;&amp; $configData['authentication'] !== &quot;&quot;) {
                    $options  = [
                        'auth' =&gt; $configData['authentication'],
                        'username' =&gt; isset($configData['username']) ? $configData['username'] : '',
                        'password' =&gt; $this-&gt;smtpHelper-&gt;getPassword($storeId)
                    ];
                }
                if (isset($configData['protocol']) &amp;&amp; $configData['protocol'] !== &quot;&quot;) {
                    $options['ssl'] = $configData['protocol'];
                }
                $this-&gt;_smtpOptions[$storeId] = $options;
            }
            if (!isset($this-&gt;_smtpOptions[$storeId]['host']) || !$this-&gt;_smtpOptions[$storeId]['host']) {
                throw new \Zend_Exception('A host is necessary for smtp transport, but none was given');
            }
            if ($this-&gt;smtpHelper-&gt;versionCompare('2.2.8')) {
                $options = $this-&gt;_smtpOptions[$storeId];
                if (isset($options['auth'])) {
                    $options['connection_class'] = $options['auth'];
                    $options['connection_config'] = [
                        'username' =&gt; $options['username'],
                        'password' =&gt; $options['password']
                    ];
                    unset($options['auth']);
                    unset($options['username']);
                    unset($options['password']);
                }
                if (isset($options['ssl'])) {
                    $options['connection_config']['ssl'] = $options['ssl'];
                    unset($options['ssl']);
                }
                unset($options['type']);
                $options = new \Zend\Mail\Transport\SmtpOptions($options);
                $this-&gt;_transport = new \Zend\Mail\Transport\Smtp($options);
            } else {
                $this-&gt;_transport = new \Zend_Mail_Transport_Smtp($this-&gt;_smtpOptions[$storeId]['host'], $this-&gt;_smtpOptions[$storeId]);
            }
        }
        return $this-&gt;_transport;
    }

Web4pro\All\Model\Plugin

class Plugin
{
    protected $productMetaData;
    public function __construct(\Magento\Framework\App\ProductMetadata $productMetaData)
    {
        $this-&gt;productMetaData = $productMetaData;
    }
public function aroundSaveLog($subject,$proceed,$message,$status){
    if(version_compare($this-&gt;productMetaData-&gt;getVersion(),'2.2.8','&lt;')){
        $proceed($message,$status);
    }else{
        if ($message-&gt;getSubject()) {
            $subject-&gt;setSubject($message-&gt;getSubject());
        }
        $from = $message-&gt;getFrom();
        if (count($from)) {
            $from-&gt;rewind();
            $subject-&gt;setSender($from-&gt;current()-&gt;getEmail());
        }
        $toArr = [];
        foreach($message-&gt;getTo() as $toAddr){
            $toArr[] = $toAddr-&gt;getEmail();
        }
        $subject-&gt;setRecipient(implode(',', $toArr));
        $ccArr = [];
        foreach($message-&gt;getCc() as $ccAddr){
            $ccArr[] = $ccAddr-&gt;getEmail();
        }
        $subject-&gt;setCc(implode(',', $ccArr));
        $bccArr = [];
        foreach($message-&gt;getBcc() as $bccAddr){
            $bccArr[] = $bccAddr-&gt;getEmail();
        }
        $subject-&gt;setBcc(implode(',', $bccArr));
        $content = htmlspecialchars($message-&gt;getBodyText());
        $subject-&gt;setEmailContent($content)
            -&gt;setStatus($status)
            -&gt;save();
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #AE81FF">Web4pro</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">All</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Model</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Mail</span></span>
<span class="line"></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">Mail</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">extends</span><span style="color: #F8F8F2"> \Mageplaza\Smtp\Mail\Rse\</span><span style="color: #A6E22E; font-style: italic; text-decoration: underline">Mail</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">processMessage</span><span style="color: #F8F8F2">($message, $storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_returnPath[$storeId])) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_returnPath[$storeId] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">smtpHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSmtpConfig</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;return_path_email&#39;</span><span style="color: #F8F8F2">, $storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_returnPath[$storeId]) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">smtpHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">versionCompare</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;2.3.0&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getHeaders</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addHeaders</span><span style="color: #F8F8F2">([</span><span style="color: #E6DB74">&quot;Return-Path&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_returnPath[$storeId]]);</span></span>
<span class="line"><span style="color: #F8F8F2">            } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">method_exists</span><span style="color: #F8F8F2">($message, </span><span style="color: #E6DB74">&#39;setReturnPath&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setReturnPath</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_returnPath[$storeId]);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">empty</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_fromByStore) </span><span style="color: #F92672">&amp;&amp;</span></span>
<span class="line"><span style="color: #F8F8F2">            (($message </span><span style="color: #F92672">instanceof</span><span style="color: #F8F8F2"> \Zend\Mail\</span><span style="color: #66D9EF; font-style: italic">Message</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">!</span><span style="color: #F8F8F2">$message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getFrom</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">count</span><span style="color: #F8F8F2">()))</span></span>
<span class="line"><span style="color: #F8F8F2">        ) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setFrom</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_fromByStore[</span><span style="color: #E6DB74">&#39;email&#39;</span><span style="color: #F8F8F2">], </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_fromByStore[</span><span style="color: #E6DB74">&#39;name&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $message;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">getTransport</span><span style="color: #F8F8F2">($storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">===</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_transport) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId])) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $configData </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">smtpHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSmtpConfig</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">, $storeId);</span></span>
<span class="line"><span style="color: #F8F8F2">                $options </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($configData[</span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">?</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">:</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #E6DB74">&#39;port&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($configData[</span><span style="color: #E6DB74">&#39;port&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">?</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;port&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">:</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">                ];</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($configData[</span><span style="color: #E6DB74">&#39;authentication&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;authentication&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">!==</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&quot;&quot;</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">                    $options  </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #E6DB74">&#39;auth&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;authentication&#39;</span><span style="color: #F8F8F2">],</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($configData[</span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">?</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">:</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #E6DB74">&#39;password&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">smtpHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getPassword</span><span style="color: #F8F8F2">($storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">                    ];</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($configData[</span><span style="color: #E6DB74">&#39;protocol&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;protocol&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">!==</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&quot;&quot;</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">                    $options[</span><span style="color: #E6DB74">&#39;ssl&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $configData[</span><span style="color: #E6DB74">&#39;protocol&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $options;</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId][</span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2">]) </span><span style="color: #F92672">||</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">!</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId][</span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2">]) {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Exception</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;A host is necessary for smtp transport, but none was given&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">smtpHelper</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">versionCompare</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;2.2.8&#39;</span><span style="color: #F8F8F2">)) {</span></span>
<span class="line"><span style="color: #F8F8F2">                $options </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId];</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;auth&#39;</span><span style="color: #F8F8F2">])) {</span></span>
<span class="line"><span style="color: #F8F8F2">                    $options[</span><span style="color: #E6DB74">&#39;connection_class&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $options[</span><span style="color: #E6DB74">&#39;auth&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">                    $options[</span><span style="color: #E6DB74">&#39;connection_config&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $options[</span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2">],</span></span>
<span class="line"><span style="color: #F8F8F2">                        </span><span style="color: #E6DB74">&#39;password&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $options[</span><span style="color: #E6DB74">&#39;password&#39;</span><span style="color: #F8F8F2">]</span></span>
<span class="line"><span style="color: #F8F8F2">                    ];</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF">unset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;auth&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF">unset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;username&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF">unset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;password&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">isset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;ssl&#39;</span><span style="color: #F8F8F2">])) {</span></span>
<span class="line"><span style="color: #F8F8F2">                    $options[</span><span style="color: #E6DB74">&#39;connection_config&#39;</span><span style="color: #F8F8F2">][</span><span style="color: #E6DB74">&#39;ssl&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $options[</span><span style="color: #E6DB74">&#39;ssl&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">                    </span><span style="color: #66D9EF">unset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;ssl&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">                }</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #66D9EF">unset</span><span style="color: #F8F8F2">($options[</span><span style="color: #E6DB74">&#39;type&#39;</span><span style="color: #F8F8F2">]);</span></span>
<span class="line"><span style="color: #F8F8F2">                $options </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \Zend\Mail\Transport\</span><span style="color: #66D9EF; font-style: italic">SmtpOptions</span><span style="color: #F8F8F2">($options);</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_transport </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \Zend\Mail\Transport\</span><span style="color: #66D9EF; font-style: italic">Smtp</span><span style="color: #F8F8F2">($options);</span></span>
<span class="line"><span style="color: #F8F8F2">            } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_transport </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Mail_Transport_Smtp</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId][</span><span style="color: #E6DB74">&#39;host&#39;</span><span style="color: #F8F8F2">], </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_smtpOptions[$storeId]);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_transport;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #AE81FF">Web4pro</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">All</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Model</span><span style="color: #F8F8F2">\</span><span style="color: #AE81FF">Plugin</span></span>
<span class="line"></span>
<span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">Plugin</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $productMetaData;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(\Magento\Framework\App\</span><span style="color: #66D9EF; font-style: italic">ProductMetadata</span><span style="color: #F8F8F2"> $productMetaData)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">productMetaData </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $productMetaData;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">aroundSaveLog</span><span style="color: #F8F8F2">($subject,$proceed,$message,$status){</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF">version_compare</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">productMetaData</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getVersion</span><span style="color: #F8F8F2">(),</span><span style="color: #E6DB74">&#39;2.2.8&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #E6DB74">&#39;&lt;&#39;</span><span style="color: #F8F8F2">)){</span></span>
<span class="line"><span style="color: #F8F8F2">        $proceed($message,$status);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span><span style="color: #F92672">else</span><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSubject</span><span style="color: #F8F8F2">()) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setSubject</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getSubject</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $from </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getFrom</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">count</span><span style="color: #F8F8F2">($from)) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $from</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">rewind</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">            $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setSender</span><span style="color: #F8F8F2">($from</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">current</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEmail</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $toArr </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTo</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $toAddr){</span></span>
<span class="line"><span style="color: #F8F8F2">            $toArr[] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $toAddr</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEmail</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setRecipient</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF">implode</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;,&#39;</span><span style="color: #F8F8F2">, $toArr));</span></span>
<span class="line"><span style="color: #F8F8F2">        $ccArr </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getCc</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $ccAddr){</span></span>
<span class="line"><span style="color: #F8F8F2">            $ccArr[] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $ccAddr</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEmail</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setCc</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF">implode</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;,&#39;</span><span style="color: #F8F8F2">, $ccArr));</span></span>
<span class="line"><span style="color: #F8F8F2">        $bccArr </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getBcc</span><span style="color: #F8F8F2">() </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $bccAddr){</span></span>
<span class="line"><span style="color: #F8F8F2">            $bccArr[] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $bccAddr</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEmail</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setBcc</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF">implode</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;,&#39;</span><span style="color: #F8F8F2">, $bccArr));</span></span>
<span class="line"><span style="color: #F8F8F2">        $content </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">htmlspecialchars</span><span style="color: #F8F8F2">($message</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getBodyText</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">        $subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setEmailContent</span><span style="color: #F8F8F2">($content)</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setStatus</span><span style="color: #F8F8F2">($status)</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">save</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Shopify Review: Pros and Cons for eCommerce Business</title>
		<link>https://web4pro.net/blog-news/shopify-review-pros-cons-ecommerce-business/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 14 May 2019 09:42:02 +0000</pubDate>
				<category><![CDATA[Explore Technology]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[Shopify]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8434</guid>

					<description><![CDATA[Check our Shopify platform review, compare its pros and cons to decide whether it fits your online business.]]></description>
										<content:encoded><![CDATA[<p>A decade ago, there weren&#8217;t any eCommerce websites who could take the top spot, and then Shopify arrived with a new concept. Shopify is a web application through which you will be able to have your very own online store, regardless of whether or not your business has a physical address.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-8435" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12.png" alt="Shopify Website" width="1581" height="800" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12.png 1581w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12-300x152.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12-1024x518.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12-640x324.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083034/Screenshot-12-768x389.png 768w" sizes="(max-width: 1581px) 100vw, 1581px" /></p>
<p>The application gives you various types of templates that can be easily customized according to your preference and necessities. Shopify enables you to sell both physical and digital products. You can be selling either a bracelet or an eBook, the possibilities are endless. The application consists of incredible features. Currently, Shopify is among one of the top leaders in the eCommerce industry.</p>
<h2>Shopify Feature List</h2>
<p>Shopify is considered to have the most contrived features. Nearly all that you need to do in order to manage your own online store is completely taken care of by Shopify.</p>
<h3>Admin management</h3>
<p>Admin management is the complete rundown of your online content. Here you will be able to see the customers, orders, and products of your store. You will be able also to administer the sales channels such as POS or Point of Sale Purchase, the store and other Shopify products if you want to utilize them.</p>
<h3>Dashboard Overview</h3>
<p>The dashboard demonstrates important sales of your store along with the orders, and customer data. You can also see how your store is performing — over the majority of your business channels.</p>
<h3>Catalogs</h3>
<p>All the stores of Shopify consist of a catalog page where you will be able to create a collection to manage the order on how you want your products to be displayed on your page.</p>
<h3>Products</h3>
<p>Shopify consists of a product section where you will be able to edit the details of the products by color, size and other features.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/how-to-grow-your-clothing-business-9-practical-tips/" target="_self" rel="noopener" data-wpel-link="internal">How to Grow Your Clothing Business: 9 Practical Tips</a></li>
</ul>
</div>
</div>
<h2>Shopify Pros and Cons</h2>
<p><strong><img decoding="async" class="aligncenter size-full wp-image-8451" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083030/Shopify_2-1.jpg" alt="Shopify Pros and Cons" width="860" height="500" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083030/Shopify_2-1.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083030/Shopify_2-1-300x174.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083030/Shopify_2-1-640x372.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083030/Shopify_2-1-768x447.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></strong></p>
<p><strong>Shopify Pros</strong></p>
<ul>
<li><strong>Shopify is fast and reliable.</strong> It can handle any kind of sensitive information and processing payments of the orders.</li>
<li><strong>Shopify consists of a wide range of templates, and add-ons</strong> both free and paid that enables you to build both professional and yet, a creative site at the same time. It also allows you to expand the features in your site.</li>
<li><strong>24/7 Support.</strong> Shopify team is always available, and you can reach them through phone support, online live chat or email.</li>
<li><strong>Shopify products.</strong> It has own POS system to go omnichannel, Shopify payments as a substitution to the PayPal or other payment methods.</li>
</ul>
<p><strong>Shopify Cons</strong></p>
<ul>
<li><strong>Additional fees.</strong> Before you sign up on Shopify, you need to make sure that you will be able to pay the necessary fees. You need to pay the monthly fees and transaction processing fees to Shopify.</li>
<li><strong>Functionality limits.</strong> On Shopify, you cannot work with the products as you wish. There are various limits by the categories.</li>
<li><strong>Shopify is made up of unique coding language.</strong> Hence, if you need to work on the back-end of your website design, you will need expert programmers for that. This will lead to an increase in your maintenance costs which will in turn delay in running your online store.</li>
</ul>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/list-best-ecommerce-website-builders/" target="_self" rel="noopener" data-wpel-link="internal">List of the Best eCommerce Website Builders</a></li>
<li class="ufy-block__item"></li>
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/woocommerce-review-good-choice-running-store/" target="_self" rel="noopener" data-wpel-link="internal">Woocommerce Review: is it a good choice for running the store?</a></li>
</ul>
</div>
</div>
<h2>Ease of Use</h2>
<p>Nowadays, most online stores promote easy and simple features, but only very few of them actually are. Anyone can open an account on Shopify and launch their online store within a few minutes.</p>
<h3>Shopify Server Requirements</h3>
<p>Shopify is completely Cloud-based and hosted application. This means that you do not need to stress about updating or maintaining the application and web servers. This provides you with enough flexibility to manage your online store from any corner of the world using the mobile app that you can download from the app store. All you need is a smart device with good internet speed.</p>
<h3>Shopify Pricing</h3>
<p>There are five Shopify pricing plans which include:</p>
<ul>
<li><strong>Shopify Lite:</strong> At $9 per month, you can sell as many products as you want but you will not have a functional online store.</li>
<li><strong>Basic Shopify:</strong> This plan gives you a serviceable online store with two staff accounts &#8211; all for just $29 per month.</li>
<li><strong>Shopify:</strong> This option costs a monthly charge of $79, but it allows you a reporting feature and gives gift cards too.</li>
<li><strong>Advanced Shopify:</strong> With 15 staff accounts and a great progressive reporting feature, this plan costs $299.</li>
<li><strong>Shopify Plus:</strong> This premium plan costs a whopping $2000 monthly, but there’s some room for discussions. With heavy security, API and more, the Shopify Plus is for large businesses that require advanced features and functionalities where some customization is possible.</li>
</ul>
<h3>Shopify Templates</h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8436" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9.png" alt="Shopify Templates" width="1600" height="766" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9-300x144.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9-1024x490.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9-640x306.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-9-768x368.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Shopify provides more than a hundred aesthetic and amazing template designs. Hence, you can be certain that you will be able to find a template that suits your style and the brand identity of your online store.</p>
<p>The basic <strong>$9 per month plan</strong> offers you with<strong> 10 free template designs</strong>. The template designs can be embedded to your Youtube page, if you have any, to display your story.</p>
<p>Along with that, the Shopify template designs also consists of a header slideshow in order to feature various products of your online store. Shopify website templates have an incredible product framework system that can be changed according to the number of products that are being displayed.</p>
<p>Also, they are fully customizable which means that you can get a unique theme for your store and attract customers with modern design and easy-to-browse sections.</p>
<h3>Shopify Plugins and Extensions</h3>
<p>Shopify provides you with a wide range of plugins and extensions in order to expand your online business. These plugins help you to receive more visitors and help you stand out among the crowd.</p>
<h3>Shopify Marketing and SEO</h3>
<p>In this era of the Internet and Technology, one of the best ways to increase traffic to your website is blogging. Luckily, Shopify consists of a <strong>built-in blogging</strong> feature that enables you to create different types of content to increase traffic. The blogging feature of Shopify is quite different from WordPress, but it enables you to use tags.</p>
<p>The SEO tool for Shopify is very easy to use. You can <strong>change the tiles</strong> of the page, add <strong>headings</strong> and provide<strong> meta descriptions.</strong></p>
<h3>Shopify Payment Processing</h3>
<p>Shopify has its own payment system which is completely incorporated with your online store and you do not need to rely on any third-party account.</p>
<p><strong>Shopify Payments</strong> enables you to manage your online store and the payments in one place.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-8437" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-13.png" alt="Shopify Payments" width="374" height="667" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-13.png 374w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083033/Screenshot-13-168x300.png 168w" sizes="(max-width: 374px) 100vw, 374px" /></p>
<p>Shopify has more than 100 payment gateways available. Along with that, Shopify enables you to accept credit cards and you can also set up a Bitcoin payment system. Besides, there are additional payment processing methods which include cash on delivery and bank transfer among others.</p>
<p>Shopify also integrates with PayPal, hence once you open an online store, you can easily sign up for a Paypal Express Checkout account at the click of a button.</p>
<h3>Shopify Security</h3>
<p>Shopify is devoted to providing a secure shopping experience for both you and your clients. It has been certified<strong> Level 1 PCI DSS compliant</strong>. Subsequently, all the online stores of Shopify are consequently PCI compliant, which guarantees that your clients have a sense of security when shopping from your website and ensures that your online business is authentic and safe.</p>
<p>You will need to follow certain regulations while running your online store on Shopify, which includes:</p>
<ul>
<li>Site and server vulnerability checks by Approved Scanning Vendors (ASVs)</li>
<li>Security audits of the company</li>
<li>Self-assessment questionnaires (SAQs)</li>
</ul>
<h3>Shopify Customer Service</h3>
<p>Shopify provides excellent customer service to its users. The web application is accessible through the majority of channels. Shopify customer service is available 24/7 by email, mobile, phone and, live chat. There are also separate contact numbers for customers who reside in North America, Australia, UK, and New Zealand.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-8452" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083029/Shopify_1-1.jpg" alt="What Customers Say About Shopify?" width="860" height="600" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083029/Shopify_1-1.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083029/Shopify_1-1-300x209.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083029/Shopify_1-1-640x447.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/05/07083029/Shopify_1-1-768x536.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Another Story About the Broken Shopping Cart in Magento 2</title>
		<link>https://web4pro.net/blog-news/story-broken-shopping-cart-magento2/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 23 Apr 2019 10:28:29 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8343</guid>

					<description><![CDATA[Read one more case on how to deal with broken cart in Magento 2.]]></description>
										<content:encoded><![CDATA[
<p>We&#8217;ve already investigated the broken cart bug in cases when administrators delete simple child products. But, as it turns out, there can be other reasons for this bug.</p>



<p>Magento 2 has a very convenient feature for store administrators: they can change product type as they wish. When creating a product, an administrator can set the product weight, resulting in the product having the type &#8220;simple.&#8221; They can also not set the weight, resulting in a &#8220;virtual&#8221; product. Moreover, when administrators remove the weight from an existing &#8220;simple&#8221; product and save it, they get a &#8220;virtual&#8221; product and vice versa. They can also take any simple product that isn&#8217;t part of a configurable one and make it configurable on the product editing page, using the configuration component.</p>



<p>We will elaborate on this last scenario since in the hands of inexperienced users it could create issues for store users. This article will be about how to use this feature properly.</p>



<h2 class="wp-block-heading">Chapter 1: Background</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="860" height="400" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083053/1.jpg" alt="Chapter 1. Story Background " class="wp-image-8355" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083053/1.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083053/1-300x140.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083053/1-640x298.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083053/1-768x357.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></figure></div>


<p>Let&#8217;s say there&#8217;s a Magento 2 store with the following cast of characters:</p>



<ul class="wp-block-list">
<li><strong>the developer</strong> who made a site based on functional specifications and provides support for it.</li>



<li><strong>the store administrator</strong> who creates products, process orders, etc.</li>



<li><strong>the customer</strong> who is buying something in the store.</li>
</ul>



<p>This store sells clothing and hats since these are products that usually require configuration.</p>



<p>The administrator created a simple product and made it available for purchase: a cap with a white pattern on a black background (CAP1).</p>



<h2 class="wp-block-heading">Chapter 2: Product Changes</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="860" height="910" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/21.jpg" alt="Chapter 2: Product Changes" class="wp-image-8360" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/21.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/21-284x300.jpg 284w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/21-640x677.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/21-768x813.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></figure></div>


<p>The customer goes to the store and adds this product to their cart, but for some reason, they don&#8217;t make a purchase and the product stays in the cart. The customer doesn’t return to the site again for some time. Then, the same exact cap appeared in the store&#8217;s inventory, but with a black pattern on a white background.</p>



<p>The administrator decided to turn the existing product, CAP1, into a configurable product with a color attribute. This is easy to do on the product editing page. In this instance, the product becomes configurable after saving, and two simple child products are automatically created.</p>



<p>This couldn&#8217;t be done in Magento 1 since product type could only be set when creating a product. You had to create a new configurable product and link the child simple products to it. The new product would have a new URL, and that would start age-old SEO problems.</p>



<h2 class="wp-block-heading">Chapter 3: Error</h2>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="860" height="440" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/3-1.jpg" alt="Chapter 3: Error" class="wp-image-8364" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/3-1.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/3-1-300x153.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/3-1-640x327.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/04/07083051/3-1-768x393.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></figure></div>


<p>So, the administrator turned the simple product into a configurable one, and a drop-down list with color choices (or visual swatches) appeared on the product page on the front end. Now the customer decides to log in again and complete the purchase, but when they go to their cart, they get a 503 error.</p>



<p>The customer can&#8217;t proceed to checkout to complete the order, so they go to the Contact Us page and write a complaint to the manager. The manager then creates a bug report for the developer. The developer looks at the server logs and sees the following error:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[Tue Mar 05 19:20:54.026160 2019] [php7:error] [pid 8691] [client 127.0.0.1:58142] PHP Fatal error:  Uncaught Error: Call to a member function getValue() on null in /var/www/magento23/vendor/magento/module-configurable-product/Model/Quote/Item/CartItemProcessor.php:86\nStack trace:\n#0 /var/www/magento23/generated/code/Magento/ConfigurableProduct/Model/Quote/Item/CartItemProcessor/Proxy.php(103): Magento\\ConfigurableProduct\\Model\\Quote\\Item\\CartItemProcessor-&gt;processOptions(Object(Magento\\Quote\\Model\\Quote\\Item))\n#1 /var/www/magento23/vendor/magento/module-quote/Model/Quote/Item/CartItemOptionsProcessor.php(84): Magento\\ConfigurableProduct\\Model\\Quote\\Item\\CartItemProcessor\\Proxy-&gt;processOptions(Object(Magento\\Quote\\Model\\Quote\\Item))\n#2 /var/www/magento23/vendor/magento/module-quote/Model/Quote/Item/Repository.php(74): Magento\\Quote\\Model\\Quote\\Item\\CartItemOptionsProcessor-&gt;addProductOptions('configurable', Object(Magento\\Quote\\Model\\Quote\\Item))\n#3 /var/www/magento23/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(430): Magento\\Quote\\Model\\Quote\\Item\\Repository-&gt;getList('1')\n#4 /var/www/magen in /var/www/magento23/vendor/magento/module-configurable-product/Model/Quote/Item/CartItemProcessor.php on line 86, referer: http://magento23.loc/index.php/" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">[Tue Mar </span><span style="color: #AE81FF">05</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">19</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">20</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">54</span><span style="color: #F8F8F2">.</span><span style="color: #AE81FF">026160</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">2019</span><span style="color: #F8F8F2">] [</span><span style="color: #E6DB74">php7:error</span><span style="color: #F8F8F2">] [pid </span><span style="color: #AE81FF">8691</span><span style="color: #F8F8F2">] [</span><span style="color: #E6DB74">client 127.0.0.1:58142</span><span style="color: #F8F8F2">] PHP Fatal error:  Uncaught Error: Call to a member function getValue() on null in /var/www/magento23/vendor/magento/module-configurable-product/Model/Quote/Item/CartItemProcessor.php:</span><span style="color: #AE81FF">86</span><span style="color: #F8F8F2">\nStack trace:\n#</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2"> /var/www/magento23/generated/code/Magento/ConfigurableProduct/Model/Quote/Item/CartItemProcessor/Proxy.php(</span><span style="color: #AE81FF">103</span><span style="color: #F8F8F2">): Magento\\ConfigurableProduct\\Model\\Quote\\Item\\CartItemProcessor-&gt;processOptions(Object(Magento\\Quote\\Model\\Quote\\Item))\n#</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> /var/www/magento23/vendor/magento/module-quote/Model/Quote/Item/CartItemOptionsProcessor.php(</span><span style="color: #AE81FF">84</span><span style="color: #F8F8F2">): Magento\\ConfigurableProduct\\Model\\Quote\\Item\\CartItemProcessor\\Proxy-&gt;processOptions(Object(Magento\\Quote\\Model\\Quote\\Item))\n#</span><span style="color: #AE81FF">2</span><span style="color: #F8F8F2"> /var/www/magento23/vendor/magento/module-quote/Model/Quote/Item/Repository.php(</span><span style="color: #AE81FF">74</span><span style="color: #F8F8F2">): Magento\\Quote\\Model\\Quote\\Item\\CartItemOptionsProcessor-&gt;addProductOptions(&#39;configurable&#39;, Object(Magento\\Quote\\Model\\Quote\\Item))\n#</span><span style="color: #AE81FF">3</span><span style="color: #F8F8F2"> /var/www/magento23/vendor/magento/module-checkout/Model/DefaultConfigProvider.php(</span><span style="color: #AE81FF">430</span><span style="color: #F8F8F2">): Magento\\Quote\\Model\\Quote\\Item\\Repository-&gt;getList(&#39;</span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">&#39;)\n#</span><span style="color: #AE81FF">4</span><span style="color: #F8F8F2"> /var/www/magen in /var/www/magento23/vendor/magento/module-configurable-product/Model/Quote/Item/CartItemProcessor.php on line </span><span style="color: #AE81FF">86</span><span style="color: #F8F8F2">, referer: http://magento23.loc/index.php/</span></span></code></pre></div>



<p>This is the error for Magento version 2.3. Earlier versions will show a slightly different error, but the essence is the same. The error occurs because when automatically converting the product type, the product type in the cart changed, too.</p>



<p>The configurable product in the cart should have a child element, as well as configuration options—but it doesn&#8217;t since the product wasn&#8217;t configurable when it was added to the cart. The error appears in the processOptions method when attempting to receive the value of the &#8216;attributes&#8217; option, which for the reason mentioned above does not exist. The method code is below.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function processOptions(CartItemInterface $cartItem)
{
    $attributesOption = $cartItem-&gt;getProduct()-&gt;getCustomOption('attributes');
    $selectedConfigurableOptions = $this-&gt;serializer-&gt;unserialize($attributesOption-&gt;getValue());
    if (is_array($selectedConfigurableOptions)) {
        $configurableOptions = [];
        foreach ($selectedConfigurableOptions as $optionId =&gt; $optionValue) {
            /** @var \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface $option */
            $option = $this-&gt;itemOptionValueFactory-&gt;create();
            $option-&gt;setOptionId($optionId);
            $option-&gt;setOptionValue($optionValue);
            $configurableOptions[] = $option;
        }
        $productOption = $cartItem-&gt;getProductOption()
            ? $cartItem-&gt;getProductOption()
            : $this-&gt;productOptionFactory-&gt;create();
        /** @var  \Magento\Quote\Api\Data\ProductOptionExtensionInterface $extensibleAttribute */
        $extensibleAttribute =  $productOption-&gt;getExtensionAttributes()
            ? $productOption-&gt;getExtensionAttributes()
            : $this-&gt;extensionFactory-&gt;create();
        $extensibleAttribute-&gt;setConfigurableItemOptions($configurableOptions);
        $productOption-&gt;setExtensionAttributes($extensibleAttribute);
        $cartItem-&gt;setProductOption($productOption);
    }
    return $cartItem;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">processOptions</span><span style="color: #F8F8F2">(</span><span style="color: #66D9EF; font-style: italic">CartItemInterface</span><span style="color: #F8F8F2"> $cartItem)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    $attributesOption </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $cartItem</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getProduct</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getCustomOption</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;attributes&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    $selectedConfigurableOptions </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">serializer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">unserialize</span><span style="color: #F8F8F2">($attributesOption</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getValue</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_array</span><span style="color: #F8F8F2">($selectedConfigurableOptions)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $configurableOptions </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2"> ($selectedConfigurableOptions </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $optionId </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $optionValue) {</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F"> \Magento\ConfigurableProduct\Api\Data\</span><span style="color: #66D9EF; font-style: italic">ConfigurableItemOptionValueInterface</span><span style="color: #88846F"> $option */</span></span>
<span class="line"><span style="color: #F8F8F2">            $option </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">itemOptionValueFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">            $option</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setOptionId</span><span style="color: #F8F8F2">($optionId);</span></span>
<span class="line"><span style="color: #F8F8F2">            $option</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setOptionValue</span><span style="color: #F8F8F2">($optionValue);</span></span>
<span class="line"><span style="color: #F8F8F2">            $configurableOptions[] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $option;</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">        $productOption </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $cartItem</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getProductOption</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">?</span><span style="color: #F8F8F2"> $cartItem</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getProductOption</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">:</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">productOptionFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #88846F">/** </span><span style="color: #F92672">@var</span><span style="color: #88846F">  \Magento\Quote\Api\Data\</span><span style="color: #66D9EF; font-style: italic">ProductOptionExtensionInterface</span><span style="color: #88846F"> $extensibleAttribute */</span></span>
<span class="line"><span style="color: #F8F8F2">        $extensibleAttribute </span><span style="color: #F92672">=</span><span style="color: #F8F8F2">  $productOption</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getExtensionAttributes</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">?</span><span style="color: #F8F8F2"> $productOption</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getExtensionAttributes</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">:</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">extensionFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        $extensibleAttribute</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setConfigurableItemOptions</span><span style="color: #F8F8F2">($configurableOptions);</span></span>
<span class="line"><span style="color: #F8F8F2">        $productOption</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setExtensionAttributes</span><span style="color: #F8F8F2">($extensibleAttribute);</span></span>
<span class="line"><span style="color: #F8F8F2">        $cartItem</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setProductOption</span><span style="color: #F8F8F2">($productOption);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $cartItem;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<div class="ufy-block">
  <div class="ufy-block__wrapper">
    <p class="ufy-block__label">Useful for you:</p>
    <ul class="ufy-block__list">
      <li class="ufy-block__item"><a href="https://web4pro.net/blog-news/broken-magento-shopping-cart-cause-and-solution/" target="_self" rel="noopener" data-wpel-link="internal">Broken Magento Shopping Cart: Cause and Solution</a></li>
    </ul>
  </div>
</div>



<h2 class="wp-block-heading">Chapter 4: Solution for Broken Cart Using Product Aftersave Event Observer</h2>



<p>The developer thought about the situation and decided that the user&#8217;s cart shouldn&#8217;t be broken, regardless of what the store administrator did. The developer implemented the following solution: they added a product aftersave event observer to the broken cart module.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Event/etc/events.xsd&quot;&gt;
    &lt;event name=&quot;catalog_product_save_after&quot;&gt;
        &lt;observer name=&quot;fix-customer-cart&quot; instance=&quot;Web4pro\BrokenCart\Model\Observer&quot; shared=&quot;false&quot; /&gt;
    &lt;/event&gt;
&lt;/config&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">&lt;?</span><span style="color: #F92672">xml</span><span style="color: #A6E22E"> version</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;1.0&quot;</span><span style="color: #F8F8F2">?&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #F92672">config</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">xmlns:xsi</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">xsi:noNamespaceSchemaLocation</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;urn:magento:framework:Event/etc/events.xsd&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #F92672">event</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;catalog_product_save_after&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #F92672">observer</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">name</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;fix-customer-cart&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">instance</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;Web4pro\BrokenCart\Model\Observer&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">shared</span><span style="color: #F8F8F2">=</span><span style="color: #E6DB74">&quot;false&quot;</span><span style="color: #F8F8F2"> /&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;/</span><span style="color: #F92672">event</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #F92672">config</span><span style="color: #F8F8F2">&gt;</span></span></code></pre></div>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="class Observer implements  \Magento\Framework\Event\ObserverInterface
{
    protected $cartCleaner;
    public function __construct(\Web4pro\BrokenCart\Model\QuoteItemsCleaner $cartCleaner)
    {
        $this-&gt;cartCleaner = $cartCleaner;
    }
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        if($product = $observer-&gt;getEvent()-&gt;getProduct()){
            if(($product-&gt;getTypeId()=='configurable')&amp;&amp;($product-&gt;getOrigData('type_id')!='configurable')){
                $this-&gt;cartCleaner-&gt;execute($product);
            }
        }
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">Observer</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">implements</span><span style="color: #F8F8F2">  \Magento\Framework\Event\</span><span style="color: #A6E22E; font-style: italic; text-decoration: underline">ObserverInterface</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> $cartCleaner;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF">__construct</span><span style="color: #F8F8F2">(\Web4pro\BrokenCart\Model\</span><span style="color: #66D9EF; font-style: italic">QuoteItemsCleaner</span><span style="color: #F8F8F2"> $cartCleaner)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">cartCleaner </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $cartCleaner;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">execute</span><span style="color: #F8F8F2">(\Magento\Framework\Event\</span><span style="color: #66D9EF; font-style: italic">Observer</span><span style="color: #F8F8F2"> $observer)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2">($product </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $observer</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getEvent</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getProduct</span><span style="color: #F8F8F2">()){</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">if</span><span style="color: #F8F8F2">(($product</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTypeId</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">==</span><span style="color: #E6DB74">&#39;configurable&#39;</span><span style="color: #F8F8F2">)</span><span style="color: #F92672">&amp;&amp;</span><span style="color: #F8F8F2">($product</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getOrigData</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;type_id&#39;</span><span style="color: #F8F8F2">)</span><span style="color: #F92672">!=</span><span style="color: #E6DB74">&#39;configurable&#39;</span><span style="color: #F8F8F2">)){</span></span>
<span class="line"><span style="color: #F8F8F2">                </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">cartCleaner</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">execute</span><span style="color: #F8F8F2">($product);</span></span>
<span class="line"><span style="color: #F8F8F2">            }</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>If a configurable product&#8217;s type becomes configurable when it&#8217;s saved, the product should be removed from all users&#8217; carts. Indeed, after its type was changed, the product in the example is no longer the same cap with a white pattern on a black background that the customer added to their cart.</p>



<p>eCommerce rules dictate that the product should be deleted from the user&#8217;s cart. Now the store administrator can change the product type at will, without it resulting in the problem described above.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Debugging Magento 2 Using Logs</title>
		<link>https://web4pro.net/blog-news/debugging-magento-2-using-logs/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Tue, 12 Mar 2019 12:22:13 +0000</pubDate>
				<category><![CDATA[Code for Magento]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8234</guid>

					<description><![CDATA[Check how to work with Magento issues using log files.]]></description>
										<content:encoded><![CDATA[
<p>When working with Magento 2, sections of code are often processed unexpectedly. When this happens, developers need to understand the reason for the error and fix it.</p>



<p>Log files are convenient for debugging. In most cases, they help you quickly determine the cause of the error and fix it. In this article, we will examine the types of log files and the specifics of working with them.</p>



<h2 class="wp-block-heading">Using Logs: Magento 2 Live Site Example</h2>



<p>Let&#8217;s assume we&#8217;re working with a site on Magento 2 that is in production mode (the main &#8220;live&#8221; mode of Magento 2 sites) and is running on a UNIX-like OS.</p>



<h3 class="wp-block-heading">Types of Logs</h3>



<p>There are two types of logs available to developers: information logs and error logs. An information log can hold information a developer needs for debugging, while error logs hold information about runtime errors. The main information log is saved in your Magento 2 directory: var/log/system.log.</p>



<h3 class="wp-block-heading">Types of Errors</h3>



<p>There are three types of errors:</p>



<ul class="wp-block-list">
<li>handled exceptions,</li>



<li>non-handled exceptions, and</li>



<li>fatal runtime errors.</li>
</ul>



<p>We will consider each of these error types.</p>



<p>Magento 2 has a Psr logging library that implements embedded logging. To log something, you simply have to call the interface Psr\Log\LoggerInterface, which will be implemented using dependency injection of the class <strong>Magento\Framework\Logger\Monolog</strong> (the dependency is defined in the global app/etc/di.xml).</p>



<p>The interface declares several logging methods, and the class implements them. These methods differ only in terms of the additional information about critical messages shown in the log. The models inherited from AbstractModel, block collections, and helpers have a protected _logger property that can be used for logging. For all remaining classes, you can log using dependency injection in the constructor or using ObjectManager. In the examples below, we will assume that the class has _logger property.</p>



<h3 class="wp-block-heading">The Principles of Magento Logging</h3>



<p>Logging is simple. You just need to call $this-&gt;_logger-&gt;info(param), where param is some scalar variable that will be logged in the file var/log/system.log.</p>



<p>Calling the error or critical methods will write a scalar variable to this same file. If you pass an object of the class inherited from \Exception as a parameter, then the error will be logged in the file var/log/exception.log. In versions 2.0 and 2.1, the exception&#8217;s full trace was recorded to this file, making it possible to easily determine the location of the error and a way to fix it. But starting in version 2.2, only the exception message and the place where it was thrown are recorded.</p>



<p>To get the trace, you need to write $this-&gt;_logger-&gt;critical($e-&gt;_toString());, but the error and trace will be recorded in the file var/log/system.log. Nevertheless, this is convenient when you need to determine the full path to the location where the error occurred and also determine the current values of various parameters in order to understand the reason for the error. Exceptions can only be logged in the catch block of the construct.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="try{
..}
catch(\Exception $e){
 $this-&gt;_logger-&gt;critical($e-&gt;__toString());
..}." style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">try</span><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F92672">..</span><span style="color: #F8F8F2">}</span></span>
<span class="line"><span style="color: #F92672">catch</span><span style="color: #F8F8F2">(\</span><span style="color: #66D9EF; font-style: italic">Exception</span><span style="color: #F8F8F2"> $e){</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_logger</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">critical</span><span style="color: #F8F8F2">($e</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">__toString</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F92672">..</span><span style="color: #F8F8F2">}</span><span style="color: #F92672">.</span></span></code></pre></div>



<p>If the developer didn&#8217;t use exception handling, then sometimes this handling is already implemented at the core level, in particular when outputting blocks.</p>



<p>When an exception occurs when a block&#8217;s content is generated, the block will not be displayed, and a message about the error will be displayed in the file var/log/exception.log. Otherwise, if the exception is intercepted by a top-level handler, the server will return an error and the exception will be logged in a separate file in the directory var/report. If the error occurred when processing an API request, the error will be logged in a separate file in the directory var/report/api.</p>



<p>The cases above considered errors that Magento could process. But if a fatal error occurs when executing code, Magento will not be able to process it, and the error will go to the Web server log. Next, we will look at examples of fatal errors, where they appear, and why they appear.</p>



<h2 class="wp-block-heading">Fatal Errors and the Reasons Behind Them</h2>



<p>By default, these files are located in the server&#8217;s /var/log directory, with the rest of the path determined by the type of server (Apache, NGINX, PHP-FPM) and configuration features. On live servers (and others) developers often do not have the data in these directories for security reasons, or the server administrator may redirect logging of fatal errors to other files, which will be available. This is often done if several virtual hosts are implemented on one physical server and access to the hosts is limited to certain users.</p>



<p>Sometimes this log is available in Cpanel, if it is supported by the hosting. Since these errors are fatal, the HTTP request will return a 50x error. These types of errors can occur at the PHP level; they can be caused by insufficient memory allotted to runtime or insufficient disk space; and they can also occur at the Apache or NGINX level. One common error of this kind at the NGINX level is be caused by a connection timeout or buffer overflow, which can only be resolved by changing NGINX settings.</p>



<p>There are often redirect errors at the server level as well, which return 404 server errors. There are other types of 40x errors as well, such as transferring more to POST than the server can handle, but that&#8217;s a separate topic.</p>



<p><strong>Let&#8217;s summarize what we&#8217;ve gone over so far.</strong></p>



<ol class="wp-block-list">
<li>If the executed code isn&#8217;t working as expected, you should first check the Magento logs. More often than not, it&#8217;s easy to establish the reason for the error from these logs.</li>



<li>If requests to the server return 40x or 50x errors, you should check the var/report directory and the Web server log, if possible.</li>



<li>When debugging code, log critical variables and check their values.</li>



<li>If existing core code isn&#8217;t writing all the necessary information to the log (this usually has to do with error handling) then when you are debugging and finding out the reason for the error, you can temporarily add logging. Don&#8217;t forget to roll back changes to the core, returning it to its original state after debugging.</li>



<li>In some cases, logs are the only available means of debugging. For example, cron jobs, API requests, and payment methods can usually only be debugged using logs.</li>



<li>Keep in mind that logs have the tendency to grow, so don&#8217;t forget to periodically delete old Magento log files. The automatic deletion of global logs after a certain period of time is usually configured on servers.</li>



<li>Don&#8217;t forget to remove logging of safety-critical information from the code after debugging. This usually pertains to credit card information, but it could be other information as well.</li>
</ol>



<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/magento-2-issues-detected-and-solved/" target="_self" rel="noopener" data-wpel-link="internal">Magento 2 Issues: Detected and Solved</a></li>
</ul>
</div>
</div>



<h2 class="wp-block-heading">Real Examples of Using Logs for Debugging</h2>



<p><strong>1. Optimizing a site that has seen a sharp increase in front-end page load speeds after upgrading to version 2.3.</strong></p>



<p>This may be caused by conflicts between obsolete site modules and the new core version of Magento. There is speculation that the problem may be related to the generation of a menu in a custom extension. The menu displays categories and uses flat tables. When researching, you were able to establish that category information is received in the _loadNodes method of the \Magento\Catalog\Model\ResourceModel\Category\Flat class.</p>



<div class="wp-block-pb-accordion-item c-accordion__item js-accordion-item no-js" data-initially-open="false" data-click-to-close="true" data-auto-close="false" data-scroll="false" data-scroll-offset="0"><h4 id="at-82340" class="c-accordion__title js-accordion-controller" role="button">The method looks as follows:</h4><div id="ac-82340" class="c-accordion__content">
<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="protected function _loadNodes($parentNode = null, $recursionLevel = 0, $storeId = 0, $skipMenuFilter = false)
{
    $_conn = $this-&gt;getConnection();
    $startLevel = 1;
    $parentPath = '';
    if ($parentNode instanceof \Magento\Catalog\Model\Category) {
        $parentPath = $parentNode-&gt;getPath();
        $startLevel = $parentNode-&gt;getLevel();
    } elseif (is_numeric($parentNode)) {
        $selectParent = $_conn-&gt;select()-&gt;from(
            $this-&gt;getMainStoreTable($storeId)
        )-&gt;where(
            'entity_id = ?',
            $parentNode
        )-&gt;where(
            'store_id = ?',
            $storeId
        );
        $parentNode = $_conn-&gt;fetchRow($selectParent);
        if ($parentNode) {
            $parentPath = $parentNode['path'];
            $startLevel = $parentNode['level'];
        }
    }
    $select = $_conn-&gt;select()-&gt;from(
        ['main_table' =&gt; $this-&gt;getMainStoreTable($storeId)],
        [
            'entity_id',
            new \Zend_Db_Expr('main_table.' . $_conn-&gt;quoteIdentifier('name')),
            new \Zend_Db_Expr('main_table.' . $_conn-&gt;quoteIdentifier('path')),
            'is_active',
            'is_anchor'
        ]
    )-&gt;joinLeft(
        ['url_rewrite' =&gt; $this-&gt;getTable('url_rewrite')],
        'url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1'
        . $_conn-&gt;quoteInto(' AND url_rewrite.store_id = ?', $storeId)
        . $_conn-&gt;quoteInto(' AND url_rewrite.entity_type = ?', CategoryUrlRewriteGenerator::ENTITY_TYPE),
        ['request_path' =&gt; 'url_rewrite.request_path']
    )-&gt;where('main_table.is_active = 1');
    if (false == $skipMenuFilter) {
        $select-&gt;where('main_table.include_in_menu = ?', '1');
    }
    $select-&gt;order('main_table.position');
    if ($parentPath) {
        $select-&gt;where($_conn-&gt;quoteInto(&quot;main_table.path like ?&quot;, &quot;{$parentPath}/%&quot;));
    }
    if ($recursionLevel != 0) {
        $levelField = $_conn-&gt;quoteIdentifier('level');
        $select-&gt;where($levelField . ' &lt;= ?', $startLevel   $recursionLevel);
    }
    $inactiveCategories = $this-&gt;getInactiveCategoryIds();
    if (!empty($inactiveCategories)) {
        $select-&gt;where('main_table.entity_id NOT IN (?)', $inactiveCategories);
    }
    // Allow extensions to modify select (e.g. add custom category attributes to select)
    $this-&gt;_eventManager-&gt;dispatch('catalog_category_flat_loadnodes_before', ['select' =&gt; $select]);
    $arrNodes = $_conn-&gt;fetchAll($select);
    $nodes = [];
    foreach ($arrNodes as $node) {
        $node['id'] = $node['entity_id'];
        $nodes[$node['id']] = $this-&gt;_categoryFactory-&gt;create()-&gt;setData($node);
    }
    return $nodes;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">_loadNodes</span><span style="color: #F8F8F2">($parentNode </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, $recursionLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $storeId </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $skipMenuFilter </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    $_conn </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getConnection</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentNode </span><span style="color: #F92672">instanceof</span><span style="color: #F8F8F2"> \Magento\Catalog\Model\</span><span style="color: #66D9EF; font-style: italic">Category</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getPath</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getLevel</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    } </span><span style="color: #F92672">elseif</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_numeric</span><span style="color: #F8F8F2">($parentNode)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $selectParent </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">select</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">from</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMainStoreTable</span><span style="color: #F8F8F2">($storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">        )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;entity_id = ?&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            $parentNode</span></span>
<span class="line"><span style="color: #F8F8F2">        )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;store_id = ?&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            $storeId</span></span>
<span class="line"><span style="color: #F8F8F2">        );</span></span>
<span class="line"><span style="color: #F8F8F2">        $parentNode </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">fetchRow</span><span style="color: #F8F8F2">($selectParent);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentNode) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode[</span><span style="color: #E6DB74">&#39;path&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">            $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode[</span><span style="color: #E6DB74">&#39;level&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $select </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">select</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">from</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;main_table&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMainStoreTable</span><span style="color: #F8F8F2">($storeId)],</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;entity_id&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Db_Expr</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;name&#39;</span><span style="color: #F8F8F2">)),</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Db_Expr</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;path&#39;</span><span style="color: #F8F8F2">)),</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;is_active&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;is_anchor&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">        ]</span></span>
<span class="line"><span style="color: #F8F8F2">    )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">joinLeft</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;url_rewrite&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;url_rewrite&#39;</span><span style="color: #F8F8F2">)],</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #E6DB74">&#39;url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39; </span><span style="color: #F92672">AND</span><span style="color: #E6DB74"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #E6DB74">.</span><span style="color: #AE81FF">store_id</span><span style="color: #E6DB74"> </span><span style="color: #F92672">=</span><span style="color: #E6DB74"> ?&#39;</span><span style="color: #F8F8F2">, $storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39; </span><span style="color: #F92672">AND</span><span style="color: #E6DB74"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #E6DB74">.</span><span style="color: #AE81FF">entity_type</span><span style="color: #E6DB74"> </span><span style="color: #F92672">=</span><span style="color: #E6DB74"> ?&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">CategoryUrlRewriteGenerator</span><span style="color: #F92672">::</span><span style="color: #AE81FF">ENTITY_TYPE</span><span style="color: #F8F8F2">),</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;request_path&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;url_rewrite.request_path&#39;</span><span style="color: #F8F8F2">]</span></span>
<span class="line"><span style="color: #F8F8F2">    )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.is_active = 1&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">==</span><span style="color: #F8F8F2"> $skipMenuFilter) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.include_in_menu = ?&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">&#39;1&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">order</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.position&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentPath) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">($_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&quot;main_table.path like ?&quot;</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">&quot;{</span><span style="color: #F8F8F2">$parentPath</span><span style="color: #E6DB74">}/%&quot;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($recursionLevel </span><span style="color: #F92672">!=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $levelField </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;level&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">($levelField </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39; &lt;= ?&#39;</span><span style="color: #F8F8F2">, $startLevel   $recursionLevel);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $inactiveCategories </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getInactiveCategoryIds</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">empty</span><span style="color: #F8F8F2">($inactiveCategories)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.entity_id NOT IN (?)&#39;</span><span style="color: #F8F8F2">, $inactiveCategories);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">// Allow extensions to modify select (e.g. add custom category attributes to select)</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_eventManager</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">dispatch</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;catalog_category_flat_loadnodes_before&#39;</span><span style="color: #F8F8F2">, [</span><span style="color: #E6DB74">&#39;select&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $select]);</span></span>
<span class="line"><span style="color: #F8F8F2">    $arrNodes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">fetchAll</span><span style="color: #F8F8F2">($select);</span></span>
<span class="line"><span style="color: #F8F8F2">    $nodes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2"> ($arrNodes </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $node) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $node[</span><span style="color: #E6DB74">&#39;id&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $node[</span><span style="color: #E6DB74">&#39;entity_id&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">        $nodes[$node[</span><span style="color: #E6DB74">&#39;id&#39;</span><span style="color: #F8F8F2">]] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_categoryFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setData</span><span style="color: #F8F8F2">($node);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $nodes;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>Since we need to get the request for debugging and optimization, we can modify this method:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="protected function _loadNodes($parentNode = null, $recursionLevel = 0, $storeId = 0, $skipMenuFilter = false)
{
    $_conn = $this-&gt;getConnection();
    $startLevel = 1;
    $parentPath = '';
    if ($parentNode instanceof \Magento\Catalog\Model\Category) {
        $parentPath = $parentNode-&gt;getPath();
        $startLevel = $parentNode-&gt;getLevel();
    } elseif (is_numeric($parentNode)) {
        $selectParent = $_conn-&gt;select()-&gt;from(
            $this-&gt;getMainStoreTable($storeId)
        )-&gt;where(
            'entity_id = ?',
            $parentNode
        )-&gt;where(
            'store_id = ?',
            $storeId
        );
        $parentNode = $_conn-&gt;fetchRow($selectParent);
        if ($parentNode) {
            $parentPath = $parentNode['path'];
            $startLevel = $parentNode['level'];
        }
    }
    $select = $_conn-&gt;select()-&gt;from(
        ['main_table' =&gt; $this-&gt;getMainStoreTable($storeId)],
        [
            'entity_id',
            new \Zend_Db_Expr('main_table.' . $_conn-&gt;quoteIdentifier('name')),
            new \Zend_Db_Expr('main_table.' . $_conn-&gt;quoteIdentifier('path')),
            'is_active',
            'is_anchor'
        ]
    )-&gt;joinLeft(
        ['url_rewrite' =&gt; $this-&gt;getTable('url_rewrite')],
        'url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1'
        . $_conn-&gt;quoteInto(' AND url_rewrite.store_id = ?', $storeId)
        . $_conn-&gt;quoteInto(' AND url_rewrite.entity_type = ?', CategoryUrlRewriteGenerator::ENTITY_TYPE),
        ['request_path' =&gt; 'url_rewrite.request_path']
    )-&gt;where('main_table.is_active = 1');
    if (false == $skipMenuFilter) {
        $select-&gt;where('main_table.include_in_menu = ?', '1');
    }
    $select-&gt;order('main_table.position');
    if ($parentPath) {
        $select-&gt;where($_conn-&gt;quoteInto(&quot;main_table.path like ?&quot;, &quot;{$parentPath}/%&quot;));
    }
    if ($recursionLevel != 0) {
        $levelField = $_conn-&gt;quoteIdentifier('level');
        $select-&gt;where($levelField . ' &lt;= ?', $startLevel   $recursionLevel);
    }
    $inactiveCategories = $this-&gt;getInactiveCategoryIds();
    if (!empty($inactiveCategories)) {
        $select-&gt;where('main_table.entity_id NOT IN (?)', $inactiveCategories);
    }
    // Allow extensions to modify select (e.g. add custom category attributes to select)
    $this-&gt;_eventManager-&gt;dispatch('catalog_category_flat_loadnodes_before', ['select' =&gt; $select]);
    $logger = \Magento\Framework\App\ObjectManager::getInstance()-&gt;get('Psr\Log\LoggerInterface');
    $logger-&gt;info($select-&gt;__toString());
    $arrNodes = $_conn-&gt;fetchAll($select);
    $nodes = [];
    foreach ($arrNodes as $node) {
        $node['id'] = $node['entity_id'];
        $nodes[$node['id']] = $this-&gt;_categoryFactory-&gt;create()-&gt;setData($node);
    }
    return $nodes;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">_loadNodes</span><span style="color: #F8F8F2">($parentNode </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">null</span><span style="color: #F8F8F2">, $recursionLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $storeId </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">, $skipMenuFilter </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    $_conn </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getConnection</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;&#39;</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentNode </span><span style="color: #F92672">instanceof</span><span style="color: #F8F8F2"> \Magento\Catalog\Model\</span><span style="color: #66D9EF; font-style: italic">Category</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getPath</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getLevel</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    } </span><span style="color: #F92672">elseif</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF">is_numeric</span><span style="color: #F8F8F2">($parentNode)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $selectParent </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">select</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">from</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMainStoreTable</span><span style="color: #F8F8F2">($storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">        )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;entity_id = ?&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            $parentNode</span></span>
<span class="line"><span style="color: #F8F8F2">        )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;store_id = ?&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            $storeId</span></span>
<span class="line"><span style="color: #F8F8F2">        );</span></span>
<span class="line"><span style="color: #F8F8F2">        $parentNode </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">fetchRow</span><span style="color: #F8F8F2">($selectParent);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentNode) {</span></span>
<span class="line"><span style="color: #F8F8F2">            $parentPath </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode[</span><span style="color: #E6DB74">&#39;path&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">            $startLevel </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $parentNode[</span><span style="color: #E6DB74">&#39;level&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $select </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">select</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">from</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;main_table&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getMainStoreTable</span><span style="color: #F8F8F2">($storeId)],</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;entity_id&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Db_Expr</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;name&#39;</span><span style="color: #F8F8F2">)),</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> \</span><span style="color: #66D9EF; font-style: italic">Zend_Db_Expr</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;path&#39;</span><span style="color: #F8F8F2">)),</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;is_active&#39;</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #E6DB74">&#39;is_anchor&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">        ]</span></span>
<span class="line"><span style="color: #F8F8F2">    )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">joinLeft</span><span style="color: #F8F8F2">(</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;url_rewrite&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTable</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;url_rewrite&#39;</span><span style="color: #F8F8F2">)],</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #E6DB74">&#39;url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1&#39;</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39; </span><span style="color: #F92672">AND</span><span style="color: #E6DB74"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #E6DB74">.</span><span style="color: #AE81FF">store_id</span><span style="color: #E6DB74"> </span><span style="color: #F92672">=</span><span style="color: #E6DB74"> ?&#39;</span><span style="color: #F8F8F2">, $storeId)</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39; </span><span style="color: #F92672">AND</span><span style="color: #E6DB74"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #E6DB74">.</span><span style="color: #AE81FF">entity_type</span><span style="color: #E6DB74"> </span><span style="color: #F92672">=</span><span style="color: #E6DB74"> ?&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #66D9EF; font-style: italic">CategoryUrlRewriteGenerator</span><span style="color: #F92672">::</span><span style="color: #AE81FF">ENTITY_TYPE</span><span style="color: #F8F8F2">),</span></span>
<span class="line"><span style="color: #F8F8F2">        [</span><span style="color: #E6DB74">&#39;request_path&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;url_rewrite.request_path&#39;</span><span style="color: #F8F8F2">]</span></span>
<span class="line"><span style="color: #F8F8F2">    )</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.is_active = 1&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">false</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">==</span><span style="color: #F8F8F2"> $skipMenuFilter) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.include_in_menu = ?&#39;</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">&#39;1&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">order</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.position&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($parentPath) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">($_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteInto</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&quot;main_table.path like ?&quot;</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">&quot;{</span><span style="color: #F8F8F2">$parentPath</span><span style="color: #E6DB74">}/%&quot;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> ($recursionLevel </span><span style="color: #F92672">!=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $levelField </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">quoteIdentifier</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;level&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">($levelField </span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39; &lt;= ?&#39;</span><span style="color: #F8F8F2">, $startLevel   $recursionLevel);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    $inactiveCategories </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getInactiveCategoryIds</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #66D9EF">empty</span><span style="color: #F8F8F2">($inactiveCategories)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">where</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;main_table.entity_id NOT IN (?)&#39;</span><span style="color: #F8F8F2">, $inactiveCategories);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #88846F">// Allow extensions to modify select (e.g. add custom category attributes to select)</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_eventManager</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">dispatch</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;catalog_category_flat_loadnodes_before&#39;</span><span style="color: #F8F8F2">, [</span><span style="color: #E6DB74">&#39;select&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> $select]);</span></span>
<span class="line"><span style="color: #F8F8F2">    $logger </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> \Magento\Framework\App\</span><span style="color: #66D9EF; font-style: italic">ObjectManager</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getInstance</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">get</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;Psr\Log\LoggerInterface&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    $logger</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">info</span><span style="color: #F8F8F2">($select</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">__toString</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">    $arrNodes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $_conn</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">fetchAll</span><span style="color: #F8F8F2">($select);</span></span>
<span class="line"><span style="color: #F8F8F2">    $nodes </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> [];</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">foreach</span><span style="color: #F8F8F2"> ($arrNodes </span><span style="color: #F92672">as</span><span style="color: #F8F8F2"> $node) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $node[</span><span style="color: #E6DB74">&#39;id&#39;</span><span style="color: #F8F8F2">] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> $node[</span><span style="color: #E6DB74">&#39;entity_id&#39;</span><span style="color: #F8F8F2">];</span></span>
<span class="line"><span style="color: #F8F8F2">        $nodes[$node[</span><span style="color: #E6DB74">&#39;id&#39;</span><span style="color: #F8F8F2">]] </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">_categoryFactory</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">create</span><span style="color: #F8F8F2">()</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setData</span><span style="color: #F8F8F2">($node);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $nodes;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>
</div></div>



<p>Then, after loading the page without the cache in the var/log/system.log file, we see the following message:</p>



<p>[2019-02-04 15:20:25] main.INFO: SELECT `main_table`.`entity_id`, main_table.`name`, main_table.`path`, `main_table`.`is_active`, `main_table`.`is_anchor`, `url_rewrite`.`request_path` FROM `catalog_category_flat_store_1` AS `main_table`<br>LEFT JOIN `url_rewrite` ON url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.store_id = &#8216;1&#8217; AND url_rewrite.entity_type = &#8216;category&#8217; WHERE (main_table.is_active = 1) AND (main_table.include_in_menu = &#8216;1&#8217;) AND (main_table.path like &#8216;1/71/%&#8217;) ORDER BY `main_table`.`position` ASC</p>



<p>We received a request in the message that we can optimize. If we need to get back-trace, we can get it as follows:</p>



<div class="wp-block-pb-accordion-item c-accordion__item js-accordion-item no-js" data-initially-open="false" data-click-to-close="true" data-auto-close="false" data-scroll="false" data-scroll-offset="0"><h4 id="at-82341" class="c-accordion__title js-accordion-controller" role="button">View code:</h4><div id="ac-82341" class="c-accordion__content">
<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[2019-02-04 17:43:29] main.ERROR: Exception: SELECT `main_table`.`entity_id`, main_table.`name`, main_table.`path`, `main_table`.`is_active`, `main_table`.`is_anchor`, `url_rewrite`.`request_path` FROM `catalog_category_flat_store_1` AS `main_table`
 LEFT JOIN `url_rewrite` ON url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.store_id = '1' AND url_rewrite.entity_type = 'category' WHERE (main_table.is_active = 1) AND (main_table.include_in_menu = '1') AND (main_table.path like '1/71/%') ORDER BY `main_table`.`position` ASC
 in /var/www/toshno/vendor/magento/module-catalog/Model/ResourceModel/Category/Flat.php:304
Stack trace:
#0 /var/www/toshno/vendor/magento/module-catalog/Model/ResourceModel/Category/Flat.php(376): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;_loadNodes(Object(Magento\Catalog\Model\Category\Interceptor), 0, '1')
#1 /var/www/toshno/vendor/magento/module-catalog/Model/ResourceModel/Category/Flat.php(433): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;getNodes('71', 0, '1')
#2 /var/www/toshno/vendor/magento/module-catalog/Model/Category.php(970): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;getCategories('71', 0, true, false, true)
#3 /var/www/toshno/generated/code/Magento/Catalog/Model/Category/Interceptor.php(466): Magento\Catalog\Model\Category-&gt;getCategories('71', 0, true, false, true)
#4 /var/www/toshno/vendor/magento/module-catalog/Helper/Category.php(115): Magento\Catalog\Model\Category\Interceptor-&gt;getCategories('71', 0, true, false, true)
#5 /var/www/toshno/app/code/Magentice/Megamenu/Block/Topmenu.php(60): Magento\Catalog\Helper\Category-&gt;getStoreCategories(true, false, true)
#6 /var/www/toshno/app/code/Magentice/Megamenu/Block/Topmenu.php(192): Magentice\Megamenu\Block\Topmenu-&gt;getStoreCategories(true, false, true)
#7 /var/www/toshno/app/design/frontend/Magentice/enhanced/Magentice_Megamenu/templates/topmenu.phtml(25): Magentice\Megamenu\Block\Topmenu-&gt;getMegamenuHtml()
#8 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/toshno...')
#9 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magentice\Megamenu\Block\Topmenu), '/var/www/toshno...', Array)
#10 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView('/var/www/toshno...')
#11 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()
#12 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()
#13 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock('mg.topnav')
#14 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('mg.topnav')
#15 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('mg.topnav')
#16 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('mg.topnav', true)
#17 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(512): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('mg.topnav', true)
#18 /var/www/toshno/vendor/magento/module-theme/view/frontend/templates/html/container.phtml(10): Magento\Framework\View\Element\AbstractBlock-&gt;getChildHtml()
#19 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/toshno...')
#20 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magento\Framework\View\Element\Template), '/var/www/toshno...', Array)
#21 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView('/var/www/toshno...')
#22 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()
#23 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()
#24 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock('store.menu')
#25 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('store.menu')
#26 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('store.menu')
#27 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('store.menu', true)
#28 /var/www/toshno/vendor/magento/module-theme/view/frontend/templates/html/sections.phtml(26): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('store.menu')
#29 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/toshno...')
#30 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magento\Framework\View\Element\Template), '/var/www/toshno...', Array)
#31 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView('/var/www/toshno...')
#32 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()
#33 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()
#34 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock('navigation.sect...')
#35 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('navigation.sect...')
#36 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('navigation.sect...')
#37 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('navigation.sect...', true)
#38 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(508): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('navigation.sect...', true)
#39 [internal function]: Magento\Framework\View\Element\AbstractBlock-&gt;getChildHtml('navigation.sect...')
#40 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(82): call_user_func_array(Array, Array)
#41 /var/www/toshno/app/design/frontend/Magentice/enhanced/Magentice_Enhanced/templates/html/header.phtml(357): Magento\Framework\View\TemplateEngine\Php-&gt;__call('getChildHtml', Array)
#42 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/toshno...')
#43 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magentice\Enhanced\Block\Template), '/var/www/toshno...', Array)
#44 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView('/var/www/toshno...')
#45 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()
#46 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()
#47 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock('enhanced_header')
#48 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('enhanced_header')
#49 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('enhanced_header')
#50 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('enhanced_header', false)
#51 /var/www/toshno/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('enhanced_header', false)
#52 /var/www/toshno/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout-&gt;_renderContainer('page.wrapper', false)
#53 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('page.wrapper')
#54 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('page.wrapper')
#55 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('page.wrapper', false)
#56 /var/www/toshno/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('page.wrapper', false)
#57 /var/www/toshno/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout-&gt;_renderContainer('root', false)
#58 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement('root')
#59 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement('root')
#60 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement('root', true)
#61 /var/www/toshno/vendor/magento/framework/View/Layout.php(954): Magento\Framework\View\Layout\Interceptor-&gt;renderElement('root')
#62 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout-&gt;getOutput()
#63 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor-&gt;___callParent('getOutput', Array)
#64 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor-&gt;Magento\Framework\Interception\{closure}()
#65 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(494): Magento\Framework\View\Layout\Interceptor-&gt;___callPlugins('getOutput', Array, Array)
#66 /var/www/toshno/vendor/magento/framework/View/Result/Page.php(258): Magento\Framework\View\Layout\Interceptor-&gt;getOutput()
#67 /var/www/toshno/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page-&gt;render(Object(Magento\Framework\App\Response\Http\Interceptor))
#68 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout-&gt;renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#69 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor-&gt;___callParent('renderResult', Array)
#70 /var/www/toshno/app/code/Potato/Compressor/Plugin/ControllerRenderResultAfter.php(58): Magento\Framework\View\Result\Page\Interceptor-&gt;Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#71 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(135): Potato\Compressor\Plugin\ControllerRenderResultAfter-&gt;aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))
#72 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor-&gt;Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#73 /var/www/toshno/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor-&gt;___callPlugins('renderResult', Array, NULL)
#74 /var/www/toshno/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\Page\Interceptor-&gt;renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#75 /var/www/toshno/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http-&gt;launch()
#76 /var/www/toshno/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor-&gt;launch()
#77 /var/www/toshno/index.php(39): Magento\Framework\App\Bootstrap-&gt;run(Object(Magento\Framework\App\Http\Interceptor))
#78 {main} [] []" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">[</span><span style="color: #AE81FF">2019</span><span style="color: #F92672">-</span><span style="color: #AE81FF">02</span><span style="color: #F92672">-</span><span style="color: #AE81FF">04</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">17</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">43</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">29</span><span style="color: #F8F8F2">] </span><span style="color: #AE81FF">main</span><span style="color: #F92672">.</span><span style="color: #AE81FF">ERROR</span><span style="color: #F8F8F2">: </span><span style="color: #AE81FF">Exception</span><span style="color: #F8F8F2">: </span><span style="color: #AE81FF">SELECT</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">`main_table`</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`entity_id`</span><span style="color: #F8F8F2">, </span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`name`</span><span style="color: #F8F8F2">, </span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`path`</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">`main_table`</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`is_active`</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">`main_table`</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`is_anchor`</span><span style="color: #F8F8F2">, </span><span style="color: #E6DB74">`url_rewrite`</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`request_path`</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">FROM</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">`catalog_category_flat_store_1`</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">AS</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">`main_table`</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">LEFT</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">JOIN</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">`url_rewrite`</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">ON</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F92672">.</span><span style="color: #AE81FF">entity_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #AE81FF">entity_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">AND</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F92672">.</span><span style="color: #AE81FF">is_autogenerated</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">AND</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F92672">.</span><span style="color: #AE81FF">store_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;1&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">AND</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F92672">.</span><span style="color: #AE81FF">entity_type</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;category&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">WHERE</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #AE81FF">is_active</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2">) </span><span style="color: #F92672">AND</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #AE81FF">include_in_menu</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;1&#39;</span><span style="color: #F8F8F2">) </span><span style="color: #F92672">AND</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">main_table</span><span style="color: #F92672">.</span><span style="color: #AE81FF">path</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">like</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;1/71/%&#39;</span><span style="color: #F8F8F2">) </span><span style="color: #AE81FF">ORDER</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">BY</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">`main_table`</span><span style="color: #F92672">.</span><span style="color: #E6DB74">`position`</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">ASC</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">in</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">/</span><span style="color: #66D9EF; font-style: italic">var</span><span style="color: #F92672">/</span><span style="color: #AE81FF">www</span><span style="color: #F92672">/</span><span style="color: #AE81FF">toshno</span><span style="color: #F92672">/</span><span style="color: #AE81FF">vendor</span><span style="color: #F92672">/</span><span style="color: #AE81FF">magento</span><span style="color: #F92672">/</span><span style="color: #AE81FF">module</span><span style="color: #F92672">-</span><span style="color: #AE81FF">catalog</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Model</span><span style="color: #F92672">/</span><span style="color: #AE81FF">ResourceModel</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Category</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Flat</span><span style="color: #F92672">.</span><span style="color: #AE81FF">php</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">304</span></span>
<span class="line"><span style="color: #AE81FF">Stack</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">trace</span><span style="color: #F8F8F2">:</span></span>
<span class="line"><span style="color: #88846F">#0 /var/www/toshno/vendor/magento/module-catalog/Model/ResourceModel/Category/Flat.php(376): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;_loadNodes(Object(Magento\Catalog\Model\Category\Interceptor), 0, &#39;1&#39;)</span></span>
<span class="line"><span style="color: #88846F">#1 /var/www/toshno/vendor/magento/module-catalog/Model/ResourceModel/Category/Flat.php(433): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;getNodes(&#39;71&#39;, 0, &#39;1&#39;)</span></span>
<span class="line"><span style="color: #88846F">#2 /var/www/toshno/vendor/magento/module-catalog/Model/Category.php(970): Magento\Catalog\Model\ResourceModel\Category\Flat-&gt;getCategories(&#39;71&#39;, 0, true, false, true)</span></span>
<span class="line"><span style="color: #88846F">#3 /var/www/toshno/generated/code/Magento/Catalog/Model/Category/Interceptor.php(466): Magento\Catalog\Model\Category-&gt;getCategories(&#39;71&#39;, 0, true, false, true)</span></span>
<span class="line"><span style="color: #88846F">#4 /var/www/toshno/vendor/magento/module-catalog/Helper/Category.php(115): Magento\Catalog\Model\Category\Interceptor-&gt;getCategories(&#39;71&#39;, 0, true, false, true)</span></span>
<span class="line"><span style="color: #88846F">#5 /var/www/toshno/app/code/Magentice/Megamenu/Block/Topmenu.php(60): Magento\Catalog\Helper\Category-&gt;getStoreCategories(true, false, true)</span></span>
<span class="line"><span style="color: #88846F">#6 /var/www/toshno/app/code/Magentice/Megamenu/Block/Topmenu.php(192): Magentice\Megamenu\Block\Topmenu-&gt;getStoreCategories(true, false, true)</span></span>
<span class="line"><span style="color: #88846F">#7 /var/www/toshno/app/design/frontend/Magentice/enhanced/Magentice_Megamenu/templates/topmenu.phtml(25): Magentice\Megamenu\Block\Topmenu-&gt;getMegamenuHtml()</span></span>
<span class="line"><span style="color: #88846F">#8 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#9 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magentice\Megamenu\Block\Topmenu), &#39;/var/www/toshno...&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#10 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#11 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()</span></span>
<span class="line"><span style="color: #88846F">#12 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()</span></span>
<span class="line"><span style="color: #88846F">#13 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock(&#39;mg.topnav&#39;)</span></span>
<span class="line"><span style="color: #88846F">#14 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;mg.topnav&#39;)</span></span>
<span class="line"><span style="color: #88846F">#15 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;mg.topnav&#39;)</span></span>
<span class="line"><span style="color: #88846F">#16 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;mg.topnav&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#17 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(512): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;mg.topnav&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#18 /var/www/toshno/vendor/magento/module-theme/view/frontend/templates/html/container.phtml(10): Magento\Framework\View\Element\AbstractBlock-&gt;getChildHtml()</span></span>
<span class="line"><span style="color: #88846F">#19 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#20 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magento\Framework\View\Element\Template), &#39;/var/www/toshno...&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#21 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#22 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()</span></span>
<span class="line"><span style="color: #88846F">#23 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()</span></span>
<span class="line"><span style="color: #88846F">#24 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock(&#39;store.menu&#39;)</span></span>
<span class="line"><span style="color: #88846F">#25 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;store.menu&#39;)</span></span>
<span class="line"><span style="color: #88846F">#26 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;store.menu&#39;)</span></span>
<span class="line"><span style="color: #88846F">#27 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;store.menu&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#28 /var/www/toshno/vendor/magento/module-theme/view/frontend/templates/html/sections.phtml(26): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;store.menu&#39;)</span></span>
<span class="line"><span style="color: #88846F">#29 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#30 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magento\Framework\View\Element\Template), &#39;/var/www/toshno...&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#31 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#32 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()</span></span>
<span class="line"><span style="color: #88846F">#33 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()</span></span>
<span class="line"><span style="color: #88846F">#34 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock(&#39;navigation.sect...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#35 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;navigation.sect...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#36 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;navigation.sect...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#37 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;navigation.sect...&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#38 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(508): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;navigation.sect...&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#39 [internal function]: Magento\Framework\View\Element\AbstractBlock-&gt;getChildHtml(&#39;navigation.sect...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#40 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(82): call_user_func_array(Array, Array)</span></span>
<span class="line"><span style="color: #88846F">#41 /var/www/toshno/app/design/frontend/Magentice/enhanced/Magentice_Enhanced/templates/html/header.phtml(357): Magento\Framework\View\TemplateEngine\Php-&gt;__call(&#39;getChildHtml&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#42 /var/www/toshno/vendor/magento/framework/View/TemplateEngine/Php.php(59): include(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#43 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php-&gt;render(Object(Magentice\Enhanced\Block\Template), &#39;/var/www/toshno...&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#44 /var/www/toshno/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template-&gt;fetchView(&#39;/var/www/toshno...&#39;)</span></span>
<span class="line"><span style="color: #88846F">#45 /var/www/toshno/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template-&gt;_toHtml()</span></span>
<span class="line"><span style="color: #88846F">#46 /var/www/toshno/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Element\AbstractBlock-&gt;toHtml()</span></span>
<span class="line"><span style="color: #88846F">#47 /var/www/toshno/vendor/magento/framework/View/Layout.php(533): Magento\Framework\View\Layout-&gt;_renderBlock(&#39;enhanced_header&#39;)</span></span>
<span class="line"><span style="color: #88846F">#48 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;enhanced_header&#39;)</span></span>
<span class="line"><span style="color: #88846F">#49 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;enhanced_header&#39;)</span></span>
<span class="line"><span style="color: #88846F">#50 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;enhanced_header&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#51 /var/www/toshno/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;enhanced_header&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#52 /var/www/toshno/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout-&gt;_renderContainer(&#39;page.wrapper&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#53 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;page.wrapper&#39;)</span></span>
<span class="line"><span style="color: #88846F">#54 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;page.wrapper&#39;)</span></span>
<span class="line"><span style="color: #88846F">#55 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;page.wrapper&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#56 /var/www/toshno/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;page.wrapper&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#57 /var/www/toshno/vendor/magento/framework/View/Layout.php(535): Magento\Framework\View\Layout-&gt;_renderContainer(&#39;root&#39;, false)</span></span>
<span class="line"><span style="color: #88846F">#58 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout-&gt;renderNonCachedElement(&#39;root&#39;)</span></span>
<span class="line"><span style="color: #88846F">#59 /var/www/toshno/vendor/magento/framework/View/Layout.php(488): Magento\Framework\View\Layout\Interceptor-&gt;renderNonCachedElement(&#39;root&#39;)</span></span>
<span class="line"><span style="color: #88846F">#60 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout-&gt;renderElement(&#39;root&#39;, true)</span></span>
<span class="line"><span style="color: #88846F">#61 /var/www/toshno/vendor/magento/framework/View/Layout.php(954): Magento\Framework\View\Layout\Interceptor-&gt;renderElement(&#39;root&#39;)</span></span>
<span class="line"><span style="color: #88846F">#62 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout-&gt;getOutput()</span></span>
<span class="line"><span style="color: #88846F">#63 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor-&gt;___callParent(&#39;getOutput&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#64 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor-&gt;Magento\Framework\Interception\{closure}()</span></span>
<span class="line"><span style="color: #88846F">#65 /var/www/toshno/generated/code/Magento/Framework/View/Layout/Interceptor.php(494): Magento\Framework\View\Layout\Interceptor-&gt;___callPlugins(&#39;getOutput&#39;, Array, Array)</span></span>
<span class="line"><span style="color: #88846F">#66 /var/www/toshno/vendor/magento/framework/View/Result/Page.php(258): Magento\Framework\View\Layout\Interceptor-&gt;getOutput()</span></span>
<span class="line"><span style="color: #88846F">#67 /var/www/toshno/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page-&gt;render(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#68 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout-&gt;renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#69 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor-&gt;___callParent(&#39;renderResult&#39;, Array)</span></span>
<span class="line"><span style="color: #88846F">#70 /var/www/toshno/app/code/Potato/Compressor/Plugin/ControllerRenderResultAfter.php(58): Magento\Framework\View\Result\Page\Interceptor-&gt;Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#71 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(135): Potato\Compressor\Plugin\ControllerRenderResultAfter-&gt;aroundRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Closure), Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#72 /var/www/toshno/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor-&gt;Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#73 /var/www/toshno/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor-&gt;___callPlugins(&#39;renderResult&#39;, Array, NULL)</span></span>
<span class="line"><span style="color: #88846F">#74 /var/www/toshno/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\Page\Interceptor-&gt;renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#75 /var/www/toshno/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http-&gt;launch()</span></span>
<span class="line"><span style="color: #88846F">#76 /var/www/toshno/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor-&gt;launch()</span></span>
<span class="line"><span style="color: #88846F">#77 /var/www/toshno/index.php(39): Magento\Framework\App\Bootstrap-&gt;run(Object(Magento\Framework\App\Http\Interceptor))</span></span>
<span class="line"><span style="color: #88846F">#78 {main} [] []</span></span></code></pre></div>
</div></div>



<p>After analyzing the back-trace code and getting the request, we see that it&#8217;s possible to reduce category selection by restricting the level of categories that will be displayed in the menu. We can do this with the parameter of the &#8216;catalog/navigation/max_depth&#8217; configuration. At the same time, we can optimize the request by adding additional indexes on the index table catalog_category_flat_store_1.</p>



<p>This is possible is because this is an index table and is recreated when the index is rebuilt by the createTable() method of the Magento\Catalog\Model\Indexer\Category\Flat\Action\Full class, while the method getFlatTableStructure() gets the table structure. Unfortunately, both methods are protected, so you can&#8217;t apply plugins to them, but you can redefine the indexer class using di.xml:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;preference for=&quot;Magento\Catalog\Model\Indexer\Category\Flat\Action\Full&quot; type=&quot;Web4pro\All\Model\Indexer\Category\Full&quot;/&gt;

And the class looks as follows:

class Full extends \Magento\Catalog\Model\Indexer\Category\Flat\Action\Full
{
    protected function getFlatTableStructure($tableName)
    {
        $table = parent::getFlatTableStructure($tableName);
        $table-&gt;addIndex('category_active_parent_id',array('is_active','parent_id'),array('type'=&gt;'index'));
        $table-&gt;addIndex('category_active_menu_level',array('is_active','include_in_menu','level','path'),array('type'=&gt;'index'));
        return $table;
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">preference</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">for=</span><span style="color: #E6DB74">&quot;Magento\Catalog\Model\Indexer\Category\Flat\Action\Full&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">type</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Web4pro\All\Model\Indexer\Category\Full&quot;</span><span style="color: #F92672">/&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F92672">And</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">the</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">class</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E; text-decoration: underline">looks</span><span style="color: #F8F8F2"> as follows:</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">class Full </span><span style="color: #F92672">extends</span><span style="color: #F8F8F2"> \Magento\Catalog\Model\Indexer\Category\Flat\Action\</span><span style="color: #A6E22E; font-style: italic; text-decoration: underline">Full</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">protected</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">getFlatTableStructure</span><span style="color: #F8F8F2">($tableName)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        $table </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">parent</span><span style="color: #F92672">::</span><span style="color: #A6E22E">getFlatTableStructure</span><span style="color: #F8F8F2">($tableName);</span></span>
<span class="line"><span style="color: #F8F8F2">        $table</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addIndex</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;category_active_parent_id&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #66D9EF">array</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;is_active&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #E6DB74">&#39;parent_id&#39;</span><span style="color: #F8F8F2">),</span><span style="color: #66D9EF">array</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;type&#39;</span><span style="color: #F92672">=&gt;</span><span style="color: #E6DB74">&#39;index&#39;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">        $table</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">addIndex</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;category_active_menu_level&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #66D9EF">array</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;is_active&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #E6DB74">&#39;include_in_menu&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #E6DB74">&#39;level&#39;</span><span style="color: #F8F8F2">,</span><span style="color: #E6DB74">&#39;path&#39;</span><span style="color: #F8F8F2">),</span><span style="color: #66D9EF">array</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&#39;type&#39;</span><span style="color: #F92672">=&gt;</span><span style="color: #E6DB74">&#39;index&#39;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $table;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>After rebuilding the Magento indexes, loading the page without the generated cache significantly sped up. All that remains is to take the logging code that helped solve the problem out of the core files.</p>



<p><strong>2. Migrating a site from Magento 1 to Magento 2. Data was migrated using a migration tool.</strong> Products on the Magento 1 site are updated by cron from a CSV file generated by the ERP system. With Magento 1, MAGMI is used for import, but this system can&#8217;t be used with Magento 2. Instead of MAGMI, we use the Firebear_ImportExport module, which supports the import of products by cron. The module also supports generating unique SEO URLs for products. However, the cron import task was found to not be ending successfully. When analyzing the exception.log file, the following message about the error was found</p>



<div class="wp-block-pb-accordion-item c-accordion__item js-accordion-item no-js" data-initially-open="false" data-click-to-close="true" data-auto-close="false" data-scroll="false" data-scroll-offset="0"><h4 id="at-82342" class="c-accordion__title js-accordion-controller" role="button">View code:</h4><div id="ac-82342" class="c-accordion__content">
<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[2019-02-06 08:34:27] main.CRITICAL: URL key for specified store already exists. {&quot;exception&quot;:&quot;[object] (Magento\\UrlRewrite\\Model\\Exception\\UrlAlreadyExistsException(code: 0): URL key for specified store already exists. at /home/magento/www/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:220, Magento\\Framework\\Exception\\AlreadyExistsException(code: 0): URL key for specified store already exists. at /home/magento/www/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:250, Magento\\Framework\\DB\\Adapter\\DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'skinny-charles-3-pc-4803.html-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/magento/www/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:580, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'skinny-charles-3-pc-4803.html-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID', query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/magento/www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'skinny-charles-3-pc-4803.html-1' for key 'URL_REWRITE_REQUEST_PATH_STORE_ID' at /home/magento/www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)&quot;} []" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">[</span><span style="color: #AE81FF">2019</span><span style="color: #F92672">-</span><span style="color: #AE81FF">02</span><span style="color: #F92672">-</span><span style="color: #AE81FF">06</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">08</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">34</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">27</span><span style="color: #F8F8F2">] </span><span style="color: #AE81FF">main</span><span style="color: #F92672">.</span><span style="color: #AE81FF">CRITICAL</span><span style="color: #F8F8F2">: </span><span style="color: #AE81FF">URL</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">key</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">for</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">specified</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">store</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">already</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">exists</span><span style="color: #F92672">.</span><span style="color: #F8F8F2"> {</span><span style="color: #E6DB74">&quot;exception&quot;</span><span style="color: #F8F8F2">:</span><span style="color: #E6DB74">&quot;[object] (Magento</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">UrlRewrite</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Model</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Exception</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">UrlAlreadyExistsException(code: 0): URL key for specified store already exists. at /home/magento/www/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:220, Magento</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Framework</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Exception</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">AlreadyExistsException(code: 0): URL key for specified store already exists. at /home/magento/www/vendor/magento/module-url-rewrite/Model/Storage/DbStorage.php:250, Magento</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Framework</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">DB</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Adapter</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">DuplicateException(code: 1062): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry &#39;skinny-charles-3-pc-4803.html-1&#39; for key &#39;URL_REWRITE_REQUEST_PATH_STORE_ID&#39;, query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/magento/www/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:580, Zend_Db_Statement_Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry &#39;skinny-charles-3-pc-4803.html-1&#39; for key &#39;URL_REWRITE_REQUEST_PATH_STORE_ID&#39;, query was: INSERT  INTO `url_rewrite` (`redirect_type`,`is_autogenerated`,`metadata`,`description`,`entity_type`,`entity_id`,`request_path`,`target_path`,`store_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) at /home/magento/www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry &#39;skinny-charles-3-pc-4803.html-1&#39; for key &#39;URL_REWRITE_REQUEST_PATH_STORE_ID&#39; at /home/magento/www/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)&quot;</span><span style="color: #F8F8F2">} []</span></span></code></pre></div>
</div></div>



<div class="wp-block-pb-accordion-item c-accordion__item js-accordion-item no-js" data-initially-open="false" data-click-to-close="true" data-auto-close="false" data-scroll="false" data-scroll-offset="0"><h4 id="at-82343" class="c-accordion__title js-accordion-controller" role="button">We query the database:</h4><div id="ac-82343" class="c-accordion__content">
<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="mysql&gt; select * from url_rewrite where request_path = 'skinny-charles-3-pc-4803.html'; 
 ---------------- ------------- ----------- ------------------------------- ------------------------------- --------------- ---------- ------------- ------------------ ----------  
| url_rewrite_id | entity_type | entity_id | request_path                  | target_path                   | redirect_type | store_id | description | is_autogenerated | metadata | 
 ---------------- ------------- ----------- ------------------------------- ------------------------------- --------------- ---------- ------------- ------------------ ----------  
|        1509442 | product     |      2496 | skinny-charles-3-pc-4803.html | skinny-charles-3-pc-7243.html |           301 |        1 | NULL        |                0 | NULL     | 
 ---------------- ------------- ----------- ------------------------------- ------------------------------- --------------- ---------- ------------- ------------------ ----------  
1 row in set (0,01 sec) 

mysql&gt; select * from url_rewrite where request_path = 'skinny-charles-3-pc-7243.html'; 
 ---------------- ------------- ----------- ------------------------------- ------------------------------ --------------- ---------- ------------- ------------------ ----------  
| url_rewrite_id | entity_type | entity_id | request_path                  | target_path                  | redirect_type | store_id | description | is_autogenerated | metadata | 
 ---------------- ------------- ----------- ------------------------------- ------------------------------ --------------- ---------- ------------- ------------------ ----------  
|        1508688 | product     |      2496 | skinny-charles-3-pc-7243.html | catalog/product/view/id/2496 |             0 |        1 | NULL        |                1 | NULL     | 
 ---------------- ------------- ----------- ------------------------------- ------------------------------ --------------- ---------- ------------- ------------------ ----------  
1 row in set (0,00 sec)" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #AE81FF">mysql</span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">select</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">*</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">from</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">where</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">request_path</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;skinny-charles-3-pc-4803.html&#39;</span><span style="color: #F8F8F2">; </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">entity_type</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">entity_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">request_path</span><span style="color: #F8F8F2">                  </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">target_path</span><span style="color: #F8F8F2">                   </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">redirect_type</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">store_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">description</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">is_autogenerated</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">metadata</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #F92672">|</span><span style="color: #F8F8F2">        </span><span style="color: #AE81FF">1509442</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">product</span><span style="color: #F8F8F2">     </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">      </span><span style="color: #AE81FF">2496</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">skinny</span><span style="color: #F92672">-</span><span style="color: #AE81FF">charles</span><span style="color: #F92672">-</span><span style="color: #AE81FF">3</span><span style="color: #F92672">-</span><span style="color: #AE81FF">pc</span><span style="color: #F92672">-</span><span style="color: #AE81FF">4803.html</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">skinny</span><span style="color: #F92672">-</span><span style="color: #AE81FF">charles</span><span style="color: #F92672">-</span><span style="color: #AE81FF">3</span><span style="color: #F92672">-</span><span style="color: #AE81FF">pc</span><span style="color: #F92672">-</span><span style="color: #AE81FF">7243.html</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">           </span><span style="color: #AE81FF">301</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">        </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">NULL</span><span style="color: #F8F8F2">        </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">                </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">NULL</span><span style="color: #F8F8F2">     </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">row</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">in</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">set</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">,</span><span style="color: #AE81FF">01</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">sec</span><span style="color: #F8F8F2">) </span></span>
<span class="line"></span>
<span class="line"><span style="color: #AE81FF">mysql</span><span style="color: #F92672">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">select</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">*</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">from</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">where</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">request_path</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #E6DB74">&#39;skinny-charles-3-pc-7243.html&#39;</span><span style="color: #F8F8F2">; </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">url_rewrite_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">entity_type</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">entity_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">request_path</span><span style="color: #F8F8F2">                  </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">target_path</span><span style="color: #F8F8F2">                  </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">redirect_type</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">store_id</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">description</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">is_autogenerated</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">metadata</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #F92672">|</span><span style="color: #F8F8F2">        </span><span style="color: #AE81FF">1508688</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">product</span><span style="color: #F8F8F2">     </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">      </span><span style="color: #AE81FF">2496</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">skinny</span><span style="color: #F92672">-</span><span style="color: #AE81FF">charles</span><span style="color: #F92672">-</span><span style="color: #AE81FF">3</span><span style="color: #F92672">-</span><span style="color: #AE81FF">pc</span><span style="color: #F92672">-</span><span style="color: #AE81FF">7243.html</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">catalog</span><span style="color: #F92672">/</span><span style="color: #AE81FF">product</span><span style="color: #F92672">/</span><span style="color: #AE81FF">view</span><span style="color: #F92672">/</span><span style="color: #AE81FF">id</span><span style="color: #F92672">/</span><span style="color: #AE81FF">2496</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">             </span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">        </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">NULL</span><span style="color: #F8F8F2">        </span><span style="color: #F92672">|</span><span style="color: #F8F8F2">                </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">NULL</span><span style="color: #F8F8F2">     </span><span style="color: #F92672">|</span><span style="color: #F8F8F2"> </span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">---------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">-------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">------------------</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">----------</span><span style="color: #F8F8F2">  </span></span>
<span class="line"><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">row</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">in</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">set</span><span style="color: #F8F8F2"> (</span><span style="color: #AE81FF">0</span><span style="color: #F8F8F2">,</span><span style="color: #AE81FF">00</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">sec</span><span style="color: #F8F8F2">)</span></span></code></pre></div>
</div></div>



<p>It turns out that this URL had already been used for the product with ID 2496, and in the database, there&#8217;s a 301 redirect to this product&#8217;s page. But later it turned out that this 301 redirect leads to a 404 page anyway since the product had been Disabled and isn&#8217;t visible on the front end. This means that this 301 redirect can be deleted from the database without any negative consequences.</p>



<p><strong>3. The following message was found on the site when checking the exception.log file</strong></p>



<div class="wp-block-pb-accordion-item c-accordion__item js-accordion-item no-js" data-initially-open="false" data-click-to-close="true" data-auto-close="true" data-scroll="false" data-scroll-offset="0"><h4 id="at-82344" class="c-accordion__title js-accordion-controller" role="button">View code:</h4><div id="ac-82344" class="c-accordion__content">
<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="2019-02-11 13:00:03] main.CRITICAL: Warning: Missing argument 1 for Magento\Framework\Mview\View\Changelog::clear(), called in /home/magento/www/vendor/magento/framework/Interception/Interceptor.php on line 58 and defined in /home/magento/www/vendor/magento/framework/Mview/View/Changelog.php on line 116 {&quot;exception&quot;:&quot;[object] (Exception(code: 0): Warning: Missing argument 1 for Magento\\Framework\\Mview\\View\\Changelog::clear(), called in /home/magento/www/vendor/magento/framework/Interception/Interceptor.php on line 58 and defined in /home/magento/www/vendor/magento/framework/Mview/View/Changelog.php on line 116 at /home/magento/www/vendor/magento/framework/App/ErrorHandler.php:61)&quot;}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #AE81FF">2019</span><span style="color: #F92672">-</span><span style="color: #AE81FF">02</span><span style="color: #F92672">-</span><span style="color: #AE81FF">11</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">13</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">00</span><span style="color: #F8F8F2">:</span><span style="color: #AE81FF">03</span><span style="color: #F8F8F2">] </span><span style="color: #AE81FF">main</span><span style="color: #F92672">.</span><span style="color: #AE81FF">CRITICAL</span><span style="color: #F8F8F2">: </span><span style="color: #AE81FF">Warning</span><span style="color: #F8F8F2">: </span><span style="color: #AE81FF">Missing</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">argument</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">1</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">for</span><span style="color: #F8F8F2"> Magento\Framework\Mview\View\</span><span style="color: #66D9EF; font-style: italic">Changelog</span><span style="color: #F92672">::</span><span style="color: #A6E22E">clear</span><span style="color: #F8F8F2">(), </span><span style="color: #AE81FF">called</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">in</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">/</span><span style="color: #AE81FF">home</span><span style="color: #F92672">/</span><span style="color: #AE81FF">magento</span><span style="color: #F92672">/</span><span style="color: #AE81FF">www</span><span style="color: #F92672">/</span><span style="color: #AE81FF">vendor</span><span style="color: #F92672">/</span><span style="color: #AE81FF">magento</span><span style="color: #F92672">/</span><span style="color: #AE81FF">framework</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Interception</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Interceptor</span><span style="color: #F92672">.</span><span style="color: #AE81FF">php</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">on</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">line</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">58</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">and</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">defined</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">in</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">/</span><span style="color: #AE81FF">home</span><span style="color: #F92672">/</span><span style="color: #AE81FF">magento</span><span style="color: #F92672">/</span><span style="color: #AE81FF">www</span><span style="color: #F92672">/</span><span style="color: #AE81FF">vendor</span><span style="color: #F92672">/</span><span style="color: #AE81FF">magento</span><span style="color: #F92672">/</span><span style="color: #AE81FF">framework</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Mview</span><span style="color: #F92672">/</span><span style="color: #AE81FF">View</span><span style="color: #F92672">/</span><span style="color: #AE81FF">Changelog</span><span style="color: #F92672">.</span><span style="color: #AE81FF">php</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">on</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">line</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">116</span><span style="color: #F8F8F2"> {</span><span style="color: #E6DB74">&quot;exception&quot;</span><span style="color: #F8F8F2">:</span><span style="color: #E6DB74">&quot;[object] (Exception(code: 0): Warning: Missing argument 1 for Magento</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Framework</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Mview</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">View</span><span style="color: #AE81FF">\\</span><span style="color: #E6DB74">Changelog::clear(), called in /home/magento/www/vendor/magento/framework/Interception/Interceptor.php on line 58 and defined in /home/magento/www/vendor/magento/framework/Mview/View/Changelog.php on line 116 at /home/magento/www/vendor/magento/framework/App/ErrorHandler.php:61)&quot;</span><span style="color: #F8F8F2">}</span></span></code></pre></div>
</div></div>



<p>This error occurs when rebuilding indexes. Since the method is called in the Interceptor trait, the reason for the error is most likely a plugin that was written incorrectly. We check all the plugins defined in di.xml for the class<strong> Magento\Framework\Mview\View\Changelog</strong>. We find this definition in the Amasty Order Attributes module.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="&lt;type name=&quot;Magento\Framework\Mview\View\Changelog&quot;&gt;
    &lt;plugin name=&quot;Amasty_Orderattr::ChangelogPlugin&quot; type=&quot;Amasty\Orderattr\Model\Indexer\Mview\ChangelogPlugin&quot; /&gt;
&lt;/type&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">type</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Magento\Framework\Mview\View\Changelog&quot;</span><span style="color: #F92672">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">&lt;</span><span style="color: #AE81FF">plugin</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">name</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Amasty_Orderattr::ChangelogPlugin&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">type</span><span style="color: #F92672">=</span><span style="color: #E6DB74">&quot;Amasty\Orderattr\Model\Indexer\Mview\ChangelogPlugin&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">/&gt;</span></span>
<span class="line"><span style="color: #F92672">&lt;/</span><span style="color: #AE81FF">type</span><span style="color: #F92672">&gt;</span></span></code></pre></div>



<p>In module version 3.4.5 this class contains the following method:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function aroundClear(\Magento\Framework\Mview\View\Changelog $subject, \Closure $proceed) 
    { 
        if ($this-&gt;isAmastyView($subject)) { 
            $this-&gt;changelog-&gt;setViewId($subject-&gt;getViewId()); 
            return $this-&gt;changelog-&gt;clear(); 
        } else { 
            return $proceed(); 
        }" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">aroundClear</span><span style="color: #F8F8F2">(\Magento\Framework\Mview\View\</span><span style="color: #66D9EF; font-style: italic">Changelog</span><span style="color: #F8F8F2"> $subject, \</span><span style="color: #66D9EF; font-style: italic">Closure</span><span style="color: #F8F8F2"> $proceed) </span></span>
<span class="line"><span style="color: #F8F8F2">    { </span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isAmastyView</span><span style="color: #F8F8F2">($subject)) { </span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">changelog</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setViewId</span><span style="color: #F8F8F2">($subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getViewId</span><span style="color: #F8F8F2">()); </span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">changelog</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">clear</span><span style="color: #F8F8F2">(); </span></span>
<span class="line"><span style="color: #F8F8F2">        } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> { </span></span>
<span class="line"><span style="color: #F8F8F2">            </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $proceed(); </span></span>
<span class="line"><span style="color: #F8F8F2">        }</span></span></code></pre></div>



<pre class="wp-block-preformatted"> Since the original clear method of the class,<strong> Magento\Framework\Mview\View\Changelog</strong> looks like this in Magento 2.2.6:</pre>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function clear($versionId)
{
    $changelogTableName = $this-&gt;resource-&gt;getTableName($this-&gt;getName());
    if (!$this-&gt;connection-&gt;isTableExists($changelogTableName)) {
        throw new ChangelogTableNotExistsException(new Phrase(&quot;Table %1 does not exist&quot;, [$changelogTableName]));
    }
    $this-&gt;connection-&gt;delete($changelogTableName, ['version_id &lt; ?' =&gt; (int)$versionId]);
    return true;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">clear</span><span style="color: #F8F8F2">($versionId)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    $changelogTableName </span><span style="color: #F92672">=</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">resource</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getTableName</span><span style="color: #F8F8F2">(</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getName</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #F92672">!</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">connection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isTableExists</span><span style="color: #F8F8F2">($changelogTableName)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">throw</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">ChangelogTableNotExistsException</span><span style="color: #F8F8F2">(</span><span style="color: #F92672">new</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">Phrase</span><span style="color: #F8F8F2">(</span><span style="color: #E6DB74">&quot;Table %1 does not exist&quot;</span><span style="color: #F8F8F2">, [$changelogTableName]));</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">connection</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">delete</span><span style="color: #F8F8F2">($changelogTableName, [</span><span style="color: #E6DB74">&#39;version_id &lt; ?&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #F92672">=&gt;</span><span style="color: #F8F8F2"> (</span><span style="color: #66D9EF; font-style: italic">int</span><span style="color: #F8F8F2">)$versionId]);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #AE81FF">true</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>Since the method has the mandatory $versionId parameter, this error is thrown when attempting to call the parent method from the plugin. Amasty corrected this error in version 3.4.8, where the plugin method looks as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1.125rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="public function aroundClear(\Magento\Framework\Mview\View\Changelog $subject, \Closure $proceed, $versionId)
{
    if ($this-&gt;isAmastyView($subject)) {
        $this-&gt;changelog-&gt;setViewId($subject-&gt;getViewId());
        return $this-&gt;changelog-&gt;clear($versionId);
    } else {
        return $proceed($versionId);
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki monokai" style="background-color: #272822" tabindex="0"><code><span class="line"><span style="color: #F92672">public</span><span style="color: #F8F8F2"> </span><span style="color: #66D9EF; font-style: italic">function</span><span style="color: #F8F8F2"> </span><span style="color: #A6E22E">aroundClear</span><span style="color: #F8F8F2">(\Magento\Framework\Mview\View\</span><span style="color: #66D9EF; font-style: italic">Changelog</span><span style="color: #F8F8F2"> $subject, \</span><span style="color: #66D9EF; font-style: italic">Closure</span><span style="color: #F8F8F2"> $proceed, $versionId)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #F92672">if</span><span style="color: #F8F8F2"> (</span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">isAmastyView</span><span style="color: #F8F8F2">($subject)) {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">changelog</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">setViewId</span><span style="color: #F8F8F2">($subject</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">getViewId</span><span style="color: #F8F8F2">());</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> </span><span style="color: #FD971F">$this</span><span style="color: #F92672">-&gt;</span><span style="color: #F8F8F2">changelog</span><span style="color: #F92672">-&gt;</span><span style="color: #A6E22E">clear</span><span style="color: #F8F8F2">($versionId);</span></span>
<span class="line"><span style="color: #F8F8F2">    } </span><span style="color: #F92672">else</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #F92672">return</span><span style="color: #F8F8F2"> $proceed($versionId);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre></div>



<p>As you can see, the problem was caused by incompatibility between the module version and Magento version, and it was solved by updating the module.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Why Is Drupal Website Beneficial for Your Business?</title>
		<link>https://web4pro.net/blog-news/drupal-website-beneficial-business/</link>
		
		<dc:creator><![CDATA[web4pro_su]]></dc:creator>
		<pubDate>Thu, 21 Feb 2019 14:16:16 +0000</pubDate>
				<category><![CDATA[Explore Technology]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[online store]]></category>
		<guid isPermaLink="false">https://web4pro.net/?p=8115</guid>

					<description><![CDATA[Read about Drupal benefits and successful examples of stores that use this CMS as a base of their websites.]]></description>
										<content:encoded><![CDATA[<p>With technology developing so quickly, the most important decision when you make eCommerce website is which content management system to use. The CMS handles the functionality of the site. Select the right CMS, and your site will be scalable and easily accessible across a wide range of devices. To keep up with the times, online stores also need to offer simple navigation and a personalized experience rich with interactive elements.</p>
<p><strong>Drupal</strong> is a cutting edge CMS that offers top of the line digital solutions for all of your eCommerce needs. You might ask, “<em>What is the use of Drupal? Why should I decide to make a Drupal 8 store when there are so many other choices out there?</em>”</p>
<p>The answer is simple. Drupal offers customizability, flexibility, and security. It’s a modular, open source CMS that lets you tailor your site to your brand, functionality, and approach. It’s perfect for all businesses, from the largest to the smallest. Plus, its solid, versatile design lets you modify the site and develop it with a minimum of a hassle.</p>
<p>Let’s take a look at some of Drupal’s benefits and how some major companies have used Drupal sites to improve their business and reach new heights of success.</p>
<h2>Benefits of Drupal Web Platform</h2>
<p><img decoding="async" class="aligncenter size-full wp-image-8116" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083238/img16.jpg" alt="Drupal CMS Features" width="860" height="400" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083238/img16.jpg 860w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083238/img16-300x140.jpg 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083238/img16-640x298.jpg 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083238/img16-768x357.jpg 768w" sizes="(max-width: 860px) 100vw, 860px" /></p>
<p>When you create a website using Drupal, you tap into a wide range of benefits that are hard to find in any other CMS. First and foremost, customers want security. They want to be confident when entering their information to make a purchase.</p>
<p>Drupal Commerce <strong>offers the highest rated security</strong> currently available. It has never yet been subject to a widely exploited vulnerability, and regular patches and safeguard measures are issued to improve its safety continually.</p>
<p>Another great feature is that it is <strong>open source</strong> and has the backing of a <strong>strong Drupal community</strong> that exchanges ideas and innovations. Its unique design lets you add as many new web pages as you want without having to adjust the infrastructure.</p>
<p>Let’s have a look at the main benefits of Drupal:</p>
<h3>Flexibility</h3>
<p>Drupal 8 websites are modular, so they can be easily customized with thousands of plug-ins and modules to give you exactly the functionality you want.</p>
<p>It comes packed with custom features that can be modified, adjusted, and implemented as needed. These include features for social media, SEO, CRM, and security. Drupal also lets you manage and create many different types of content.</p>
<p>A site built with Drupal is designed to<strong> handle blogs, articles, polls, statistics, videos, </strong>and<strong> other content types</strong>. It lets you create content-rich sites for any niche, from media to marketing. Also, since it’s easy to edit design elements, the web page configurations can be made as simple or as complex as needed.</p>
<h3>Personalization and Great UX</h3>
<p>Your website is your storefront. It carries the theme and message of your brand. So, it needs to be personalized to reflect what you have to offer. Personalization is what makes the difference between a conversion and a bounce.</p>
<p>Drupal provides a <strong>broad range of themes </strong>and<strong> color pallets</strong> suitable for any purpose. Its advanced system is simple to build and maintain. Drupal comes stocked with built-in tools for user interface (UI) and user experience (UX).</p>
<p>The result is that you can offer the customer a targeted, interactive experience with intuitive navigation and a user-friendly interface. Plus, Drupal customer support is second to none. Whatever the needs of your site and your customer, they can be met with a minimum of hassle.</p>
<h3>Mobile-first Architecture</h3>
<p>There are more mobile devices in existence now than ever before, and they are more accessible to the global population. So, one of the most important things to keep your site competitive is to make it not only mobile-friendly but mobile first.</p>
<p>When sites are designed around desktop architecture, it can be challenging to optimize the mobile experience fully. Drupal 8 is designed with this trend in mind, suitable for desktop but <strong>designed mobile-first</strong>. This means that the Drupal mobile site comes fully optimized for mobile devices. This saves time and effort, as well as making sure that your site is accessible to anyone, anywhere.</p>
<h3>All-In-One: CMS for Different Business Needs</h3>
<p>Whatever you need for your eCommerce store, Drupal brings it within reach. Successful sites are based on customer needs. They guide them through discovery and purchase of products or services, making it a breeze for them to find any information they want along the way.</p>
<p>Drupal 8 eCommerce modules let you tailor site functionality to the user experience you’d like to provide. They let you connect with and engage the audience through Google Analytics modules, robust APIs, and a versatile system interface that can fit any system architecture you need.</p>
<p>Also, your Drupal store <strong>incorporates a wide range of features and tools that improve the experience for both developers and users</strong>. It is easy to develop a store in a short period, plus optimization and security is a strong side of Drupal CMS.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/how-to-start-ecommerce-business/" target="_self" rel="noopener" data-wpel-link="internal">Tips on How to Start an eCommerce Business</a></li>
</ul>
</div>
</div>
<h2>Drupal Great Website Examples</h2>
<p>The current trend is for static sites to dwindle and make room for dynamic content. The content management system needs to be robust, accessible through a range of digital contact points, and abreast of current trends in customer engagement. Drupal excels at eCommerce. This is reflected by the many high-profile companies that have used it for their eCommerce websites.</p>
<p>To give you the overall vision of the best Drupal eCommerce sites, we’ve prepared a list of them based on the most successful companies:</p>
<h3><a href="https://www.box.com/platform" target="_blank" rel="noopener">Box Platform</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8118" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2.png" alt="Box Platform" width="1600" height="798" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2-300x150.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2-1024x511.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2-640x319.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083236/Screenshot-2-768x383.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Box is a company that specializes in collaboration software and simple file sharing. All of their services are online, unlike Tesla. They’ve used Drupal to create a website that showcases their online solutions clearly and easily. It’s user-friendly and efficient, with a crisp professional feel.</p>
<p>The site gives direct access to their proprietary software and code, which can be integrated with other digital solutions, like Google Apps, IBM, Slack, and Office 365. Box currently services many high profile clients, including Pandora, Boston Scientific, and P&amp;G.</p>
<h3><a href="https://www.lush.com/" target="_blank" rel="noopener">LUSH</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8123" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6.png" alt="Lush Main Page" width="1520" height="892" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6.png 1520w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6-300x176.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6-1024x601.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6-640x376.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083229/Screenshot-6-768x451.png 768w" sizes="(max-width: 1520px) 100vw, 1520px" /></p>
<p>LUSH is a site that offers premium handmade soaps and body care supplies. Their site uses Drupal Commerce features to combine commerce and content, providing inspiring stories that reach users across the globe. Users can reach the site easily through any device.</p>
<p>The site is clean and streamlined. It engages the customer with an introduction page featuring the newest line and clear call to action buttons. The setup practically guarantees click-throughs.</p>
<div class="ufy-block">
<div class="ufy-block__wrapper">
<p class="ufy-block__label">Useful for you:</p>
<ul class="ufy-block__list">
<li class="ufy-block__item"><a href="https://web4pro.net/blog-news/best-ecommerce-tools-to-operate-your-business-successfully/" target="_self" rel="noopener" data-wpel-link="internal">Best eCommerce Tools to Operate Your Business Successfully</a></li>
</ul>
</div>
</div>
<h3><a href="https://business.pinterest.com/en" target="_blank" rel="noopener">Pinterest Business</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8120" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1.png" alt="Pinterest Business Main Page" width="1600" height="723" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1-300x136.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1-1024x463.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1-640x289.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083233/Screenshot-1-768x347.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Pinterest is a great place to share images, quotes, recipes, and other forms of online content. It’s image-rich and has a reach of over 175 million users. Pinterest Business was created as a branch of the parent site, designed for presented services and products to this Pinterest audience.</p>
<p>Once again, this is a Drupal store. It integrates seamlessly with the main website, which was built with Python. And easy is the keyword here. It’s simple to add subpages, implement additional functionalities, and integrate with external systems. Drupal has allowed Pinterest to link their existing audience with a new service in a fraction of the time required for making an entirely new website.</p>
<h3><a href="https://www.royalmail.com/" target="_blank" rel="noopener">Royal Mail</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8122" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5.png" alt="Royal Mail UK Main Page" width="1600" height="862" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5-300x162.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5-1024x552.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5-640x345.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083230/Screenshot-5-768x414.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Royal Mail is a UK based site that offers a wide range of solutions for delivering, receiving, and redirecting mail. It also allows customers to track items, buy and print postage, and pay fees online.</p>
<p>Drupal Commerce has allowed them to develop a simple REST API that serves and seamlessly integrates multiple sites. The result is a content data server that combines all of their many services into one easily accessible contact point.</p>
<h3><a href="https://www.savant.com/" target="_blank" rel="noopener">Savant</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8124" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1.png" alt="Savant Main Page" width="1600" height="754" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1-300x141.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1-1024x483.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1-640x302.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083227/Screenshot-1-1-768x362.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Savant is a service-oriented industry that offers home automation systems. Their goal was to craft an immersive experience with a modular CMS that is simple to maintain and update.</p>
<p>Drupal was the perfect solution. It offers strong performance, versatility, and a modular architecture that can be adjusted or scaled as necessary without a major overhaul to the whole site.</p>
<p>Platform longevity is key, as digital developments are moving so quickly that a poorly planned CMS can make the site obsolete in no time. This is especially important for Savant, as it is a technological service that is constantly expanding into new markets. The website reflects this, emphasizing imagery and animation and reflecting the feeling of the brand.</p>
<h3><a href="https://www.hermes.com/us/en/" target="_blank" rel="noopener">Hermès</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8194" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15.png" alt="Hermès Home Page" width="1785" height="884" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15.png 1785w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15-300x149.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15-1024x507.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15-640x317.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/03/07083205/Screenshot-15-768x380.png 768w" sizes="(max-width: 1785px) 100vw, 1785px" /></p>
<p>Hermes offers a wide range of products including women’s clothing, menswear, perfume, and fashion accessories. Their site makes use of video plugins to feature fashion shows that present their clothing lines in all their glory. It is based on Drupal Commerce and we see that it works great for the business benefits.</p>
<p>It also has branded preloader, perfect site colors, and fonts that represent a brand and strengthen its positions in customers&#8217; mind. Besides smart design with various useful blocks to showcase products perfectly, it has high-quality images, and let customer complete the purchase. They offer a wide range of shipping and payment options and integrate their physical store with their online market with tools to find the brick and mortar shop nearest you.</p>
<h3><a href="https://www.manh.com/" target="_blank" rel="noopener">Manhattan</a></h3>
<p><img decoding="async" class="aligncenter size-full wp-image-8125" src="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1.png" alt="Manhattan Main Page" width="1600" height="750" srcset="https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1.png 1600w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1-300x141.png 300w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1-1024x480.png 1024w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1-640x300.png 640w, https://s3.eu-central-1.amazonaws.com/web4pro.net-new/wp-content/uploads/2019/02/07083226/Screenshot-2-1-768x360.png 768w" sizes="(max-width: 1600px) 100vw, 1600px" /></p>
<p>Manhattan Associates is a company based in connecting suppliers with buyers to build an entire supply chain. To broaden the client base and meet digital strategy goals, they decided to have a premium site built with Drupal 8.</p>
<p>With a global client base, Manhattan required marketing automation, integration with third-party services and tech, and translation services. Given that their operations work on a massive scope and have many moving parts, Manhattan also needed a site that could fully integrate the CRM and powerful editorial tools to educate customers and users in the best use of the services.</p>
<p>Their website is fast, responsive, and clean. The homepage offers testimonials, demos, and CTAs. This site is an example of the power of Drupal to coordinate a host of complex functions and different services.</p>
<p>As you can see, Drupal is being used by some of the biggest names in commerce by niches ranging from online services to physical products. With a CMS this robust and versatile, the sky’s the limit!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
